05e00d2c5c
* chore(acc): put permission gql in correct place * feat(acc): swap to new rvt import * fix(acc): add oda secrets * feat(acc): auth cookies * feat(acc): introduce integrations as workspace setting * feat(acc): create sync item from models * fix(acc): bump * fix(acc): naming lost in merge * feat(acc): no acc tab - table under settings * chore(acc): new sync but will disapper * feat(acc): see statuses over model list * chore(acc): fix return type * chore(acc): type saga * chore(acc): status badge * chore(acc): refactor acc gql (#5556) * checkpoint * fix(acc): refactor gql items * feat(acc): double button * chore(acc): gqlgen * fix(acc): model ids are not project ids * chore(acc): bump function version * chore(acc): split up clients * feat(acc): more-optimised gql folder fetching schema * feat(acc): acc folder contents gql impl * feat(acc): apollo cache optimisations * chore(acc): gqlgen * fix(acc): return something for * fix(acc): handle null values correctly * chore(acc): specify prod functions --------- Co-authored-by: Chuck Driesler <chuck@speckle.systems>
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { AccSyncItemStatuses } from '@/modules/acc/domain/acc/constants'
|
|
import type {
|
|
QueryAllAccSyncItems,
|
|
UpsertAccSyncItem
|
|
} from '@/modules/acc/domain/acc/operations'
|
|
import { logger } from '@/observability/logging'
|
|
|
|
type OnVersionAdded = (params: {
|
|
fileLineageUrn: string
|
|
fileVersionUrn: string
|
|
fileVersionIndex: number
|
|
}) => Promise<void>
|
|
|
|
export const onVersionAddedFactory =
|
|
(deps: {
|
|
queryAllAccSyncItems: QueryAllAccSyncItems
|
|
upsertAccSyncItem: UpsertAccSyncItem
|
|
}): OnVersionAdded =>
|
|
async ({ fileLineageUrn, fileVersionUrn, fileVersionIndex }) => {
|
|
for await (const syncItems of deps.queryAllAccSyncItems({
|
|
filter: { lineageUrn: fileLineageUrn }
|
|
})) {
|
|
for (const syncItem of syncItems) {
|
|
if (syncItem.accFileVersionIndex > fileVersionIndex) {
|
|
logger.warn(
|
|
{
|
|
syncItemId: syncItem.id,
|
|
currentVersion: syncItem.accFileVersionIndex,
|
|
incomingVersion: fileVersionIndex,
|
|
incomingAccFile: {
|
|
fileLineageUrn,
|
|
fileVersionUrn,
|
|
fileVersionIndex
|
|
}
|
|
},
|
|
'Received event for superseded version of sync item {syncItemId} - Current: {currentVersion} Incoming: {incomingVersion}'
|
|
)
|
|
continue
|
|
}
|
|
|
|
await deps.upsertAccSyncItem({
|
|
...syncItem,
|
|
status: AccSyncItemStatuses.pending,
|
|
accFileVersionIndex: fileVersionIndex,
|
|
accFileVersionUrn: fileVersionUrn
|
|
})
|
|
}
|
|
}
|
|
}
|