🏢 Organization Blocks
Organization blocks provide comprehensive functionality for organization management in Nodeblocks applications. These blocks handle organization lifecycle operations including creation, member management, and business logic.
🎯 Overview
Organization blocks are designed to:
- Manage organizations with full CRUD operations
- Handle member management and role assignments
- Provide organization validation and business rules
- Support multi-tenant application architecture
- Enable organization administration with comprehensive controls
📦 Block Types
🔍 Schemas
JSON Schema definitions for organization data validation:
- organizationSchema: Base organization entity structure
- createOrganizationSchema: Organization creation validation
- updateOrganizationSchema: Organization update validation
- getOrganizationSchema: Organization retrieval validation
- deleteOrganizationSchema: Organization deletion validation
- organizationMembersSchema: Member role assignments array
- upsertOrganizationMembersSchema: Upsert member roles payload
- getOrganizationMemberRoleSchema: Member role retrieval
- checkOrganizationMemberExistenceSchema: Member existence check
- findOrganizationMembersSchema: Members listing query
- deleteOrganizationMemberSchema: Member deletion validation
- findOrganizationsSchema: Organizations search with filtering and pagination
- findOrganizationsForMemberSchema: Organizations by member with optional roles and inheritance
- findOrganizationDescendantsSchema: Descendants retrieval with optional depth
- findChangeRequestsForOrganizationSchema: Change requests retrieval with pagination
- getOrganizationFollowersSchema: Organization followers retrieval with pagination support
- getCertificateUploadUrlSchema: Certificate upload URL generation validation
- createChangeRequestSchema: Change request creation validation
- updateOrganizationAsAdminSchema: Admin-level organization update validation
- findByOrganizationIdSchema: Organization-scoped resource retrieval validation
🔧 Blocks
Pure business logic functions for organization operations:
- createOrganization: Organization creation
- getOrganizationById: Organization data retrieval
- updateOrganization: Organization updates
- deleteOrganization: Organization deletion
- findOrganizations: Organization search and filtering
- calculateDirectMemberRole: Calculate a member's direct role
- checkOrganizationMemberExistence: Check if an identity is a member
- findOrganizationMembers: List members with pagination metadata
- upsertOrganizationMembers: Add/update members (merge with existing)
- deleteOrganizationMember: Remove a member from organization
- findOrganizationsForIdentity: Find organizations for a specific identity with optional role filtering
- findOrganizationsForMember: List organizations for a specific identity
- calculateChildAncestors: Calculate child ancestors from parent
- buildDescendantsQuery: Build query for descendant search
- buildOrganizationsForMemberByRoleQuery: Build MongoDB query for organizations by member role
- buildOrganizationsForMemberByIdsQuery: Build MongoDB query for organizations by member IDs
- buildOrganizationsWithDescendantsQuery: Build query for organizations with descendants
- buildOrganizationFollowersByFollowOrganizationIdQuery: Build MongoDB query for organization followers
- buildOrganizationIdFilter: Build organization ID filter for database queries
- generateSignedLogoUploadUrl: Generate signed URL for logo uploads
- normalizeCertificateImage: Normalize organization certificate image with signed URL
- normalizeCertificateImages: Normalize certificate images for multiple organizations
- normalizeLogoOfOwner: Normalize owner logo by converting objectId to signed URL
- normalizeLogosOfOwners: Normalize logos for multiple owners
- normalizeLogosOfPaginatedOwners: Normalize logo URLs for paginated organization owners
- deleteLogoOfOwner: Delete logo file from storage for an owner entity
- extractAncestors: Extract all unique ancestor organization IDs
- calculateInheritedMemberRole: Calculate highest inherited member role from ancestors
- calculateMemberRole: Calculate member role (direct or inherited) for organization and identity
- calculateMemberRoleForOrganizations: Calculate member role information for each organization in a list
- normalizeOrganizations: Normalize array of organizations by removing
_idfields - normalizeOrganization: Remove MongoDB
_idfield from organization data - normalizeOrganizationsForMember: Normalize organizations for member response
- findChangeRequests: Retrieve change requests for an organization
- normalizeChangeRequest: Normalize single change request with file URLs
- normalizeChangeRequests: Normalize array of change requests with file URLs
- validateOrganizationName: Organization name uniqueness validation
- createChangeRequest: Organization change request creation in database
- buildUpdateOrganizationAfterNewChangeRequestPayload: Organization audit status update payload after new change request
- validateAuditStatus: Organization audit status validation for change request workflows
- Error Classes: OrganizationBadRequestError, OrganizationChangeRequestDbError, OrganizationChangeRequestError, OrganizationNotFoundError
🧰 Handlers
Terminator and normalization handlers for API response formatting:
- normalizeOrganizationTerminator: Normalize single organization response
- normalizeOrganizationsListTerminator: Normalize organizations list response
- deleteOrganizationTerminator: Format 204 response for organization deletion
- normalizeOrganizationMemberExistenceTerminator: Normalize membership existence response
- normalizeOrganizationMembersListTerminator: Normalize members list response
- deleteOrganizationMemberTerminator: Format 204 response for member deletion
- upsertOrganizationMembersTerminator: Format 204 response for members upsert
🛣️ Routes
HTTP endpoint definitions for organization operations:
- createOrganizationRoute: POST
/organizationswith creation block - getOrganizationRoute: GET
/organizations/:organizationIdwith retrieval block - findOrganizationsRoute: GET
/organizationswith search and pagination - updateOrganizationRoute: PATCH
/organizations/:organizationIdwith update block - deleteOrganizationRoute: DELETE
/organizations/:organizationIdwith deletion block - getOrganizationMemberRoleRoute: GET
/organizations/:organizationId/members/:identityId/rolewith role retrieval - checkOrganizationMemberExistenceRoute: GET
/organizations/:organizationId/members/check-existencewith membership check - findOrganizationMembersRoute: GET
/organizations/:organizationId/memberswith members listing - upsertOrganizationMembersRoute: PATCH
/organizations/:organizationId/memberswith member upsert - deleteOrganizationMemberRoute: DELETE
/organizations/:organizationId/members/:identityIdwith member removal - findOrganizationsForMemberRoute: GET
/organizations/members/:identityIdwith identity organizations - findOrganizationDescendantsRoute: GET
/organizations/:organizationId/descendantswith descendants listing - getLogoUploadUrlRoute: GET
/organizations/:organizationId/logo-upload-urlwith signed URL generation - getCertificateUploadUrlRoute: GET
/organizations/:organizationId/certificate-upload-urlwith certificate signed URL generation - createChangeRequestRoute: POST
/organizations/:organizationId/change-requestswith change request creation - findChangeRequestsForOrganizationRoute: GET
/organizations/:organizationId/change-requestswith change requests retrieval - updateOrganizationAsAdminRoute: PATCH
/admin/organizations/:organizationId/with admin-level organization updates - getOrganizationFollowersRoute: GET
/organizations/:organizationId/followerswith followers retrieval and pagination
🚀 Features
Complete organization management features combining schemas, routes, and blocks:
- createOrganizationFeature: Organization creation with validation and routing
- getOrganizationFeatures: Retrieve individual organization
- findOrganizationsFeatures: Search organizations with filtering and pagination
- editOrganizationFeatures: Update organization with validation and routing
- deleteOrganizationFeatures: Delete organization
- getOrganizationMemberFeatures: Retrieve a member role within organization
- checkOrganizationMemberExistenceFeatures: Validate identity membership in organization
- findOrganizationMembersFeatures: List organization members with pagination
- findOrganizationsForMemberFeatures: List organizations for a specific identity
- editOrganizationMembersFeatures: Upsert organization members with validation
- deleteOrganizationMemberFeatures: Delete an organization member
- findOrganizationDescendantsFeatures: Retrieve descendant organizations
- getLogoUploadUrlFeature: Generate signed URL for logo upload
- getCertificateUploadUrlFeature: Generate signed URL for certificate upload
- createChangeRequestFeature: Organization change request creation with validation and audit tracking
- findChangeRequestsForOrganizationFeature: Retrieve and normalize organization change requests with pagination
- updateOrganizationAsAdminFeature: Admin-only organization updates with extended field access
- getOrganizationFollowersFeature: Retrieve organization followers with pagination and avatar normalization
✅ Validators
Validation functions for organization operations:
- hasOrgRole: Validates organization member role based on allowed roles and organization ID
- validateOrganizationAccess (deprecated): Legacy access validator; replaced by
hasOrgRole
View Organization Validators →
🔗 Related Documentation
- Organization Schemas - Organization data validation and contracts
- Organization Handlers - Organization business logic functions
- Organization Routes - HTTP endpoint definitions
- Organization Features - Complete organization management features
- Organization Validators - Organization validation functions