(org: OrganizationPayload)
| 106 | // written — never re-minted live, never renamed. A row the mirror does not |
| 107 | // hold is minted live (`insertOrganization`). |
| 108 | const upsertOrganization = async (org: OrganizationPayload) => { |
| 109 | const existing = await getOrganization(org.id); |
| 110 | if (existing) { |
| 111 | if (existing.deletedAt !== null) return existing; |
| 112 | const [updated] = await db |
| 113 | .update(organizations) |
| 114 | .set({ name: org.name, workosUpdatedAt: org.updatedAt }) |
| 115 | .where(and(eq(organizations.id, org.id), organizationAcceptsName(org.updatedAt))) |
| 116 | .returning(); |
| 117 | return updated ?? existing; |
| 118 | } |
| 119 | return insertOrganization(db, { |
| 120 | id: org.id, |
| 121 | name: org.name, |
| 122 | workosUpdatedAt: org.updatedAt, |
| 123 | deletedAt: null, |
| 124 | }); |
| 125 | }; |
| 126 | |
| 127 | return { |
| 128 | // --- Accounts --- |
nothing calls this directly
no test coverage detected