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)
}
/** 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 (
input: ActivityCreateInput,
demandDrafts: ActivityDemandDraft[] = [],

View file

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

View file

@ -3,9 +3,9 @@
import { revalidatePath } from 'next/cache'
import type { Payload } from 'payload'
import { assertCampaignDocCas } from '@/app/(campaign)/campanha/actions/assertCampaignDocCas'
import { nextStateDeputyIdsAfterMunicipalityMembership } from '@/lib/municipalityStateDeputyMembership'
import { uniqueRelationshipIds } from '@/lib/relationship'
import { assertOpsUpdatedAtCas } from '@/lib/schemas/opsCas'
import {
STATE_DEPUTY_CONFLICT_MESSAGE,
STATE_DEPUTY_STAFF_MESSAGE,
@ -138,28 +138,23 @@ export const setStateDeputyMunicipalitiesBatchRecord = async (
for (const municipalityId of uniqueMunicipalityIds) {
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
// (`canUpdateMunicipality` for advisors, `canManageCampaignStaffField`
// 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({
collection: 'municipality',
id: municipalityId,
depth: 0,
select: { stateDeputies: true, slug: true },
select: { stateDeputies: true, slug: true, updatedAt: true },
user: currentActor,
overrideAccess: false,
req,
})
assertOpsUpdatedAtCas(enforceCas, baseForMunicipality, municipality.updatedAt)
const currentStateDeputyIDs = uniqueRelationshipIds(municipality.stateDeputies)
const nextStateDeputyIDs = nextStateDeputyIdsAfterMunicipalityMembership(
currentStateDeputyIDs,
@ -218,6 +213,7 @@ export const setStateDeputyMunicipalitiesBatch = async (
return result
}
/** @public CAS entry for offline/hybrid batch municipality writes (OH13). */
export const setStateDeputyMunicipalitiesBatchCas = async (
input: StateDeputyMunicipalitiesBatchInput,
) => {