Skip to content
Sarj Workspace Sync

org-sync/google-identity-schema

@sarj-ai/workspace-sync/org-sync/google-identity-schema ยท Source

import { z } from "zod";
import { type IdentityWriteBudget } from "../identity-provisioning/identity-budget-contracts.ts";
import { type GoogleIdentityMaintenanceWriteGuard } from "../identity-sync/google-identity-maintenance-fence-error.ts";
import type { GoogleIdentityParentContext, GoogleIdentityParentDispatch } from "../identity-sync/google-identity-parent-boundary-schema.ts";
import { type Sleep } from "./http.ts";
export declare const SARJ_IDENTITY_SCHEMA_NAME = "SarjIdentity";
export declare const GoogleSchemaFieldSchema: z.ZodObject<{
displayName: z.ZodOptional<z.ZodString>;
etag: z.ZodOptional<z.ZodString>;
fieldId: z.ZodOptional<z.ZodString>;
fieldName: z.ZodString;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
kind: z.ZodOptional<z.ZodLiteral<"admin#directory#schema#fieldspec">>;
multiValued: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
numericIndexingSpec: z.ZodOptional<z.ZodObject<{
maxValue: z.ZodOptional<z.ZodNumber>;
minValue: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>>;
readAccessType: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export declare const GoogleWorkspaceSchemaSnapshotSchema: z.ZodObject<{
displayName: z.ZodString;
etag: z.ZodString;
fields: z.ZodArray<z.ZodObject<{
displayName: z.ZodOptional<z.ZodString>;
etag: z.ZodOptional<z.ZodString>;
fieldId: z.ZodOptional<z.ZodString>;
fieldName: z.ZodString;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
kind: z.ZodOptional<z.ZodLiteral<"admin#directory#schema#fieldspec">>;
multiValued: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
numericIndexingSpec: z.ZodOptional<z.ZodObject<{
maxValue: z.ZodOptional<z.ZodNumber>;
minValue: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>>;
readAccessType: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
kind: z.ZodOptional<z.ZodLiteral<"admin#directory#schema">>;
schemaId: z.ZodString;
schemaName: z.ZodString;
}, z.core.$strip>;
export declare const SarjIdentitySchemaFieldSchema: z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodLiteral<"STRING">;
indexed: z.ZodLiteral<true>;
multiValued: z.ZodLiteral<false>;
readAccessType: z.ZodLiteral<"ADMINS_AND_SELF">;
}, z.core.$strip>;
export type SarjIdentitySchemaField = z.output<typeof SarjIdentitySchemaFieldSchema>;
export type GoogleWorkspaceSchemaSnapshot = z.output<typeof GoogleWorkspaceSchemaSnapshotSchema>;
export declare const SarjIdentitySchemaManagedSliceSchema: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
export type SarjIdentitySchemaManagedSlice = z.output<typeof SarjIdentitySchemaManagedSliceSchema>;
export declare const SARJ_IDENTITY_SCHEMA_FIELDS: readonly [{
readonly fieldName: "githubLogin";
readonly fieldType: "STRING";
readonly indexed: true;
readonly multiValued: false;
readonly readAccessType: "ADMINS_AND_SELF";
}, {
readonly fieldName: "githubUserId";
readonly fieldType: "STRING";
readonly indexed: true;
readonly multiValued: false;
readonly readAccessType: "ADMINS_AND_SELF";
}];
export interface GoogleWorkspaceIdentitySchemaGateway {
addFields(snapshot: GoogleWorkspaceSchemaSnapshot, fields: readonly SarjIdentitySchemaField[]): Promise<void>;
createSchema(input: {
displayName: typeof SARJ_IDENTITY_SCHEMA_NAME;
fields: readonly SarjIdentitySchemaField[];
schemaName: typeof SARJ_IDENTITY_SCHEMA_NAME;
}): Promise<void>;
readSchema(schemaName: typeof SARJ_IDENTITY_SCHEMA_NAME): Promise<unknown>;
}
export declare const SarjIdentitySchemaPlanSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
after: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
before: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodLiteral<"STRING">;
indexed: z.ZodLiteral<true>;
multiValued: z.ZodLiteral<false>;
readAccessType: z.ZodLiteral<"ADMINS_AND_SELF">;
}, z.core.$strip>>;
kind: z.ZodLiteral<"add-fields">;
schemaId: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
after: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
before: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
issues: z.ZodArray<z.ZodString>;
kind: z.ZodLiteral<"blocked">;
}, z.core.$strict>, z.ZodObject<{
after: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
before: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodLiteral<"STRING">;
indexed: z.ZodLiteral<true>;
multiValued: z.ZodLiteral<false>;
readAccessType: z.ZodLiteral<"ADMINS_AND_SELF">;
}, z.core.$strip>>;
kind: z.ZodLiteral<"create">;
}, z.core.$strict>, z.ZodObject<{
after: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
before: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
kind: z.ZodLiteral<"unchanged">;
schemaId: z.ZodString;
}, z.core.$strict>], "kind">;
export type SarjIdentitySchemaPlan = z.output<typeof SarjIdentitySchemaPlanSchema>;
export type ExistingSarjIdentitySchemaPlan = Extract<SarjIdentitySchemaPlan, {
kind: "add-fields" | "unchanged";
}>;
export declare const ReviewedSarjIdentitySchemaSliceSchema: z.ZodObject<{
schemaId: z.ZodString;
managedSlice: z.ZodObject<{
fields: z.ZodArray<z.ZodObject<{
fieldName: z.ZodEnum<{
githubLogin: "githubLogin";
githubUserId: "githubUserId";
}>;
fieldType: z.ZodEnum<{
BOOL: "BOOL";
DATE: "DATE";
DOUBLE: "DOUBLE";
EMAIL: "EMAIL";
INT64: "INT64";
PHONE: "PHONE";
STRING: "STRING";
}>;
indexed: z.ZodBoolean;
multiValued: z.ZodBoolean;
readAccessType: z.ZodNullable<z.ZodString>;
}, z.core.$strict>>;
schemaName: z.ZodNullable<z.ZodString>;
}, z.core.$strict>;
}, z.core.$strict>;
export type ReviewedSarjIdentitySchemaSlice = z.output<typeof ReviewedSarjIdentitySchemaSliceSchema>;
export type SarjIdentitySchemaReconciliation = {
mode: "apply";
plan: Exclude<SarjIdentitySchemaPlan, {
kind: "blocked";
}>;
verified: true;
} | {
mode: "dry-run";
plan: SarjIdentitySchemaPlan;
};
export declare class SarjIdentitySchemaCompatibilityError extends Error {
readonly issues: readonly string[];
constructor(issues: readonly string[], options?: ErrorOptions);
}
export interface ISarjIdentitySchemaService {
applyPlan(plan: SarjIdentitySchemaPlan): Promise<SarjIdentitySchemaReconciliation>;
plan(): Promise<SarjIdentitySchemaPlan>;
readManagedSlice(): Promise<SarjIdentitySchemaManagedSlice>;
readReviewedSchema?(plan: ExistingSarjIdentitySchemaPlan): Promise<ReviewedSarjIdentitySchemaSlice>;
reconcile(mode: "apply" | "dry-run"): Promise<SarjIdentitySchemaReconciliation>;
}
export declare class SarjIdentitySchemaService implements ISarjIdentitySchemaService {
#private;
constructor(gateway: GoogleWorkspaceIdentitySchemaGateway);
applyPlan(reviewed: SarjIdentitySchemaPlan): Promise<SarjIdentitySchemaReconciliation>;
reconcile(mode: "apply" | "dry-run"): Promise<SarjIdentitySchemaReconciliation>;
plan(): Promise<SarjIdentitySchemaPlan>;
readManagedSlice(): Promise<SarjIdentitySchemaManagedSlice>;
readReviewedSchema(reviewed: ExistingSarjIdentitySchemaPlan): Promise<ReviewedSarjIdentitySchemaSlice>;
}
export declare const GoogleImmutableUserIdSchema: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
export declare const GitHubLoginSchema: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">;
export declare const GitHubUserIdSchema: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">;
export declare const GoogleGithubIdentitySchema: z.ZodObject<{
githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">;
githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">;
}, z.core.$strict>;
declare const GoogleCustomSchemasSnapshotSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
export declare const GoogleIdentityUserSnapshotSchema: z.ZodObject<{
archived: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
customSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
deletionTime: z.ZodOptional<z.ZodISODateTime>;
etag: z.ZodString;
id: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
primaryEmail: z.ZodEmail;
suspended: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, z.core.$strict>;
export type GoogleGithubIdentity = z.output<typeof GoogleGithubIdentitySchema>;
export type GoogleIdentityUserSnapshot = z.output<typeof GoogleIdentityUserSnapshotSchema>;
export interface GoogleWorkspaceIdentityUserGateway {
readUserById(userId: z.input<typeof GoogleImmutableUserIdSchema>, deadlineAtMs?: number): Promise<unknown>;
updateUser(input: {
expectedEtag: string;
identity: GoogleGithubIdentity;
preservedCustomSchemas: z.output<typeof GoogleCustomSchemasSnapshotSchema>;
userId: z.output<typeof GoogleImmutableUserIdSchema>;
parentDispatch?: GoogleIdentityParentDispatch;
maintenanceGuard?: GoogleIdentityMaintenanceWriteGuard;
}): Promise<void>;
}
export declare const GoogleGitHubIdentityPlanSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"blocked">;
reason: z.ZodEnum<{
deleted: "deleted";
inactive: "inactive";
"not-found": "not-found";
}>;
userId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
}, z.core.$strict>, z.ZodObject<{
current: z.ZodNullable<z.ZodObject<{
githubLogin: z.ZodOptional<z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">>;
githubUserId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">>;
}, z.core.$strict>>;
desired: z.ZodObject<{
githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">;
githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">;
}, z.core.$strict>;
kind: z.ZodLiteral<"update">;
user: z.ZodObject<{
etag: z.ZodString;
id: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
primaryEmail: z.ZodEmail;
}, z.core.$strict>;
}, z.core.$strict>, z.ZodObject<{
identity: z.ZodObject<{
githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">;
githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">;
}, z.core.$strict>;
kind: z.ZodLiteral<"unchanged">;
user: z.ZodObject<{
etag: z.ZodString;
id: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
primaryEmail: z.ZodEmail;
}, z.core.$strict>;
}, z.core.$strict>], "kind">;
export type GoogleGithubIdentityPlan = z.output<typeof GoogleGitHubIdentityPlanSchema>;
export type GoogleGithubIdentityReconciliation = {
mode: "apply";
plan: Exclude<GoogleGithubIdentityPlan, {
kind: "blocked";
}>;
verified: true;
} | {
mode: "dry-run";
plan: GoogleGithubIdentityPlan;
};
export interface IGoogleGithubIdentityService {
applyPlan(plan: GoogleGithubIdentityPlan, identityBudget?: IdentityWriteBudget, parentContext?: GoogleIdentityParentContext<GoogleGithubIdentityPlan>): Promise<GoogleGithubIdentityReconciliation>;
plan(input: {
desired: z.input<typeof GoogleGithubIdentitySchema>;
userId: z.input<typeof GoogleImmutableUserIdSchema>;
}): Promise<GoogleGithubIdentityPlan>;
planFromSnapshot(input: {
desired: z.input<typeof GoogleGithubIdentitySchema>;
user: unknown;
userId: z.input<typeof GoogleImmutableUserIdSchema>;
}): GoogleGithubIdentityPlan;
reconcile(input: {
desired: z.input<typeof GoogleGithubIdentitySchema>;
mode: "apply" | "dry-run";
userId: z.input<typeof GoogleImmutableUserIdSchema>;
}): Promise<GoogleGithubIdentityReconciliation>;
}
export declare const GoogleGithubIdentityApplyMaxProviderReads: number;
export declare const GoogleGithubIdentityParentApplyMaxProviderReads: number;
interface GoogleGithubIdentityServiceOptions {
readbackDelaysMs?: readonly number[];
sleep?: Sleep;
}
export declare class GoogleGithubIdentityService implements IGoogleGithubIdentityService {
#private;
constructor(gateway: GoogleWorkspaceIdentityUserGateway, options?: GoogleGithubIdentityServiceOptions);
applyPlan(reviewedInput: GoogleGithubIdentityPlan, identityBudget?: IdentityWriteBudget, parentContext?: GoogleIdentityParentContext<GoogleGithubIdentityPlan>): Promise<GoogleGithubIdentityReconciliation>;
plan(input: {
desired: z.input<typeof GoogleGithubIdentitySchema>;
userId: z.input<typeof GoogleImmutableUserIdSchema>;
}): Promise<GoogleGithubIdentityPlan>;
planFromSnapshot(input: {
desired: z.input<typeof GoogleGithubIdentitySchema>;
user: unknown;
userId: z.input<typeof GoogleImmutableUserIdSchema>;
}): GoogleGithubIdentityPlan;
reconcile(input: {
desired: z.input<typeof GoogleGithubIdentitySchema>;
mode: "apply" | "dry-run";
userId: z.input<typeof GoogleImmutableUserIdSchema>;
}): Promise<GoogleGithubIdentityReconciliation>;
}
export {};