'use strict';
import { eq } from 'drizzle-orm';
import { resourceNames } from '../../../../../../fd-toolbox/resources/resource-names.js';
import { getDbSchema } from '../../../../../db/db-schema.js';
import { getResourcesByName, createResourceDirectlyInDb, updateResource } from '../../../../../meta/server/db/db.js';
import { getQuery } from '../../../../../meta/server/web/drizzle.js';
import { applyFilterToQuery, getTableColumn, runQuery } from '../../../../../db/drizzle-queries.js';
import { createResource } from '../../../../../meta/server/resources/crud-resources.js';
import { dbInnerJoin } from '../../../../../db/db-connection.js';
import { schemaNames, columnNames } from '../../../../../db/constants/schema-names.js';

var __defProp=Object['defineProperty'],__name=(_0x50a6e7,_0x59a5c2)=>__defProp(_0x50a6e7,'name',{'value':_0x59a5c2,'configurable':!![]});async function getRoleToPermissions(){return getResourcesByName(resourceNames['roleToPermission']);}__name(getRoleToPermissions,'getRoleToPermissions');async function getRoleToPermissionsByRoleId(_0x53931e){const _0x496b8f=getDbSchema(),_0x45fbb6=_0x496b8f[schemaNames['roleToPermissionSchema']],{query:_0x5c2a58}=await getQuery(_0x45fbb6);return applyFilterToQuery(_0x5c2a58,eq(getTableColumn(_0x45fbb6,columnNames['roleId']),_0x53931e)),runQuery(_0x5c2a58);}__name(getRoleToPermissionsByRoleId,'getRoleToPermissionsByRoleId');async function getRoleToPermissionByPermissionTypes(_0x41f5f0){const _0x32c018=getDbSchema(),_0x47ead0=_0x32c018[schemaNames['permissionSchema']],_0x2c74f5=_0x32c018[schemaNames['roleToPermissionSchema']],{query:_0x504318}=await getQuery(_0x2c74f5,{'fields':_0x2c74f5});dbInnerJoin(_0x504318,_0x47ead0,eq(getTableColumn(_0x2c74f5,columnNames['permissionId']),getTableColumn(_0x47ead0,columnNames['id']))),applyFilterToQuery(_0x504318,eq(getTableColumn(_0x47ead0,columnNames['type']),_0x41f5f0));const _0x27c732=await runQuery(_0x504318);return _0x27c732['map'](_0x18e585=>_0x18e585['fields']);}__name(getRoleToPermissionByPermissionTypes,'getRoleToPermissionByPermissionTypes');async function createRoleToPermission(_0x7cc436){const _0x158603=await createResource(_0x7cc436,resourceNames['roleToPermission']);return _0x158603;}__name(createRoleToPermission,'createRoleToPermission');async function createRoleToPermissionDirectlyInDb(_0x1094e8){return createResourceDirectlyInDb(_0x1094e8,resourceNames['roleToPermission']);}__name(createRoleToPermissionDirectlyInDb,'createRoleToPermissionDirectlyInDb');async function updateRoleToPermission(_0x5aa2a1){const _0x2d9808=await updateResource(_0x5aa2a1,resourceNames['roleToPermission']);return _0x2d9808;}__name(updateRoleToPermission,'updateRoleToPermission');

export { createRoleToPermission, createRoleToPermissionDirectlyInDb, getRoleToPermissionByPermissionTypes, getRoleToPermissions, getRoleToPermissionsByRoleId, updateRoleToPermission };
