EXPECTED_BUCKET_OWNER = 437795906767 REQUIRED_COLUMNS = ["identity_id", "tenant_type", "tenant_uuid"] # Maps tenant_type from CSV to Neo4j node label TENANT_TYPE_TO_LABEL = { "parent_company": "ParentCompany", "company_brand": "CompanyBrand", "account": "Vendor", } # Query to check if identity exists IDENTITY_EXISTS_QUERY = """ MATCH (i:Identity {id: $identity_id}) RETURN i.id AS identityId """ def get_tenant_exists_query(tenant_label: str) -> str: """Return tenant exists query with label for index usage.""" return ( f"MATCH (t:{tenant_label} {{uuid: $tenant_uuid}}) RETURN t.uuid AS tenantUuid" ) def get_create_profile_query(tenant_label: str) -> str: """Return profile creation query with label for index usage.""" return f""" MATCH (i:Identity {{id: $identity_id}}) MATCH (t:{tenant_label} {{uuid: $tenant_uuid}}) MATCH (inc:IncrementId {{nodeName: 'Profile'}}) CALL apoc.atomic.add(inc, 'id', 1, 3) YIELD newValue AS increment WITH i, t, increment MERGE (i)-[:HAS_PROFILE]->(p:Profile {{profileType: 'SongwhipProfile'}})-[:HAS_ACCESS_TO]->(t) ON CREATE SET p.profileId = increment, p.profileName = 'SongwhipProfile', p.roles = ['songwhip'], p.uuid = randomUUID(), p.createdAt = datetime(), p.createdBy = 'lambda/songwhipProfileCreator', p.lastModifiedAt = datetime(), p.lastModifiedBy = 'lambda/songwhipProfileCreator', p.fullCatalogAccess = true RETURN i.id AS identityId, t.uuid AS tenantUuid """