Skip to content
Sarj Workspace Sync

workspace-directory/posthog-membership-plan

@sarj-ai/workspace-sync/workspace-directory/posthog-membership-plan ยท Source

import { z } from "zod";
import type { ActiveResourceLease } from "../identity-sync/resource-lease.ts";
import type { GoogleDirectoryUser } from "../org-sync/model.ts";
import { type PosthogManagedGrant } from "./posthog-managed-grant.ts";
import { type PosthogMembershipSnapshot } from "./posthog-membership-client.ts";
export { PosthogManagedGrantSchema, type PosthogManagedGrant, } from "./posthog-managed-grant.ts";
export declare const PosthogMembershipPolicySchema: z.ZodObject<{
origin: z.ZodEnum<{
"https://eu.posthog.com": "https://eu.posthog.com";
"https://us.posthog.com": "https://us.posthog.com";
}>;
organizationId: z.ZodString;
actorUuid: z.ZodString;
authorityGroupEmail: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
authorityGroupId: z.ZodString;
minimumGoogleUsers: z.ZodNumber;
adoptedGrants: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
email: z.ZodEmail;
evidence: z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"invitation">;
inviteId: z.core.$ZodBranded<z.ZodString, "PosthogInvitationId", "out">;
}, z.core.$strict>, z.ZodObject<{
kind: z.ZodLiteral<"membership">;
userUuid: z.core.$ZodBranded<z.ZodString, "PosthogUserUuid", "out">;
}, z.core.$strict>, z.ZodObject<{
kind: z.ZodLiteral<"accepted-invitation">;
inviteId: z.core.$ZodBranded<z.ZodString, "PosthogInvitationId", "out">;
userUuid: z.core.$ZodBranded<z.ZodString, "PosthogUserUuid", "out">;
}, z.core.$strict>], "kind">;
state: z.ZodLiteral<"managed">;
}, z.core.$strict>, z.ZodObject<{
googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
email: z.ZodEmail;
evidence: z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"invitation">;
inviteId: z.core.$ZodBranded<z.ZodString, "PosthogInvitationId", "out">;
}, z.core.$strict>, z.ZodObject<{
kind: z.ZodLiteral<"membership">;
userUuid: z.core.$ZodBranded<z.ZodString, "PosthogUserUuid", "out">;
}, z.core.$strict>, z.ZodObject<{
kind: z.ZodLiteral<"accepted-invitation">;
inviteId: z.core.$ZodBranded<z.ZodString, "PosthogInvitationId", "out">;
userUuid: z.core.$ZodBranded<z.ZodString, "PosthogUserUuid", "out">;
}, z.core.$strict>], "kind">;
state: z.ZodLiteral<"retired">;
}, z.core.$strict>], "state">>>;
}, z.core.$strict>;
export type PosthogMembershipPolicy = z.output<typeof PosthogMembershipPolicySchema>;
export declare const PosthogMembershipActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
type: z.ZodLiteral<"invite">;
}, z.core.$strict>, z.ZodObject<{
googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
type: z.ZodLiteral<"cancel-invite">;
inviteId: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
type: z.ZodLiteral<"remove-member">;
userUuid: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
type: z.ZodLiteral<"retire-grant">;
}, z.core.$strict>, z.ZodObject<{
googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
type: z.ZodLiteral<"bind-member">;
userUuid: z.ZodString;
}, z.core.$strict>], "type">;
export type PosthogMembershipAction = z.output<typeof PosthogMembershipActionSchema>;
export interface IPosthogManagedGrantRepository {
list(organizationId: string): Promise<PosthogManagedGrant[]>;
record(organizationId: string, grant: PosthogManagedGrant, lease: ActiveResourceLease): Promise<void>;
}
export interface PosthogMembershipPlan {
actions: PosthogMembershipAction[];
blockers: string[];
planHash: string;
}
interface PosthogMembershipPlanInput {
policy: PosthogMembershipPolicy;
desired: readonly {
googleUserId: string;
email: string;
}[];
googleUsers: readonly GoogleDirectoryUser[];
grants: readonly PosthogManagedGrant[];
provider: PosthogMembershipSnapshot;
}
export declare function planPosthogMemberships(input: PosthogMembershipPlanInput): Promise<PosthogMembershipPlan>;