MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / seedTarget

Function seedTarget

apps/cloud/src/auth/mirror-feeders.node.test.ts:1179–1218  ·  view source on GitHub ↗
(
    org: string,
    options: { readonly backfilled: boolean } = { backfilled: true },
  )

Source from the content-addressed store, hash-verified

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

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected