History

Feed the cloud membership mirror from login and member writes (#2004)

Rhys Sullivan committed 1 month ago

Commit ddfe3f51 parent 89f424633 files · +5374 −606Browse files

Showing the changes to apps/cloud/src/api (4 of 33 files). Show all

Unified · Split

4 files
  1. apps/cloud/src/api/layers.ts +3 −1
  2. apps/cloud/src/api/protected-api-key-auth.node.test.ts +9 −0
  3. apps/cloud/src/api/protected-jwt-auth.node.test.ts +9 −0
  4. apps/cloud/src/api/router.ts +4 −1
apps/cloud/src/api/layers.ts+3−1
@@ -56,7 +56,9 @@ export const BootSharedServices = Layer.mergeAll( · 55 unmodified lines
5656 // `AutumnService.Default` is provided HERE because the `createOrganization`
5757 // handler reads it for the free-organizations-per-user limit gate — one of the
5858 // few app-only billing touchpoints. (It is NOT on the neutral boot core.)
59−export const makeNonProtectedApiLive = (rsLive: Layer.Layer<DbService | UserStoreService>) =>
59+export const makeNonProtectedApiLive = (
60+ rsLive: Layer.Layer<DbService | UserStoreService | WorkOsMirror>,
61+) =>
6062 HttpApiBuilder.layer(NonProtectedApi).pipe(
6163 Layer.provide(Layer.mergeAll(CloudAuthPublicHandlers, CloudSessionAuthHandlers)),
6264 Layer.provide(requestScopedMiddleware(rsLive).layer),
apps/cloud/src/api/protected-api-key-auth.node.test.ts+9−0
@@ -68,18 +68,27 @@ const stubUsers = Layer.succeed(UserStoreService)({ · 67 unmodified lines
6868 upsertOrganization: async (org: { id: string; name: string }) => ({
6969 ...org,
7070 slug: `org-slug-${org.id}`,
71+ backfilledAt: null,
72+ deletedAt: null,
73+ workosUpdatedAt: null,
7174 createdAt,
7275 }),
7376 getOrganization: async (id: string) => ({
7477 id,
7578 name: `Org ${id}`,
7679 slug: `org-slug-${id}`,
80+ backfilledAt: null,
81+ deletedAt: null,
82+ workosUpdatedAt: null,
7783 createdAt,
7884 }),
7985 getOrganizationBySlug: async (slug: string) => ({
8086 id: "org_by_slug",
8187 name: `Org ${slug}`,
8288 slug,
89+ backfilledAt: null,
90+ deletedAt: null,
91+ workosUpdatedAt: null,
8392 createdAt,
8493 }),
8594 deleteOrganizationCascade: async () => {},
apps/cloud/src/api/protected-jwt-auth.node.test.ts+9−0
@@ -85,18 +85,27 @@ const stubUsers = Layer.succeed(UserStoreService)({ · 84 unmodified lines
8585 upsertOrganization: async (org: { id: string; name: string }) => ({
8686 ...org,
8787 slug: `org-slug-${org.id}`,
88+ backfilledAt: null,
89+ deletedAt: null,
90+ workosUpdatedAt: null,
8891 createdAt,
8992 }),
9093 getOrganization: async (id: string) => ({
9194 id,
9295 name: `Org ${id}`,
9396 slug: `org-slug-${id}`,
97+ backfilledAt: null,
98+ deletedAt: null,
99+ workosUpdatedAt: null,
94100 createdAt,
95101 }),
96102 getOrganizationBySlug: async (slug: string) => ({
97103 id: "org_by_slug",
98104 name: `Org ${slug}`,
99105 slug,
106+ backfilledAt: null,
107+ deletedAt: null,
108+ workosUpdatedAt: null,
100109 createdAt,
101110 }),
102111 deleteOrganizationCascade: async () => {},
apps/cloud/src/api/router.ts+4−1
@@ -4,6 +4,7 @@ import { HttpRouter } from "effect/unstable/http"; · 3 unmodified lines
44 import { RouterConfigLive, requestScopedMiddleware } from "@executor-js/api/server";
55
66 import { UserStoreService } from "../auth/context";
7+import { WorkOsMirror } from "../auth/workos-mirror";
78 import { DbService } from "../db/db";
89 import { makeAccountApiLive } from "../account/account-api";
910
@@ -29,7 +30,9 @@ import { makeProtectedApiLive } from "./protected"; · 19 unmodified lines
2930 // so tests can substitute a counting fake for `DbService.Live` and
3031 // assert per-request semantics — see
3132 // `apps/cloud/src/api.request-scope.node.test.ts`.
32−export const makeApiLive = (requestScopedLive: Layer.Layer<DbService | UserStoreService>) => {
33+export const makeApiLive = (
34+ requestScopedLive: Layer.Layer<DbService | UserStoreService | WorkOsMirror>,
35+) => {
3336 const BillingRoutesLive = AutumnRoutesLive.pipe(
3437 Layer.provide(requestScopedMiddleware(requestScopedLive).layer),
3538 );