(
org: string,
options: { readonly backfilled: boolean } = { backfilled: true },
)
| 1172 | // leaves every org) unless a test wants the unscanned state, so a seat |
| 1173 | // count reads the mirror rather than scanning WorkOS. |
| 1174 | const seedTarget = ( |
| 1175 | org: string, |
| 1176 | options: { readonly backfilled: boolean } = { backfilled: true }, |
| 1177 | ) => |
| 1178 | Effect.gen(function* () { |
| 1179 | const users = yield* UserStoreService; |
| 1180 | const mirror = yield* WorkOsMirror; |
| 1181 | yield* users.use("upsertOrganization", (s) => |
| 1182 | s.upsertOrganization({ |
| 1183 | id: org, |
| 1184 | name: `Org ${org}`, |
| 1185 | updatedAt: new Date(T1), |
| 1186 | }), |
| 1187 | ); |
| 1188 | yield* mirror.upsertMembership({ |
| 1189 | id: `om_${ADMIN}_${org}`, |
| 1190 | accountId: ADMIN, |
| 1191 | organizationId: org, |
| 1192 | role: "admin", |
| 1193 | status: "active", |
| 1194 | updatedAt: new Date(T1), |
| 1195 | }); |
| 1196 | yield* mirror.upsertMembership({ |
| 1197 | id: `om_${TARGET}_${org}`, |
| 1198 | accountId: TARGET, |
| 1199 | organizationId: org, |
| 1200 | role: "member", |
| 1201 | status: "active", |
| 1202 | updatedAt: new Date(T1), |
| 1203 | }); |
| 1204 | if (options.backfilled) { |
| 1205 | // An empty listing at T1 (nothing to tombstone: TARGET's row is |
| 1206 | // stamped T1, not before it) marks the org scanned as of T1. |
| 1207 | yield* mirror.applyOrganizationScan({ |
| 1208 | organizationId: org, |
| 1209 | listedAt: new Date(T1), |
| 1210 | members: [], |
| 1211 | }); |
| 1212 | } |
| 1213 | }); |
| 1214 | |
| 1215 | const membersOf = (org: string) => |
| 1216 | Effect.flatMap(MemberDirectory.asEffect(), (directory) => directory.members(org)); |
no outgoing calls
no test coverage detected