Skip to main content
Version: 🚧 Canary

🏢 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

View Organization Schemas →

🔧 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 _id fields
  • normalizeOrganization: Remove MongoDB _id field 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

View Organization Blocks →

🧰 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

View Organization Handlers →

🛣️ Routes

HTTP endpoint definitions for organization operations:

  • createOrganizationRoute: POST /organizations with creation block
  • getOrganizationRoute: GET /organizations/:organizationId with retrieval block
  • findOrganizationsRoute: GET /organizations with search and pagination
  • updateOrganizationRoute: PATCH /organizations/:organizationId with update block
  • deleteOrganizationRoute: DELETE /organizations/:organizationId with deletion block
  • getOrganizationMemberRoleRoute: GET /organizations/:organizationId/members/:identityId/role with role retrieval
  • checkOrganizationMemberExistenceRoute: GET /organizations/:organizationId/members/check-existence with membership check
  • findOrganizationMembersRoute: GET /organizations/:organizationId/members with members listing
  • upsertOrganizationMembersRoute: PATCH /organizations/:organizationId/members with member upsert
  • deleteOrganizationMemberRoute: DELETE /organizations/:organizationId/members/:identityId with member removal
  • findOrganizationsForMemberRoute: GET /organizations/members/:identityId with identity organizations
  • findOrganizationDescendantsRoute: GET /organizations/:organizationId/descendants with descendants listing
  • getLogoUploadUrlRoute: GET /organizations/:organizationId/logo-upload-url with signed URL generation
  • getCertificateUploadUrlRoute: GET /organizations/:organizationId/certificate-upload-url with certificate signed URL generation
  • createChangeRequestRoute: POST /organizations/:organizationId/change-requests with change request creation
  • findChangeRequestsForOrganizationRoute: GET /organizations/:organizationId/change-requests with change requests retrieval
  • updateOrganizationAsAdminRoute: PATCH /admin/organizations/:organizationId/ with admin-level organization updates
  • getOrganizationFollowersRoute: GET /organizations/:organizationId/followers with followers retrieval and pagination

View Organization Routes →

🚀 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

View Organization Features →

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 →