OH13: keep unused domain Cas entry points public for knip

After dropping the dead outbox enqueue paths, mark the still-shipped
createActivity/membership/stateDeputy Cas wrappers @public so knip
does not delete them while hybrid callers are unfinished.
This commit is contained in:
Cursor Agent 2026-08-02 03:17:41 +00:00
parent 2eec800511
commit 334713324b
No known key found for this signature in database
3 changed files with 15 additions and 29 deletions

View file

@ -375,7 +375,10 @@ export const createActivity = async (
return createActivityRecord(payload, actor, input, demandDrafts) return createActivityRecord(payload, actor, input, demandDrafts)
} }
/** Outbox entry for create — no CAS (new doc). */ /**
* Outbox / hybrid entry for create — no CAS (new doc).
* @public Kept as the CAS-named twin of `createActivity` for offline enqueue.
*/
export const createActivityCas = async ( export const createActivityCas = async (
input: ActivityCreateInput, input: ActivityCreateInput,
demandDrafts: ActivityDemandDraft[] = [], demandDrafts: ActivityDemandDraft[] = [],

View file

@ -3,7 +3,6 @@
import { revalidatePath } from 'next/cache' import { revalidatePath } from 'next/cache'
import type { Payload } from 'payload' import type { Payload } from 'payload'
import { assertCampaignDocCas } from '@/app/(campaign)/campanha/actions/assertCampaignDocCas'
import { nextMunicipalityIdsAfterLeadershipMembership } from '@/lib/leadershipMunicipalityMembership' import { nextMunicipalityIdsAfterLeadershipMembership } from '@/lib/leadershipMunicipalityMembership'
import { nextStateDeputyIdsAfterMembership } from '@/lib/leadershipStateDeputyMembership' import { nextStateDeputyIdsAfterMembership } from '@/lib/leadershipStateDeputyMembership'
import { relationshipId, uniqueRelationshipIds } from '@/lib/relationship' import { relationshipId, uniqueRelationshipIds } from '@/lib/relationship'
@ -437,7 +436,7 @@ const openLeadershipForRelationDelta = async <
collection: 'leadership', collection: 'leadership',
id: leadershipId, id: leadershipId,
depth: 0, depth: 0,
select: { [relation]: true } as Record<Relation, true>, select: { [relation]: true, updatedAt: true } as Record<Relation | 'updatedAt', true>,
user: currentActor, user: currentActor,
overrideAccess: false, overrideAccess: false,
req, req,
@ -474,14 +473,7 @@ export const setLeadershipStateDeputyMembershipRecord = async (
'stateDeputies', 'stateDeputies',
) )
await assertCampaignDocCas(payload, { assertOpsUpdatedAtCas(enforceCas, baseUpdatedAt, current.updatedAt)
collection: 'leadership',
id: leadershipId,
actor: currentActor,
enforceCas,
baseUpdatedAt,
req,
})
const currentStateDeputyIDs = uniqueRelationshipIds(current.stateDeputies) const currentStateDeputyIDs = uniqueRelationshipIds(current.stateDeputies)
const nextStateDeputyIDs = nextStateDeputyIdsAfterMembership( const nextStateDeputyIDs = nextStateDeputyIdsAfterMembership(
@ -540,6 +532,7 @@ export const setLeadershipStateDeputyMembership = async (
return leadership return leadership
} }
/** @public CAS entry for offline/hybrid membership writes (OH13). */
export const setLeadershipStateDeputyMembershipCas = async ( export const setLeadershipStateDeputyMembershipCas = async (
input: LeadershipStateDeputyMembershipInput, input: LeadershipStateDeputyMembershipInput,
) => { ) => {
@ -607,14 +600,7 @@ export const setLeadershipMunicipalitiesMembershipRecord = async (
'municipalities', 'municipalities',
) )
await assertCampaignDocCas(payload, { assertOpsUpdatedAtCas(enforceCas, baseUpdatedAt, current.updatedAt)
collection: 'leadership',
id: leadershipId,
actor: currentActor,
enforceCas,
baseUpdatedAt,
req,
})
const change = nextMunicipalityIdsAfterLeadershipMembership( const change = nextMunicipalityIdsAfterLeadershipMembership(
uniqueRelationshipIds(current.municipalities), uniqueRelationshipIds(current.municipalities),
@ -679,6 +665,7 @@ export const setLeadershipMunicipalitiesMembership = async (
return leadership return leadership
} }
/** @public CAS entry for offline/hybrid membership writes (OH13). */
export const setLeadershipMunicipalitiesMembershipCas = async ( export const setLeadershipMunicipalitiesMembershipCas = async (
input: LeadershipMunicipalitiesMembershipInput, input: LeadershipMunicipalitiesMembershipInput,
) => { ) => {

View file

@ -3,9 +3,9 @@
import { revalidatePath } from 'next/cache' import { revalidatePath } from 'next/cache'
import type { Payload } from 'payload' import type { Payload } from 'payload'
import { assertCampaignDocCas } from '@/app/(campaign)/campanha/actions/assertCampaignDocCas'
import { nextStateDeputyIdsAfterMunicipalityMembership } from '@/lib/municipalityStateDeputyMembership' import { nextStateDeputyIdsAfterMunicipalityMembership } from '@/lib/municipalityStateDeputyMembership'
import { uniqueRelationshipIds } from '@/lib/relationship' import { uniqueRelationshipIds } from '@/lib/relationship'
import { assertOpsUpdatedAtCas } from '@/lib/schemas/opsCas'
import { import {
STATE_DEPUTY_CONFLICT_MESSAGE, STATE_DEPUTY_CONFLICT_MESSAGE,
STATE_DEPUTY_STAFF_MESSAGE, STATE_DEPUTY_STAFF_MESSAGE,
@ -138,28 +138,23 @@ export const setStateDeputyMunicipalitiesBatchRecord = async (
for (const municipalityId of uniqueMunicipalityIds) { for (const municipalityId of uniqueMunicipalityIds) {
const baseForMunicipality = municipalityBaseUpdatedAt?.[String(municipalityId)] const baseForMunicipality = municipalityBaseUpdatedAt?.[String(municipalityId)]
await assertCampaignDocCas(payload, {
collection: 'municipality',
id: municipalityId,
actor: currentActor,
enforceCas,
baseUpdatedAt: baseForMunicipality,
req,
})
// Row + field access verify the município is in the actor's scope // Row + field access verify the município is in the actor's scope
// (`canUpdateMunicipality` for advisors, `canManageCampaignStaffField` // (`canUpdateMunicipality` for advisors, `canManageCampaignStaffField`
// for the field) — an out-of-scope município throws here. // for the field) — an out-of-scope município throws here.
// CAS stamp rides the same load (OH13) — avoid a second findByID.
const municipality = await payload.findByID({ const municipality = await payload.findByID({
collection: 'municipality', collection: 'municipality',
id: municipalityId, id: municipalityId,
depth: 0, depth: 0,
select: { stateDeputies: true, slug: true }, select: { stateDeputies: true, slug: true, updatedAt: true },
user: currentActor, user: currentActor,
overrideAccess: false, overrideAccess: false,
req, req,
}) })
assertOpsUpdatedAtCas(enforceCas, baseForMunicipality, municipality.updatedAt)
const currentStateDeputyIDs = uniqueRelationshipIds(municipality.stateDeputies) const currentStateDeputyIDs = uniqueRelationshipIds(municipality.stateDeputies)
const nextStateDeputyIDs = nextStateDeputyIdsAfterMunicipalityMembership( const nextStateDeputyIDs = nextStateDeputyIdsAfterMunicipalityMembership(
currentStateDeputyIDs, currentStateDeputyIDs,
@ -218,6 +213,7 @@ export const setStateDeputyMunicipalitiesBatch = async (
return result return result
} }
/** @public CAS entry for offline/hybrid batch municipality writes (OH13). */
export const setStateDeputyMunicipalitiesBatchCas = async ( export const setStateDeputyMunicipalitiesBatchCas = async (
input: StateDeputyMunicipalitiesBatchInput, input: StateDeputyMunicipalitiesBatchInput,
) => { ) => {