Add entity customer numbers and scope APIs via selected company.
Entity gets an optional unique-per-company number with allocate/peek/isNumberFree helpers. Company-scoped store methods no longer take companyId and resolve google_auth.selected_company instead.
This commit is contained in:
@@ -99,17 +99,17 @@ const MENU = {
|
||||
{
|
||||
value: 'unit.list',
|
||||
label: 'list',
|
||||
hint: 'googleAuthId, companyId → rows',
|
||||
hint: 'googleAuthId → rows',
|
||||
},
|
||||
{
|
||||
value: 'unit.upsert',
|
||||
label: 'upsert',
|
||||
hint: 'googleAuthId, companyId, JSON unit → row',
|
||||
hint: 'googleAuthId, JSON unit → row',
|
||||
},
|
||||
{
|
||||
value: 'unit.delete',
|
||||
label: 'delete',
|
||||
hint: 'googleAuthId, companyId, si',
|
||||
hint: 'googleAuthId, si',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -119,22 +119,22 @@ const MENU = {
|
||||
{
|
||||
value: 'companysetting.list',
|
||||
label: 'list',
|
||||
hint: 'googleAuthId, companyId, frontendOnly? → rows',
|
||||
hint: 'googleAuthId, frontendOnly? → rows',
|
||||
},
|
||||
{
|
||||
value: 'companysetting.get',
|
||||
label: 'get',
|
||||
hint: 'googleAuthId, companyId, key → row',
|
||||
hint: 'googleAuthId, key → row',
|
||||
},
|
||||
{
|
||||
value: 'companysetting.set',
|
||||
label: 'set',
|
||||
hint: 'googleAuthId, companyId, JSON setting → row',
|
||||
hint: 'googleAuthId, JSON setting → row',
|
||||
},
|
||||
{
|
||||
value: 'companysetting.delete',
|
||||
label: 'delete',
|
||||
hint: 'googleAuthId, companyId, key',
|
||||
hint: 'googleAuthId, key',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -144,56 +144,58 @@ const MENU = {
|
||||
{
|
||||
value: 'brand.list',
|
||||
label: 'list',
|
||||
hint: 'googleAuthId, companyId → rows',
|
||||
hint: 'googleAuthId → rows',
|
||||
},
|
||||
{
|
||||
value: 'brand.upsert',
|
||||
label: 'upsert',
|
||||
hint: 'googleAuthId, companyId, JSON brand → row',
|
||||
hint: 'googleAuthId, JSON brand → row',
|
||||
},
|
||||
{
|
||||
value: 'brand.delete',
|
||||
label: 'delete',
|
||||
hint: 'googleAuthId, companyId, id',
|
||||
hint: 'googleAuthId, id',
|
||||
},
|
||||
],
|
||||
},
|
||||
customergroup: {
|
||||
label: 'customergroup',
|
||||
items: [
|
||||
{ value: 'customergroup.list', label: 'list', hint: 'googleAuthId, companyId → rows' },
|
||||
{ value: 'customergroup.create', label: 'create', hint: 'googleAuthId, companyId, name → row' },
|
||||
{ value: 'customergroup.update', label: 'update', hint: 'googleAuthId, companyId, id, name → row' },
|
||||
{ value: 'customergroup.order', label: 'order', hint: 'googleAuthId, companyId, JSON customergroupIds → { customergroupIds }' },
|
||||
{ value: 'customergroup.delete', label: 'delete', hint: 'googleAuthId, companyId, id' },
|
||||
{ value: 'customergroup.list', label: 'list', hint: 'googleAuthId → rows' },
|
||||
{ value: 'customergroup.create', label: 'create', hint: 'googleAuthId, name → row' },
|
||||
{ value: 'customergroup.update', label: 'update', hint: 'googleAuthId, id, name → row' },
|
||||
{ value: 'customergroup.order', label: 'order', hint: 'googleAuthId, JSON customergroupIds → { customergroupIds }' },
|
||||
{ value: 'customergroup.delete', label: 'delete', hint: 'googleAuthId, id' },
|
||||
],
|
||||
},
|
||||
entity: {
|
||||
label: 'entity',
|
||||
items: [
|
||||
{ value: 'entity.list', label: 'list', hint: 'googleAuthId, companyId, customergroupId?|role=customer → rows' },
|
||||
{ value: 'entity.getById', label: 'getById', hint: 'googleAuthId, companyId, id → row' },
|
||||
{ value: 'entity.create', label: 'create', hint: 'googleAuthId, companyId, JSON → row' },
|
||||
{ value: 'entity.update', label: 'update', hint: 'googleAuthId, companyId, id, JSON → row' },
|
||||
{ value: 'entity.delete', label: 'delete', hint: 'googleAuthId, companyId, id' },
|
||||
{ value: 'entity.list', label: 'list', hint: 'googleAuthId, customergroupId?|role=customer → rows' },
|
||||
{ value: 'entity.getById', label: 'getById', hint: 'googleAuthId, id → row' },
|
||||
{ value: 'entity.create', label: 'create', hint: 'googleAuthId, JSON → row' },
|
||||
{ value: 'entity.update', label: 'update', hint: 'googleAuthId, id, JSON → row' },
|
||||
{ value: 'entity.delete', label: 'delete', hint: 'googleAuthId, id' },
|
||||
{ value: 'entity.peekNextNumber', label: 'peekNextNumber', hint: 'googleAuthId → next number' },
|
||||
{ value: 'entity.isNumberFree', label: 'isNumberFree', hint: 'googleAuthId, number, excludeEntityId? → bool' },
|
||||
],
|
||||
},
|
||||
entityaddress: {
|
||||
label: 'entityaddress',
|
||||
items: [
|
||||
{ value: 'entityaddress.list', label: 'list', hint: 'googleAuthId, companyId, entityId → rows' },
|
||||
{ value: 'entityaddress.create', label: 'create', hint: 'googleAuthId, companyId, entityId, JSON → row' },
|
||||
{ value: 'entityaddress.update', label: 'update', hint: 'googleAuthId, companyId, entityId, id, JSON → row' },
|
||||
{ value: 'entityaddress.delete', label: 'delete', hint: 'googleAuthId, companyId, entityId, id' },
|
||||
{ value: 'entityaddress.list', label: 'list', hint: 'googleAuthId, entityId → rows' },
|
||||
{ value: 'entityaddress.create', label: 'create', hint: 'googleAuthId, entityId, JSON → row' },
|
||||
{ value: 'entityaddress.update', label: 'update', hint: 'googleAuthId, entityId, id, JSON → row' },
|
||||
{ value: 'entityaddress.delete', label: 'delete', hint: 'googleAuthId, entityId, id' },
|
||||
],
|
||||
},
|
||||
entitycontact: {
|
||||
label: 'entitycontact',
|
||||
items: [
|
||||
{ value: 'entitycontact.list', label: 'list', hint: 'googleAuthId, companyId, entityId → rows' },
|
||||
{ value: 'entitycontact.create', label: 'create', hint: 'googleAuthId, companyId, entityId, JSON → row' },
|
||||
{ value: 'entitycontact.update', label: 'update', hint: 'googleAuthId, companyId, entityId, id, JSON → row' },
|
||||
{ value: 'entitycontact.delete', label: 'delete', hint: 'googleAuthId, companyId, entityId, id' },
|
||||
{ value: 'entitycontact.list', label: 'list', hint: 'googleAuthId, entityId → rows' },
|
||||
{ value: 'entitycontact.create', label: 'create', hint: 'googleAuthId, entityId, JSON → row' },
|
||||
{ value: 'entitycontact.update', label: 'update', hint: 'googleAuthId, entityId, id, JSON → row' },
|
||||
{ value: 'entitycontact.delete', label: 'delete', hint: 'googleAuthId, entityId, id' },
|
||||
],
|
||||
},
|
||||
supplier: {
|
||||
@@ -202,22 +204,22 @@ const MENU = {
|
||||
{
|
||||
value: 'supplier.list',
|
||||
label: 'list',
|
||||
hint: 'googleAuthId, companyId → rows',
|
||||
hint: 'googleAuthId → rows',
|
||||
},
|
||||
{
|
||||
value: 'supplier.create',
|
||||
label: 'create',
|
||||
hint: 'googleAuthId, companyId, name → row',
|
||||
hint: 'googleAuthId, name → row',
|
||||
},
|
||||
{
|
||||
value: 'supplier.update',
|
||||
label: 'update',
|
||||
hint: 'googleAuthId, companyId, id, name → row',
|
||||
hint: 'googleAuthId, id, name → row',
|
||||
},
|
||||
{
|
||||
value: 'supplier.delete',
|
||||
label: 'delete',
|
||||
hint: 'googleAuthId, companyId, id',
|
||||
hint: 'googleAuthId, id',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -227,27 +229,27 @@ const MENU = {
|
||||
{
|
||||
value: 'delivery.list',
|
||||
label: 'list',
|
||||
hint: 'googleAuthId, companyId → summaries',
|
||||
hint: 'googleAuthId → summaries',
|
||||
},
|
||||
{
|
||||
value: 'delivery.getById',
|
||||
label: 'getById',
|
||||
hint: 'googleAuthId, companyId, id → delivery',
|
||||
hint: 'googleAuthId, id → delivery',
|
||||
},
|
||||
{
|
||||
value: 'delivery.create',
|
||||
label: 'create',
|
||||
hint: 'googleAuthId, companyId, JSON body → delivery',
|
||||
hint: 'googleAuthId, JSON body → delivery',
|
||||
},
|
||||
{
|
||||
value: 'delivery.update',
|
||||
label: 'update',
|
||||
hint: 'googleAuthId, companyId, id, JSON patch → delivery',
|
||||
hint: 'googleAuthId, id, JSON patch → delivery',
|
||||
},
|
||||
{
|
||||
value: 'delivery.delete',
|
||||
label: 'delete',
|
||||
hint: 'googleAuthId, companyId, id',
|
||||
hint: 'googleAuthId, id',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -257,27 +259,27 @@ const MENU = {
|
||||
{
|
||||
value: 'quote.list',
|
||||
label: 'list',
|
||||
hint: 'googleAuthId, companyId → summaries',
|
||||
hint: 'googleAuthId → summaries',
|
||||
},
|
||||
{
|
||||
value: 'quote.getById',
|
||||
label: 'getById',
|
||||
hint: 'googleAuthId, companyId, id → quote',
|
||||
hint: 'googleAuthId, id → quote',
|
||||
},
|
||||
{
|
||||
value: 'quote.create',
|
||||
label: 'create',
|
||||
hint: 'googleAuthId, companyId, JSON body → quote',
|
||||
hint: 'googleAuthId, JSON body → quote',
|
||||
},
|
||||
{
|
||||
value: 'quote.update',
|
||||
label: 'update',
|
||||
hint: 'googleAuthId, companyId, id, JSON patch → quote',
|
||||
hint: 'googleAuthId, id, JSON patch → quote',
|
||||
},
|
||||
{
|
||||
value: 'quote.delete',
|
||||
label: 'delete',
|
||||
hint: 'googleAuthId, companyId, id',
|
||||
hint: 'googleAuthId, id',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -287,27 +289,27 @@ const MENU = {
|
||||
{
|
||||
value: 'order.list',
|
||||
label: 'list',
|
||||
hint: 'googleAuthId, companyId → summaries',
|
||||
hint: 'googleAuthId → summaries',
|
||||
},
|
||||
{
|
||||
value: 'order.getById',
|
||||
label: 'getById',
|
||||
hint: 'googleAuthId, companyId, id → order',
|
||||
hint: 'googleAuthId, id → order',
|
||||
},
|
||||
{
|
||||
value: 'order.create',
|
||||
label: 'create',
|
||||
hint: 'googleAuthId, companyId, JSON body → order',
|
||||
hint: 'googleAuthId, JSON body → order',
|
||||
},
|
||||
{
|
||||
value: 'order.update',
|
||||
label: 'update',
|
||||
hint: 'googleAuthId, companyId, id, JSON patch → order',
|
||||
hint: 'googleAuthId, id, JSON patch → order',
|
||||
},
|
||||
{
|
||||
value: 'order.delete',
|
||||
label: 'delete',
|
||||
hint: 'googleAuthId, companyId, id',
|
||||
hint: 'googleAuthId, id',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -319,7 +321,7 @@ const MENU = {
|
||||
{ value: 'category.move', label: 'move', hint: 'googleAuthId, id, parentId → row' },
|
||||
{ value: 'category.order', label: 'order', hint: 'googleAuthId, parentId, JSON categoryIds' },
|
||||
{ value: 'category.delete', label: 'delete', hint: 'googleAuthId, id' },
|
||||
{ value: 'category.getTreeForCompany', label: 'getTreeForCompany', hint: 'googleAuthId, companyId → rows' },
|
||||
{ value: 'category.getTreeForCompany', label: 'getTreeForCompany', hint: 'googleAuthId → rows' },
|
||||
{ value: 'category.getCategoryArticles', label: 'getCategoryArticles', hint: 'googleAuthId, categoryId → rows' },
|
||||
],
|
||||
},
|
||||
@@ -597,18 +599,14 @@ async function runMethod(client, action) {
|
||||
case 'unit.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.unit.list(Number(googleAuthId), Number(companyId)),
|
||||
await client.unit.list(Number(googleAuthId)),
|
||||
];
|
||||
}
|
||||
case 'unit.upsert': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const unitJson = await askText('unit JSON', {
|
||||
placeholder:
|
||||
'{"si":"ml","basesi":"l","basesifactor":0.001,"symbol":"ml","name":"Milliliter"}',
|
||||
@@ -629,7 +627,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.unit.upsert(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
JSON.parse(unitJson),
|
||||
),
|
||||
];
|
||||
@@ -637,27 +634,23 @@ async function runMethod(client, action) {
|
||||
case 'unit.delete': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const si = await askText('si', {
|
||||
validate: (v) => (!v?.trim() ? 'Required' : undefined),
|
||||
});
|
||||
if (si == null) return;
|
||||
await client.unit.delete(Number(googleAuthId), Number(companyId), si);
|
||||
await client.unit.delete(Number(googleAuthId), si);
|
||||
return ['ok', true];
|
||||
}
|
||||
case 'companysetting.list': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const frontendOnly = await askText('frontendOnly (true/false)', {
|
||||
placeholder: 'false',
|
||||
});
|
||||
if (frontendOnly == null) return;
|
||||
return [
|
||||
'result[]',
|
||||
await client.companysetting.list(Number(googleAuthId), Number(companyId), {
|
||||
await client.companysetting.list(Number(googleAuthId), {
|
||||
frontendOnly: frontendOnly.trim().toLowerCase() === 'true',
|
||||
}),
|
||||
];
|
||||
@@ -665,8 +658,6 @@ async function runMethod(client, action) {
|
||||
case 'companysetting.get': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const key = await askText('key', {
|
||||
validate: (v) => (!v?.trim() ? 'Required' : undefined),
|
||||
});
|
||||
@@ -679,7 +670,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.companysetting.get(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
key,
|
||||
{ frontendOnly: frontendOnly.trim().toLowerCase() === 'true' },
|
||||
),
|
||||
@@ -688,8 +678,6 @@ async function runMethod(client, action) {
|
||||
case 'companysetting.set': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const settingJson = await askText('setting JSON', {
|
||||
placeholder: '{"key":"theme","value":"dark","frontend":true}',
|
||||
validate: (v) => {
|
||||
@@ -709,7 +697,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.companysetting.set(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
JSON.parse(settingJson),
|
||||
),
|
||||
];
|
||||
@@ -717,15 +704,12 @@ async function runMethod(client, action) {
|
||||
case 'companysetting.delete': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const key = await askText('key', {
|
||||
validate: (v) => (!v?.trim() ? 'Required' : undefined),
|
||||
});
|
||||
if (key == null) return;
|
||||
await client.companysetting.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
key,
|
||||
);
|
||||
return ['ok', true];
|
||||
@@ -733,18 +717,14 @@ async function runMethod(client, action) {
|
||||
case 'brand.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.brand.list(Number(googleAuthId), Number(companyId)),
|
||||
await client.brand.list(Number(googleAuthId)),
|
||||
];
|
||||
}
|
||||
case 'brand.upsert': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const brandJson = await askText('brand JSON', {
|
||||
placeholder: '{"name":"Nike","gsprpinfo":"..."}',
|
||||
validate: (v) => {
|
||||
@@ -764,7 +744,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.brand.upsert(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
JSON.parse(brandJson),
|
||||
),
|
||||
];
|
||||
@@ -772,28 +751,22 @@ async function runMethod(client, action) {
|
||||
case 'brand.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('brand id');
|
||||
if (id == null) return;
|
||||
await client.brand.delete(Number(googleAuthId), Number(companyId), id);
|
||||
await client.brand.delete(Number(googleAuthId), id);
|
||||
return ['ok', true];
|
||||
}
|
||||
case 'customergroup.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.customergroup.list(Number(googleAuthId), Number(companyId)),
|
||||
await client.customergroup.list(Number(googleAuthId)),
|
||||
];
|
||||
}
|
||||
case 'customergroup.create': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const name = await askText('name', {
|
||||
validate: (v) => (!v?.trim() ? 'Required' : undefined),
|
||||
});
|
||||
@@ -802,7 +775,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.customergroup.create(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
{ name },
|
||||
),
|
||||
];
|
||||
@@ -810,8 +782,6 @@ async function runMethod(client, action) {
|
||||
case 'customergroup.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('customergroup id');
|
||||
if (id == null) return;
|
||||
const name = await askText('name', {
|
||||
@@ -822,7 +792,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.customergroup.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
{ name },
|
||||
),
|
||||
@@ -831,8 +800,6 @@ async function runMethod(client, action) {
|
||||
case 'customergroup.order': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const idsJson = await askText('customergroupIds JSON', {
|
||||
placeholder: '[3,1,2]',
|
||||
validate: (v) => {
|
||||
@@ -850,7 +817,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.customergroup.order(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
{ customergroupIds: JSON.parse(idsJson) },
|
||||
),
|
||||
];
|
||||
@@ -858,13 +824,10 @@ async function runMethod(client, action) {
|
||||
case 'customergroup.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('customergroup id');
|
||||
if (id == null) return;
|
||||
await client.customergroup.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
);
|
||||
return ['ok', true];
|
||||
@@ -872,8 +835,6 @@ async function runMethod(client, action) {
|
||||
case 'entity.list': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const roleRaw = await askText('role (customer|empty)', {
|
||||
placeholder: '',
|
||||
validate: (v) => {
|
||||
@@ -900,7 +861,7 @@ async function runMethod(client, action) {
|
||||
}
|
||||
return [
|
||||
'result[]',
|
||||
await client.entity.list(Number(googleAuthId), Number(companyId), {
|
||||
await client.entity.list(Number(googleAuthId), {
|
||||
customergroupId,
|
||||
role,
|
||||
}),
|
||||
@@ -909,15 +870,12 @@ async function runMethod(client, action) {
|
||||
case 'entity.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('entity id');
|
||||
if (id == null) return;
|
||||
return [
|
||||
'result',
|
||||
await client.entity.getById(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
),
|
||||
];
|
||||
@@ -925,10 +883,8 @@ async function runMethod(client, action) {
|
||||
case 'entity.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('entity JSON', {
|
||||
placeholder: '{"customergroupId":1,"name":"Acme","firstName":null}',
|
||||
placeholder: '{"customergroupId":1,"name":"Acme","firstName":null,"number":null}',
|
||||
validate: (v) => {
|
||||
if (!v?.trim()) return 'Required';
|
||||
try {
|
||||
@@ -943,7 +899,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.entity.create(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
JSON.parse(bodyJson),
|
||||
),
|
||||
];
|
||||
@@ -951,12 +906,10 @@ async function runMethod(client, action) {
|
||||
case 'entity.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('entity id');
|
||||
if (id == null) return;
|
||||
const patchJson = await askText('patch JSON', {
|
||||
placeholder: '{"name":"Acme","firstName":"Ada"}',
|
||||
placeholder: '{"name":"Acme","firstName":"Ada","number":"C-1"}',
|
||||
validate: (v) => {
|
||||
if (!v?.trim()) return 'Required';
|
||||
try {
|
||||
@@ -971,7 +924,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.entity.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
JSON.parse(patchJson),
|
||||
),
|
||||
@@ -980,29 +932,61 @@ async function runMethod(client, action) {
|
||||
case 'entity.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('entity id');
|
||||
if (id == null) return;
|
||||
await client.entity.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
);
|
||||
return ['ok', true];
|
||||
}
|
||||
case 'entity.peekNextNumber': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
return [
|
||||
'result',
|
||||
await client.entity.peekNextNumber(
|
||||
Number(googleAuthId),
|
||||
),
|
||||
];
|
||||
}
|
||||
case 'entity.isNumberFree': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const number = await askText('number', {
|
||||
validate: (v) => (v?.trim() ? undefined : 'Required'),
|
||||
});
|
||||
if (number == null) return;
|
||||
const excludeRaw = await askText('exclude entity id (optional)', {
|
||||
placeholder: 'leave empty',
|
||||
validate: (v) => {
|
||||
const t = v?.trim() ?? '';
|
||||
if (!t) return undefined;
|
||||
return /^\d+$/.test(t) ? undefined : 'Integer or empty';
|
||||
},
|
||||
});
|
||||
if (excludeRaw == null) return;
|
||||
const excludeEntityId = excludeRaw.trim()
|
||||
? Number(excludeRaw.trim())
|
||||
: null;
|
||||
return [
|
||||
'result',
|
||||
await client.entity.isNumberFree(
|
||||
Number(googleAuthId),
|
||||
number.trim(),
|
||||
excludeEntityId == null ? {} : { excludeEntityId },
|
||||
),
|
||||
];
|
||||
}
|
||||
case 'entityaddress.list': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const entityId = await askInt('entity id');
|
||||
if (entityId == null) return;
|
||||
return [
|
||||
'result[]',
|
||||
await client.entityaddress.list(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(entityId),
|
||||
),
|
||||
];
|
||||
@@ -1010,8 +994,6 @@ async function runMethod(client, action) {
|
||||
case 'entityaddress.create': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const entityId = await askInt('entity id');
|
||||
if (entityId == null) return;
|
||||
const bodyJson = await askText('address JSON', {
|
||||
@@ -1031,7 +1013,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.entityaddress.create(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(entityId),
|
||||
JSON.parse(bodyJson),
|
||||
),
|
||||
@@ -1040,8 +1021,6 @@ async function runMethod(client, action) {
|
||||
case 'entityaddress.update': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const entityId = await askInt('entity id');
|
||||
if (entityId == null) return;
|
||||
const id = await askInt('address id');
|
||||
@@ -1062,7 +1041,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.entityaddress.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(entityId),
|
||||
Number(id),
|
||||
JSON.parse(patchJson),
|
||||
@@ -1072,15 +1050,12 @@ async function runMethod(client, action) {
|
||||
case 'entityaddress.delete': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const entityId = await askInt('entity id');
|
||||
if (entityId == null) return;
|
||||
const id = await askInt('address id');
|
||||
if (id == null) return;
|
||||
await client.entityaddress.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(entityId),
|
||||
Number(id),
|
||||
);
|
||||
@@ -1089,15 +1064,12 @@ async function runMethod(client, action) {
|
||||
case 'entitycontact.list': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const entityId = await askInt('entity id');
|
||||
if (entityId == null) return;
|
||||
return [
|
||||
'result[]',
|
||||
await client.entitycontact.list(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(entityId),
|
||||
),
|
||||
];
|
||||
@@ -1105,8 +1077,6 @@ async function runMethod(client, action) {
|
||||
case 'entitycontact.create': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const entityId = await askInt('entity id');
|
||||
if (entityId == null) return;
|
||||
const bodyJson = await askText('contact JSON', {
|
||||
@@ -1125,7 +1095,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.entitycontact.create(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(entityId),
|
||||
JSON.parse(bodyJson),
|
||||
),
|
||||
@@ -1134,8 +1103,6 @@ async function runMethod(client, action) {
|
||||
case 'entitycontact.update': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const entityId = await askInt('entity id');
|
||||
if (entityId == null) return;
|
||||
const id = await askInt('contact id');
|
||||
@@ -1156,7 +1123,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.entitycontact.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(entityId),
|
||||
Number(id),
|
||||
JSON.parse(patchJson),
|
||||
@@ -1166,15 +1132,12 @@ async function runMethod(client, action) {
|
||||
case 'entitycontact.delete': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const entityId = await askInt('entity id');
|
||||
if (entityId == null) return;
|
||||
const id = await askInt('contact id');
|
||||
if (id == null) return;
|
||||
await client.entitycontact.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(entityId),
|
||||
Number(id),
|
||||
);
|
||||
@@ -1183,25 +1146,21 @@ async function runMethod(client, action) {
|
||||
case 'supplier.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.supplier.list(Number(googleAuthId), Number(companyId)),
|
||||
await client.supplier.list(Number(googleAuthId)),
|
||||
];
|
||||
}
|
||||
case 'supplier.create': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const name = await askText('name', {
|
||||
validate: (v) => (!v?.trim() ? 'Required' : undefined),
|
||||
});
|
||||
if (name == null) return;
|
||||
return [
|
||||
'result',
|
||||
await client.supplier.create(Number(googleAuthId), Number(companyId), {
|
||||
await client.supplier.create(Number(googleAuthId), {
|
||||
name,
|
||||
}),
|
||||
];
|
||||
@@ -1209,8 +1168,6 @@ async function runMethod(client, action) {
|
||||
case 'supplier.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('supplier id');
|
||||
if (id == null) return;
|
||||
const name = await askText('name', {
|
||||
@@ -1221,7 +1178,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.supplier.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
{ name },
|
||||
),
|
||||
@@ -1230,13 +1186,10 @@ async function runMethod(client, action) {
|
||||
case 'supplier.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('supplier id');
|
||||
if (id == null) return;
|
||||
await client.supplier.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
);
|
||||
return ['ok', true];
|
||||
@@ -1244,25 +1197,20 @@ async function runMethod(client, action) {
|
||||
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)),
|
||||
await client.delivery.list(Number(googleAuthId)),
|
||||
];
|
||||
}
|
||||
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),
|
||||
),
|
||||
];
|
||||
@@ -1270,8 +1218,6 @@ async function runMethod(client, action) {
|
||||
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}]}',
|
||||
@@ -1292,7 +1238,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.delivery.create(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
JSON.parse(bodyJson),
|
||||
),
|
||||
];
|
||||
@@ -1300,8 +1245,6 @@ async function runMethod(client, action) {
|
||||
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', {
|
||||
@@ -1323,7 +1266,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.delivery.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
JSON.parse(patchJson),
|
||||
),
|
||||
@@ -1332,13 +1274,10 @@ async function runMethod(client, action) {
|
||||
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];
|
||||
@@ -1346,25 +1285,20 @@ async function runMethod(client, action) {
|
||||
case 'quote.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.quote.list(Number(googleAuthId), Number(companyId)),
|
||||
await client.quote.list(Number(googleAuthId)),
|
||||
];
|
||||
}
|
||||
case 'quote.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('quote id');
|
||||
if (id == null) return;
|
||||
return [
|
||||
'result',
|
||||
await client.quote.getById(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
),
|
||||
];
|
||||
@@ -1372,8 +1306,6 @@ async function runMethod(client, action) {
|
||||
case 'quote.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('quote JSON', {
|
||||
placeholder:
|
||||
'{"number":"A-2026-001","date":"2026-09-01","entityId":12,"lines":[{"sku":"1","amount":10,"net":99.5,"tax":19}]}',
|
||||
@@ -1394,7 +1326,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.quote.create(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
JSON.parse(bodyJson),
|
||||
),
|
||||
];
|
||||
@@ -1402,8 +1333,6 @@ async function runMethod(client, action) {
|
||||
case 'quote.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('quote id');
|
||||
if (id == null) return;
|
||||
const patchJson = await askText('patch JSON', {
|
||||
@@ -1425,7 +1354,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.quote.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
JSON.parse(patchJson),
|
||||
),
|
||||
@@ -1434,13 +1362,10 @@ async function runMethod(client, action) {
|
||||
case 'quote.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('quote id');
|
||||
if (id == null) return;
|
||||
await client.quote.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
);
|
||||
return ['ok', true];
|
||||
@@ -1448,25 +1373,20 @@ async function runMethod(client, action) {
|
||||
case 'order.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.order.list(Number(googleAuthId), Number(companyId)),
|
||||
await client.order.list(Number(googleAuthId)),
|
||||
];
|
||||
}
|
||||
case 'order.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('order id');
|
||||
if (id == null) return;
|
||||
return [
|
||||
'result',
|
||||
await client.order.getById(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
),
|
||||
];
|
||||
@@ -1474,8 +1394,6 @@ async function runMethod(client, action) {
|
||||
case 'order.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('order JSON', {
|
||||
placeholder:
|
||||
'{"number":"B-2026-001","date":"2026-09-15","entityId":12,"lines":[{"sku":"1","amount":10,"net":99.5,"tax":19}]}',
|
||||
@@ -1496,7 +1414,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.order.create(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
JSON.parse(bodyJson),
|
||||
),
|
||||
];
|
||||
@@ -1504,8 +1421,6 @@ async function runMethod(client, action) {
|
||||
case 'order.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('order id');
|
||||
if (id == null) return;
|
||||
const patchJson = await askText('patch JSON', {
|
||||
@@ -1527,7 +1442,6 @@ async function runMethod(client, action) {
|
||||
'result',
|
||||
await client.order.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
JSON.parse(patchJson),
|
||||
),
|
||||
@@ -1536,13 +1450,10 @@ async function runMethod(client, action) {
|
||||
case 'order.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('order id');
|
||||
if (id == null) return;
|
||||
await client.order.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
);
|
||||
return ['ok', true];
|
||||
@@ -1657,11 +1568,9 @@ async function runMethod(client, action) {
|
||||
case 'category.getTreeForCompany': {
|
||||
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(googleAuthId), Number(companyId)),
|
||||
await client.category.getTreeForCompany(Number(googleAuthId)),
|
||||
];
|
||||
}
|
||||
case 'category.getCategoryArticles': {
|
||||
|
||||
Reference in New Issue
Block a user