import { adminCrudActionCompilerSpec, adminCrudColumnCompilerSpec, authConfigSpec, createPluginModule, } from '@baseplate-dev/project-builder-lib';
import { adminCrudManageRolesActionGenerator } from './generators/admin-crud-manage-roles-action/index.js';
import { adminCrudResetPasswordActionGenerator } from './generators/admin-crud-reset-password-action/index.js';
import { adminCrudRolesColumnGenerator } from './generators/admin-crud-roles-column/index.js';
function buildRolesColumnCompiler() {
    return {
        name: 'roles',
        compileColumn(definition, { order }) {
            return adminCrudRolesColumnGenerator({
                id: definition.id,
                label: definition.label,
                order,
            });
        },
    };
}
function buildManageRolesActionCompiler() {
    return {
        name: 'manage-roles',
        compileAction(definition, { order, definitionContainer }) {
            const authConfig = definitionContainer.pluginStore.use(authConfigSpec);
            return adminCrudManageRolesActionGenerator({
                order,
                position: definition.position,
                availableRoles: authConfig
                    .getAuthConfigOrThrow(definitionContainer.definition)
                    .roles.filter((r) => !r.builtIn),
            });
        },
    };
}
function buildResetPasswordActionCompiler() {
    return {
        name: 'reset-password',
        compileAction(definition, { order }) {
            return adminCrudResetPasswordActionGenerator({
                order,
                position: definition.position,
            });
        },
    };
}
export default createPluginModule({
    name: 'node',
    dependencies: {
        adminCrudActionCompiler: adminCrudActionCompilerSpec,
        adminCrudColumnCompiler: adminCrudColumnCompilerSpec,
    },
    initialize: ({ adminCrudActionCompiler, adminCrudColumnCompiler }) => {
        adminCrudActionCompiler.actions.addMany([
            buildManageRolesActionCompiler(),
            buildResetPasswordActionCompiler(),
        ]);
        adminCrudColumnCompiler.columns.add(buildRolesColumnCompiler());
    },
});
//# sourceMappingURL=node.js.map