Overview
OrgConfig represents organization-level settings, typically stored in org.yaml. Organizations group multiple projects and manage team members and infrastructure.
Class Definition
final class OrgConfig {
const OrgConfig({
required this.id,
required this.name,
this.members = const [],
this.infrastructureTargets = const [],
});
factory OrgConfig.fromMap(Map<String, dynamic> map);
Map<String, dynamic> toJson();
}
Properties
Unique organization identifier
Organization display name
members
List<OrgMember>
default:"[]"
List of organization members and their roles
Available infrastructure deployment targets
OrgMember
Represents a member of the organization:
Member’s role: "owner", "admin", "developer", "member", "viewer"
Usage
Basic Configuration
import 'package:applad_core/applad_core.dart';
final config = OrgConfig.fromMap(yamlData);
print('Organization: ${config.name} (${config.id})');
print('Members: ${config.members.length}');
for (final member in config.members) {
print('${member.email} - ${member.role}');
}
With Infrastructure Targets
id: acme-corp
name: ACME Corporation
infrastructure_targets:
- fly
- railway
- aws
- custom-server
members:
- email: [email protected]
role: owner
final config = OrgConfig.fromMap(yamlData);
print('Available deployment targets:');
for (final target in config.infrastructureTargets) {
print(' - $target');
}
Managing Members
final config = OrgConfig.fromMap(yamlData);
// Find owners
final owners = config.members
.where((m) => m.role == 'owner')
.toList();
print('Organization owners:');
for (final owner in owners) {
print(' ${owner.email}');
}
// Check if user is admin or owner
bool hasAdminAccess(String email) {
final member = config.members
.firstWhere(
(m) => m.email == email,
orElse: () => OrgMember(email: '', role: 'none'),
);
return member.role == 'owner' || member.role == 'admin';
}
Creating Programmatically
final config = OrgConfig(
id: 'startup-inc',
name: 'Startup Inc.',
members: [
OrgMember(email: '[email protected]', role: 'owner'),
OrgMember(email: '[email protected]', role: 'developer'),
OrgMember(email: '[email protected]', role: 'developer'),
],
infrastructureTargets: ['fly', 'railway'],
);
final json = config.toJson();
Member Roles
Role hierarchy and permissions:
- owner - Full control, billing access, can delete org
- admin - Manage members, projects, and settings
- developer - Create/deploy projects, manage resources
- member - View projects, limited modification
- viewer - Read-only access
final rolePermissions = {
'owner': ['all'],
'admin': ['manage_members', 'manage_projects', 'deploy'],
'developer': ['create_projects', 'deploy', 'manage_resources'],
'member': ['view_projects', 'edit_own'],
'viewer': ['view_only'],
};
bool canDeploy(OrgMember member) {
return ['owner', 'admin', 'developer'].contains(member.role);
}
Common Patterns
Team Structure
Multi-Cloud Setup
id: enterprise
name: Enterprise Corp
infrastructure_targets:
- aws-production
- aws-staging
- gcp-analytics
- azure-backup
- fly-preview
Source Location
packages/applad_core/lib/src/config/org_config.dart:4