(writes: Writes, write: WorkOsMirrorWrite)
| 971 | type Writes = ReturnType<typeof makeWrites>; |
| 972 | |
| 973 | const applyWrite = (writes: Writes, write: WorkOsMirrorWrite): Promise<WorkOsMirrorWriteOutcome> => |
| 974 | WorkOsMirrorWrite.$match(write, { |
| 975 | UpsertUser: async ({ user }) => ((await writes.upsertUser(user)) ? "applied" : "stale"), |
| 976 | UpsertMembership: async ({ membership }) => |
| 977 | (await writes.upsertMembership(membership)) ? "applied" : "stale", |
| 978 | UpsertMember: async ({ user, membership }) => { |
| 979 | await writes.upsertUser(user); |
| 980 | return (await writes.upsertMembership(membership)) ? "applied" : "stale"; |
| 981 | }, |
| 982 | DeleteMembership: async ({ membership, deletedAt }) => |
| 983 | (await writes.deleteMembership(membership, deletedAt)) ? "applied" : "absent", |
| 984 | DeleteUser: async ({ accountId, deletedAt }) => |
| 985 | (await writes.deleteUser(accountId, deletedAt)) ? "applied" : "absent", |
| 986 | RenameOrganization: ({ organizationId, name, updatedAt }) => |
| 987 | writes.renameOrganization(organizationId, name, updatedAt), |
| 988 | MarkOrganizationDeleted: async ({ organizationId, name, deletedAt }) => |
| 989 | (await writes.markOrganizationDeleted(organizationId, name, deletedAt)) |
| 990 | ? "applied" |
| 991 | : "absent", |
| 992 | }); |
| 993 | |
| 994 | // Compare-and-set the events cursor. Run inside a transaction this also |
| 995 | // LOCKS the cursor row until commit: a concurrent run's CAS waits here, then |
no outgoing calls
no test coverage detected