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:
@@ -2,7 +2,7 @@ import {
|
||||
LIST_BY_COMPANY,
|
||||
LIST_BY_COMPANY_FRONTEND,
|
||||
} from '../../sql/companysetting.js';
|
||||
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
|
||||
import resolveSelectedCompanyAccess from '../companyuser/resolveSelectedCompanyAccess.js';
|
||||
import shapeSetting from './shapeSetting.js';
|
||||
|
||||
/**
|
||||
@@ -13,14 +13,14 @@ import shapeSetting from './shapeSetting.js';
|
||||
*
|
||||
* @example
|
||||
* const fn = list(pool);
|
||||
* const settings = await fn(42, 1, { frontendOnly: true });
|
||||
* const settings = await fn(42, { frontendOnly: true });
|
||||
* // => [{ key, value, frontend }]
|
||||
*/
|
||||
export default function list(pool) {
|
||||
const access = resolveCompanyAccess(pool);
|
||||
const access = resolveSelectedCompanyAccess(pool);
|
||||
|
||||
return async (googleAuthId, companyId, { frontendOnly = false } = {}) => {
|
||||
await access(googleAuthId, companyId);
|
||||
return async (googleAuthId, { frontendOnly = false } = {}) => {
|
||||
const { companyId } = await access(googleAuthId);
|
||||
|
||||
const result = await pool
|
||||
.request()
|
||||
|
||||
Reference in New Issue
Block a user