@deepstructure/tenant-db
Advanced tools
Comparing version 2.3.2 to 2.4.0
1040
dist/index.d.ts
import { PostgrestClient } from '@supabase/postgrest-js'; | ||
import { MergeDeep } from 'type-fest'; | ||
@@ -421,886 +422,238 @@ type Json = string | number | boolean | null | { | ||
}; | ||
type PublicSchema = Database[Extract<keyof Database, "public">]; | ||
type Tables<PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & PublicSchema["Views"]) | { | ||
schema: keyof Database; | ||
}, TableName extends PublicTableNameOrOptions extends { | ||
schema: keyof Database; | ||
} ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & Database[PublicTableNameOrOptions["schema"]]["Views"]) : never = never> = PublicTableNameOrOptions extends { | ||
schema: keyof Database; | ||
} ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { | ||
Row: infer R; | ||
} ? R : never : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & PublicSchema["Views"]) ? (PublicSchema["Tables"] & PublicSchema["Views"])[PublicTableNameOrOptions] extends { | ||
Row: infer R; | ||
} ? R : never : never; | ||
type TablesInsert<PublicTableNameOrOptions extends keyof PublicSchema["Tables"] | { | ||
schema: keyof Database; | ||
}, TableName extends PublicTableNameOrOptions extends { | ||
schema: keyof Database; | ||
} ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] : never = never> = PublicTableNameOrOptions extends { | ||
schema: keyof Database; | ||
} ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { | ||
Insert: infer I; | ||
} ? I : never : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { | ||
Insert: infer I; | ||
} ? I : never : never; | ||
type TablesUpdate<PublicTableNameOrOptions extends keyof PublicSchema["Tables"] | { | ||
schema: keyof Database; | ||
}, TableName extends PublicTableNameOrOptions extends { | ||
schema: keyof Database; | ||
} ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] : never = never> = PublicTableNameOrOptions extends { | ||
schema: keyof Database; | ||
} ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { | ||
Update: infer U; | ||
} ? U : never : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { | ||
Update: infer U; | ||
} ? U : never : never; | ||
type Enums<PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] | { | ||
schema: keyof Database; | ||
}, EnumName extends PublicEnumNameOrOptions extends { | ||
schema: keyof Database; | ||
} ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] : never = never> = PublicEnumNameOrOptions extends { | ||
schema: keyof Database; | ||
} ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] ? PublicSchema["Enums"][PublicEnumNameOrOptions] : never; | ||
/** | ||
* Create a pre-configured, typed postgrest client for the tenant-db | ||
* Modify the Postgrest types to account for default values and other differences with Prisma/Postgres. | ||
*/ | ||
declare function createPostgrestClient(): PostgrestClient<{ | ||
type DatabaseModified = MergeDeep<Database, { | ||
public: { | ||
Views: {}; | ||
Functions: {}; | ||
Enums: { | ||
UserRole: "ADMIN" | "MEMBER"; | ||
}; | ||
CompositeTypes: {}; | ||
Tables: { | ||
_prisma_migrations: { | ||
Row: { | ||
applied_steps_count: number; | ||
checksum: string; | ||
finished_at: string | null; | ||
id: string; | ||
logs: string | null; | ||
migration_name: string; | ||
rolled_back_at: string | null; | ||
started_at: string; | ||
ApiKey: { | ||
Insert: Omit<Database["public"]["Tables"]["ApiKey"]["Insert"], "id" | "createdAt"> & { | ||
id?: string; | ||
createdAt?: string; | ||
}; | ||
Insert: { | ||
applied_steps_count?: number | undefined; | ||
checksum: string; | ||
finished_at?: string | null | undefined; | ||
id: string; | ||
logs?: string | null | undefined; | ||
migration_name: string; | ||
rolled_back_at?: string | null | undefined; | ||
started_at?: string | undefined; | ||
}; | ||
Update: { | ||
applied_steps_count?: number | undefined; | ||
checksum?: string | undefined; | ||
finished_at?: string | null | undefined; | ||
id?: string | undefined; | ||
logs?: string | null | undefined; | ||
migration_name?: string | undefined; | ||
rolled_back_at?: string | null | undefined; | ||
started_at?: string | undefined; | ||
}; | ||
Relationships: []; | ||
}; | ||
Application: { | ||
Row: { | ||
createdAt: string; | ||
domain: string; | ||
id: string; | ||
name: string; | ||
repo: string; | ||
status: string; | ||
teamId: string; | ||
updatedAt: string; | ||
Insert: Omit<Database["public"]["Tables"]["Application"]["Insert"], "id" | "createdAt"> & { | ||
id?: string; | ||
createdAt?: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
domain: string; | ||
id: string; | ||
name: string; | ||
repo: string; | ||
status: string; | ||
teamId: string; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
domain?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
repo?: string | undefined; | ||
status?: string | undefined; | ||
teamId?: string | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "Application_teamId_fkey"; | ||
columns: ["teamId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Team"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
Deployment: { | ||
Row: { | ||
applicationId: string; | ||
archive: string | null; | ||
bundle: string; | ||
createdAt: string; | ||
deployment: string | number | boolean | Json[] | { | ||
[x: string]: string | number | boolean | Json[] | any | null | undefined; | ||
} | null; | ||
gitSha: string; | ||
id: string; | ||
originEnv: string | null; | ||
status: string; | ||
statusInfo: string | null; | ||
updatedAt: string; | ||
Insert: Omit<Database["public"]["Tables"]["Deployment"]["Insert"], "id" | "createdAt"> & { | ||
id?: string; | ||
createdAt?: string; | ||
}; | ||
Insert: { | ||
applicationId: string; | ||
archive?: string | null | undefined; | ||
bundle: string; | ||
createdAt?: string | undefined; | ||
deployment: string | number | boolean | Json[] | { | ||
[x: string]: string | number | boolean | Json[] | any | null | undefined; | ||
} | null; | ||
gitSha: string; | ||
id: string; | ||
originEnv?: string | null | undefined; | ||
status: string; | ||
statusInfo?: string | null | undefined; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
applicationId?: string | undefined; | ||
archive?: string | null | undefined; | ||
bundle?: string | undefined; | ||
createdAt?: string | undefined; | ||
deployment?: string | number | boolean | Json[] | { | ||
[x: string]: string | number | boolean | Json[] | any | null | undefined; | ||
} | null | undefined; | ||
gitSha?: string | undefined; | ||
id?: string | undefined; | ||
originEnv?: string | null | undefined; | ||
status?: string | undefined; | ||
statusInfo?: string | null | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "Deployment_applicationId_fkey"; | ||
columns: ["applicationId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Application"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
EnvVar: { | ||
Row: { | ||
applicationId: string; | ||
createdAt: string; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
value: string; | ||
Insert: Omit<Database["public"]["Tables"]["EnvVar"]["Insert"], "id" | "createdAt"> & { | ||
id?: string; | ||
createdAt?: string; | ||
}; | ||
Insert: { | ||
applicationId: string; | ||
createdAt?: string | undefined; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
value: string; | ||
}; | ||
Update: { | ||
applicationId?: string | undefined; | ||
createdAt?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
updatedAt?: string | undefined; | ||
value?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "EnvVar_applicationId_fkey"; | ||
columns: ["applicationId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Application"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
Secret: { | ||
Row: { | ||
applicationId: string; | ||
createdAt: string; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
valueEnc: string; | ||
Insert: Omit<Database["public"]["Tables"]["Secret"]["Insert"], "id" | "createdAt"> & { | ||
id?: string; | ||
createdAt?: string; | ||
}; | ||
Insert: { | ||
applicationId: string; | ||
createdAt?: string | undefined; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
valueEnc: string; | ||
}; | ||
Update: { | ||
applicationId?: string | undefined; | ||
createdAt?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
updatedAt?: string | undefined; | ||
valueEnc?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "Secret_applicationId_fkey"; | ||
columns: ["applicationId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Application"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
SystemConfig: { | ||
Row: { | ||
createdAt: string; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
value: string; | ||
Insert: Omit<Database["public"]["Tables"]["SystemConfig"]["Insert"], "id" | "createdAt"> & { | ||
id?: string; | ||
createdAt?: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
value: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
updatedAt?: string | undefined; | ||
value?: string | undefined; | ||
}; | ||
Relationships: []; | ||
}; | ||
Team: { | ||
Row: { | ||
createdAt: string; | ||
emailDomain: string | null; | ||
id: string; | ||
name: string; | ||
status: string; | ||
updatedAt: string; | ||
Insert: Omit<Database["public"]["Tables"]["Team"]["Insert"], "id" | "createdAt"> & { | ||
id?: string; | ||
createdAt?: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
emailDomain?: string | null | undefined; | ||
id: string; | ||
name: string; | ||
status: string; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
emailDomain?: string | null | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
status?: string | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: []; | ||
}; | ||
TeamSecret: { | ||
Row: { | ||
createdAt: string; | ||
createdById: string; | ||
id: string; | ||
name: string; | ||
teamId: string; | ||
updatedAt: string; | ||
valueEnc: string; | ||
Insert: Omit<Database["public"]["Tables"]["TeamSecret"]["Insert"], "id" | "createdAt"> & { | ||
id?: string; | ||
createdAt?: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
createdById: string; | ||
id: string; | ||
name: string; | ||
teamId: string; | ||
updatedAt: string; | ||
valueEnc: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
createdById?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
teamId?: string | undefined; | ||
updatedAt?: string | undefined; | ||
valueEnc?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "TeamSecret_createdById_fkey"; | ||
columns: ["createdById"]; | ||
isOneToOne: false; | ||
referencedRelation: "User"; | ||
referencedColumns: ["id"]; | ||
}, { | ||
foreignKeyName: "TeamSecret_teamId_fkey"; | ||
columns: ["teamId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Team"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
User: { | ||
Row: { | ||
createdAt: string; | ||
email: string; | ||
githubId: string; | ||
githubUsername: string; | ||
id: string; | ||
isSuperUser: boolean; | ||
name: string; | ||
updatedAt: string; | ||
Insert: Omit<Database["public"]["Tables"]["User"]["Insert"], "id" | "createdAt" | "isSuperUser"> & { | ||
id?: string; | ||
createdAt?: string; | ||
isSuperUser?: boolean; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
email: string; | ||
githubId: string; | ||
githubUsername: string; | ||
id: string; | ||
isSuperUser?: boolean | undefined; | ||
name: string; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
email?: string | undefined; | ||
githubId?: string | undefined; | ||
githubUsername?: string | undefined; | ||
id?: string | undefined; | ||
isSuperUser?: boolean | undefined; | ||
name?: string | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: []; | ||
}; | ||
UserTeam: { | ||
Row: { | ||
role: "ADMIN" | "MEMBER"; | ||
teamId: string; | ||
userId: string; | ||
Insert: Omit<Database["public"]["Tables"]["UserTeam"]["Insert"], "role"> & { | ||
role?: Database["public"]["Enums"]["UserRole"]; | ||
}; | ||
Insert: { | ||
role?: "ADMIN" | "MEMBER" | undefined; | ||
teamId: string; | ||
userId: string; | ||
}; | ||
Update: { | ||
role?: "ADMIN" | "MEMBER" | undefined; | ||
teamId?: string | undefined; | ||
userId?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "UserTeam_teamId_fkey"; | ||
columns: ["teamId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Team"; | ||
referencedColumns: ["id"]; | ||
}, { | ||
foreignKeyName: "UserTeam_userId_fkey"; | ||
columns: ["userId"]; | ||
isOneToOne: false; | ||
referencedRelation: "User"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
ApiKey: { | ||
Row: { | ||
applicationId: string; | ||
createdAt: string; | ||
hashedSecret: string; | ||
id: string; | ||
identifier: string; | ||
lastUsedAt: string | null; | ||
name: string | null; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
applicationId?: string | undefined; | ||
createdAt?: string | undefined; | ||
hashedSecret?: string | undefined; | ||
id?: string | undefined; | ||
identifier?: string | undefined; | ||
lastUsedAt?: string | null | undefined; | ||
name?: string | null | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "ApiKey_applicationId_fkey"; | ||
columns: ["applicationId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Application"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
Insert: { | ||
applicationId: string; | ||
hashedSecret: string; | ||
identifier: string; | ||
lastUsedAt?: string | null | undefined; | ||
name?: string | null | undefined; | ||
id?: string | undefined; | ||
updatedAt?: string | undefined; | ||
createdAt?: string | undefined; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}, "public", { | ||
Views: {}; | ||
Functions: {}; | ||
Enums: { | ||
UserRole: "ADMIN" | "MEMBER"; | ||
}>; | ||
type ReadOnlyTable<T> = Omit<T, "Insert" | "Update"> & { | ||
Insert: never; | ||
Update: never; | ||
}; | ||
type TenantDBTableNames = "Team" | "User" | "UserTeam" | "SystemConfig"; | ||
type TenantDB = { | ||
public: { | ||
Tables: { | ||
[K in TenantDBTableNames]: DatabaseModified["public"]["Tables"][K]; | ||
}; | ||
Views: DatabaseModified["public"]["Views"]; | ||
Functions: DatabaseModified["public"]["Functions"]; | ||
Enums: DatabaseModified["public"]["Enums"]; | ||
CompositeTypes: DatabaseModified["public"]["CompositeTypes"]; | ||
}; | ||
CompositeTypes: {}; | ||
Tables: { | ||
_prisma_migrations: { | ||
Row: { | ||
applied_steps_count: number; | ||
checksum: string; | ||
finished_at: string | null; | ||
id: string; | ||
logs: string | null; | ||
migration_name: string; | ||
rolled_back_at: string | null; | ||
started_at: string; | ||
}; | ||
Insert: { | ||
applied_steps_count?: number | undefined; | ||
checksum: string; | ||
finished_at?: string | null | undefined; | ||
id: string; | ||
logs?: string | null | undefined; | ||
migration_name: string; | ||
rolled_back_at?: string | null | undefined; | ||
started_at?: string | undefined; | ||
}; | ||
Update: { | ||
applied_steps_count?: number | undefined; | ||
checksum?: string | undefined; | ||
finished_at?: string | null | undefined; | ||
id?: string | undefined; | ||
logs?: string | null | undefined; | ||
migration_name?: string | undefined; | ||
rolled_back_at?: string | null | undefined; | ||
started_at?: string | undefined; | ||
}; | ||
Relationships: []; | ||
}; | ||
type OrgDBTableNames = Exclude<keyof DatabaseModified["public"]["Tables"], TenantDBTableNames | "_prisma_migrations">; | ||
type OrgDB = { | ||
public: { | ||
Tables: { | ||
[K in OrgDBTableNames]: DatabaseModified["public"]["Tables"][K]; | ||
}; | ||
Application: { | ||
Row: { | ||
createdAt: string; | ||
domain: string; | ||
id: string; | ||
name: string; | ||
repo: string; | ||
status: string; | ||
teamId: string; | ||
updatedAt: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
domain: string; | ||
id: string; | ||
name: string; | ||
repo: string; | ||
status: string; | ||
teamId: string; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
domain?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
repo?: string | undefined; | ||
status?: string | undefined; | ||
teamId?: string | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "Application_teamId_fkey"; | ||
columns: ["teamId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Team"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
Views: { | ||
[K in TenantDBTableNames]: ReadOnlyTable<DatabaseModified["public"]["Tables"][K]>; | ||
}; | ||
Deployment: { | ||
Row: { | ||
applicationId: string; | ||
archive: string | null; | ||
bundle: string; | ||
createdAt: string; | ||
deployment: string | number | boolean | Json[] | { | ||
[x: string]: string | number | boolean | Json[] | any | null | undefined; | ||
} | null; | ||
gitSha: string; | ||
id: string; | ||
originEnv: string | null; | ||
status: string; | ||
statusInfo: string | null; | ||
updatedAt: string; | ||
}; | ||
Insert: { | ||
applicationId: string; | ||
archive?: string | null | undefined; | ||
bundle: string; | ||
createdAt?: string | undefined; | ||
deployment: string | number | boolean | Json[] | { | ||
[x: string]: string | number | boolean | Json[] | any | null | undefined; | ||
} | null; | ||
gitSha: string; | ||
id: string; | ||
originEnv?: string | null | undefined; | ||
status: string; | ||
statusInfo?: string | null | undefined; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
applicationId?: string | undefined; | ||
archive?: string | null | undefined; | ||
bundle?: string | undefined; | ||
createdAt?: string | undefined; | ||
deployment?: string | number | boolean | Json[] | { | ||
[x: string]: string | number | boolean | Json[] | any | null | undefined; | ||
} | null | undefined; | ||
gitSha?: string | undefined; | ||
id?: string | undefined; | ||
originEnv?: string | null | undefined; | ||
status?: string | undefined; | ||
statusInfo?: string | null | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "Deployment_applicationId_fkey"; | ||
columns: ["applicationId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Application"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
EnvVar: { | ||
Row: { | ||
applicationId: string; | ||
createdAt: string; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
value: string; | ||
}; | ||
Insert: { | ||
applicationId: string; | ||
createdAt?: string | undefined; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
value: string; | ||
}; | ||
Update: { | ||
applicationId?: string | undefined; | ||
createdAt?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
updatedAt?: string | undefined; | ||
value?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "EnvVar_applicationId_fkey"; | ||
columns: ["applicationId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Application"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
Secret: { | ||
Row: { | ||
applicationId: string; | ||
createdAt: string; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
valueEnc: string; | ||
}; | ||
Insert: { | ||
applicationId: string; | ||
createdAt?: string | undefined; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
valueEnc: string; | ||
}; | ||
Update: { | ||
applicationId?: string | undefined; | ||
createdAt?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
updatedAt?: string | undefined; | ||
valueEnc?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "Secret_applicationId_fkey"; | ||
columns: ["applicationId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Application"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
SystemConfig: { | ||
Row: { | ||
createdAt: string; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
value: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
id: string; | ||
name: string; | ||
updatedAt: string; | ||
value: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
updatedAt?: string | undefined; | ||
value?: string | undefined; | ||
}; | ||
Relationships: []; | ||
}; | ||
Team: { | ||
Row: { | ||
createdAt: string; | ||
emailDomain: string | null; | ||
id: string; | ||
name: string; | ||
status: string; | ||
updatedAt: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
emailDomain?: string | null | undefined; | ||
id: string; | ||
name: string; | ||
status: string; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
emailDomain?: string | null | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
status?: string | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: []; | ||
}; | ||
TeamSecret: { | ||
Row: { | ||
createdAt: string; | ||
createdById: string; | ||
id: string; | ||
name: string; | ||
teamId: string; | ||
updatedAt: string; | ||
valueEnc: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
createdById: string; | ||
id: string; | ||
name: string; | ||
teamId: string; | ||
updatedAt: string; | ||
valueEnc: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
createdById?: string | undefined; | ||
id?: string | undefined; | ||
name?: string | undefined; | ||
teamId?: string | undefined; | ||
updatedAt?: string | undefined; | ||
valueEnc?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "TeamSecret_createdById_fkey"; | ||
columns: ["createdById"]; | ||
isOneToOne: false; | ||
referencedRelation: "User"; | ||
referencedColumns: ["id"]; | ||
}, { | ||
foreignKeyName: "TeamSecret_teamId_fkey"; | ||
columns: ["teamId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Team"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
User: { | ||
Row: { | ||
createdAt: string; | ||
email: string; | ||
githubId: string; | ||
githubUsername: string; | ||
id: string; | ||
isSuperUser: boolean; | ||
name: string; | ||
updatedAt: string; | ||
}; | ||
Insert: { | ||
createdAt?: string | undefined; | ||
email: string; | ||
githubId: string; | ||
githubUsername: string; | ||
id: string; | ||
isSuperUser?: boolean | undefined; | ||
name: string; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
createdAt?: string | undefined; | ||
email?: string | undefined; | ||
githubId?: string | undefined; | ||
githubUsername?: string | undefined; | ||
id?: string | undefined; | ||
isSuperUser?: boolean | undefined; | ||
name?: string | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: []; | ||
}; | ||
UserTeam: { | ||
Row: { | ||
role: "ADMIN" | "MEMBER"; | ||
teamId: string; | ||
userId: string; | ||
}; | ||
Insert: { | ||
role?: "ADMIN" | "MEMBER" | undefined; | ||
teamId: string; | ||
userId: string; | ||
}; | ||
Update: { | ||
role?: "ADMIN" | "MEMBER" | undefined; | ||
teamId?: string | undefined; | ||
userId?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "UserTeam_teamId_fkey"; | ||
columns: ["teamId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Team"; | ||
referencedColumns: ["id"]; | ||
}, { | ||
foreignKeyName: "UserTeam_userId_fkey"; | ||
columns: ["userId"]; | ||
isOneToOne: false; | ||
referencedRelation: "User"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
}; | ||
ApiKey: { | ||
Row: { | ||
applicationId: string; | ||
createdAt: string; | ||
hashedSecret: string; | ||
id: string; | ||
identifier: string; | ||
lastUsedAt: string | null; | ||
name: string | null; | ||
updatedAt: string; | ||
}; | ||
Update: { | ||
applicationId?: string | undefined; | ||
createdAt?: string | undefined; | ||
hashedSecret?: string | undefined; | ||
id?: string | undefined; | ||
identifier?: string | undefined; | ||
lastUsedAt?: string | null | undefined; | ||
name?: string | null | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
Relationships: [{ | ||
foreignKeyName: "ApiKey_applicationId_fkey"; | ||
columns: ["applicationId"]; | ||
isOneToOne: false; | ||
referencedRelation: "Application"; | ||
referencedColumns: ["id"]; | ||
}]; | ||
Insert: { | ||
applicationId: string; | ||
hashedSecret: string; | ||
identifier: string; | ||
lastUsedAt?: string | null | undefined; | ||
name?: string | null | undefined; | ||
id?: string | undefined; | ||
updatedAt?: string | undefined; | ||
createdAt?: string | undefined; | ||
}; | ||
}; | ||
Functions: DatabaseModified["public"]["Functions"]; | ||
Enums: DatabaseModified["public"]["Enums"]; | ||
CompositeTypes: DatabaseModified["public"]["CompositeTypes"]; | ||
}; | ||
}>; | ||
}; | ||
type TenantTables<T extends keyof TenantDB["public"]["Tables"]> = TenantDB["public"]["Tables"][T]["Row"]; | ||
type OrgTables<T extends keyof OrgDB["public"]["Tables"]> = OrgDB["public"]["Tables"][T]["Row"]; | ||
type OrgViews<T extends keyof OrgDB["public"]["Views"]> = Pick<DatabaseModified["public"]["Tables"][T], "Row">["Row"]; | ||
type TenantTablesInsert<T extends keyof TenantDB["public"]["Tables"]> = TenantDB["public"]["Tables"][T]["Insert"]; | ||
type OrgTablesInsert<T extends keyof OrgDB["public"]["Tables"]> = OrgDB["public"]["Tables"][T]["Insert"]; | ||
type TenantTablesUpdate<T extends keyof TenantDB["public"]["Tables"]> = TenantDB["public"]["Tables"][T]["Update"]; | ||
type OrgTablesUpdate<T extends keyof OrgDB["public"]["Tables"]> = OrgDB["public"]["Tables"][T]["Update"]; | ||
type TenantEnums<T extends keyof TenantDB["public"]["Enums"]> = TenantDB["public"]["Enums"][T]; | ||
type OrgEnums<T extends keyof OrgDB["public"]["Enums"]> = OrgDB["public"]["Enums"][T]; | ||
type PostgrestClientOptions = { | ||
url?: string; | ||
token?: string; | ||
useProvidedUrlAsIs?: boolean; | ||
}; | ||
/** | ||
* Create a pre-configured, typed postgrest client for the tenant-db or org-db. | ||
* For the Postgrest options, either pass a `url` and `token` to use, or rely | ||
* on the `POSTGREST_URL and `JWT_TOKEN` env vars. | ||
*/ | ||
declare function createPostgrestClient(): PostgrestClient<TenantDB>; | ||
declare function createPostgrestClient(options: PostgrestClientOptions | undefined): PostgrestClient<TenantDB>; | ||
declare function createPostgrestClient(teamName: string, options?: PostgrestClientOptions): PostgrestClient<OrgDB>; | ||
declare function getApplications(): Promise<Tables<"Application">[]>; | ||
declare function getApplicationById(id: string): Promise<Tables<"Application"> | null>; | ||
declare function getLatestApplicationDeployments(appIds: string[]): Promise<Pick<Tables<"Deployment">, "applicationId" | "id" | "status" | "createdAt">[]>; | ||
type ApiKey = OrgTables<"ApiKey">; | ||
type Application = OrgTables<"Application">; | ||
type Deployment = OrgTables<"Deployment">; | ||
type EnvVar = OrgTables<"EnvVar">; | ||
type Secret = OrgTables<"Secret">; | ||
type TeamSecret = OrgTables<"TeamSecret">; | ||
declare class OrgDatabase { | ||
postgrest: PostgrestClient<OrgDB>; | ||
constructor(teamName: string, options?: PostgrestClientOptions); | ||
/** | ||
* Application | ||
*/ | ||
getApplications(): Promise<{ | ||
createdAt: string; | ||
domain: string; | ||
id: string; | ||
name: string; | ||
repo: string; | ||
status: string; | ||
teamId: string; | ||
updatedAt: string; | ||
}[]>; | ||
getApplicationById(id: string): Promise<{ | ||
createdAt: string; | ||
domain: string; | ||
id: string; | ||
name: string; | ||
repo: string; | ||
status: string; | ||
teamId: string; | ||
updatedAt: string; | ||
}>; | ||
getLatestApplicationDeployments(appIds: string[]): Promise<{ | ||
id: string; | ||
createdAt: string; | ||
applicationId: string; | ||
status: string; | ||
}[]>; | ||
/** | ||
* Deployment | ||
*/ | ||
getDeploymentJson(deploymentId: string): Promise<string | number | boolean | Json[] | { | ||
[x: string]: string | number | boolean | Json[] | any | null | undefined; | ||
} | null>; | ||
/** | ||
* API Keys | ||
*/ | ||
/** | ||
* Creates an API Key for the given application, optionally with a `name`, stores | ||
* in the database, then returns it. | ||
* @param name an optional name to associate with the API Key | ||
* @param applicationId either an applicationId provided, or the default in the env | ||
* @returns | ||
*/ | ||
createApiKey(name?: string, applicationId?: string | undefined): Promise<string>; | ||
/** | ||
* Verifies an API Key to make sure that it exists for the given application. | ||
* @param apiKey an API key to verify | ||
* @param applicationId either an applicationId provided, or the default in the env | ||
*/ | ||
verifyApiKey(apiKey: string, applicationId?: string | undefined): Promise<boolean>; | ||
/** | ||
* Revoke the given API Key by its name or identifier | ||
* @param identifierOrName - the API Key's identifier or name | ||
* @param applicationId either an applicationId provided, or the default in the env | ||
*/ | ||
revokeApiKey(identifierOrName: string, applicationId?: string | undefined): Promise<{ | ||
identifier: string; | ||
name: string | null; | ||
applicationId: string; | ||
}>; | ||
/** | ||
* Get a list of all API Keys for a given application. | ||
* @param applicationId either an applicationId provided, or the default in the env | ||
*/ | ||
listApiKeys(applicationId?: string | undefined): Promise<{ | ||
id: string; | ||
identifier: string; | ||
name: string | null; | ||
createdAt: string; | ||
updatedAt: string; | ||
lastUsedAt: string | null; | ||
}[]>; | ||
} | ||
declare function getDeploymentJson(deplymentId: string): Promise<Tables<"Deployment">["deployment"]>; | ||
type Team = TenantTables<"Team">; | ||
type User = TenantTables<"User">; | ||
type UserTeam = TenantTables<"UserTeam">; | ||
type SystemConfig = TenantTables<"SystemConfig">; | ||
declare class TenantDatabase { | ||
postgrest: PostgrestClient<TenantDB>; | ||
constructor(options?: PostgrestClientOptions); | ||
getTeam(teamId: string): Promise<{ | ||
createdAt: string; | ||
emailDomain: string | null; | ||
id: string; | ||
name: string; | ||
status: string; | ||
updatedAt: string; | ||
} | null>; | ||
getUser(email: string): Promise<{ | ||
createdAt: string; | ||
email: string; | ||
githubId: string; | ||
githubUsername: string; | ||
id: string; | ||
isSuperUser: boolean; | ||
name: string; | ||
updatedAt: string; | ||
} | null>; | ||
} | ||
/** | ||
* Creates an API Key for the given application, optionally with a `name`, stores | ||
* in the database, then returns it. | ||
* @param name an optional name to associate with the API Key | ||
* @param applicationId either an applicationId provided, or the default in the env | ||
* @returns | ||
*/ | ||
declare function createApiKey(name?: string, applicationId?: string | undefined): Promise<string>; | ||
/** | ||
* Verifies an API Key to make sure that it exists for the given application. | ||
* @param apiKey an API key to verify | ||
* @param applicationId either an applicationId provided, or the default in the env | ||
*/ | ||
declare function verifyApiKey(apiKey: string, applicationId?: string | undefined): Promise<boolean>; | ||
/** | ||
* Revoke the given API Key by its name or identifier | ||
* @param identifierOrName - the API Key's identifier or name | ||
* @param applicationId either an applicationId provided, or the default in the env | ||
*/ | ||
declare function revokeApiKey(identifierOrName: string, applicationId?: string | undefined): Promise<{ | ||
identifier: string; | ||
name: string | null; | ||
applicationId: string; | ||
}>; | ||
/** | ||
* Get a list of all API Keys for a given application. | ||
* @param applicationId either an applicationId provided, or the default in the env | ||
*/ | ||
declare function listApiKeys(applicationId?: string | undefined): Promise<{ | ||
id: string; | ||
identifier: string; | ||
name: string | null; | ||
createdAt: string; | ||
updatedAt: string; | ||
lastUsedAt: string | null; | ||
}[]>; | ||
/** | ||
* Masks the secret part of an API key for display or logging purposes. | ||
@@ -1312,2 +665,7 @@ * @param apiKey The full API key string. | ||
export { type Database, type Enums, type Json, type Tables, type TablesInsert, type TablesUpdate, createApiKey, createPostgrestClient, getApplicationById, getApplications, getDeploymentJson, getLatestApplicationDeployments, listApiKeys, maskApiKey, revokeApiKey, verifyApiKey }; | ||
declare const tenantDatabase: (options?: PostgrestClientOptions) => TenantDatabase; | ||
declare const orgDatabase: (teamName: string, options?: PostgrestClientOptions) => OrgDatabase; | ||
declare const orgDatabaseFromId: (teamId: string, options?: PostgrestClientOptions) => Promise<OrgDatabase>; | ||
export { type ApiKey, type Application, type Deployment, type EnvVar, type OrgDB, type OrgDBTableNames, OrgDatabase, type OrgEnums, type OrgTables, type OrgTablesInsert, type OrgTablesUpdate, type OrgViews, type Secret, type SystemConfig, type Team, type TeamSecret, type TenantDB, type TenantDBTableNames, TenantDatabase, type TenantEnums, type TenantTables, type TenantTablesInsert, type TenantTablesUpdate, type User, type UserTeam, createPostgrestClient, maskApiKey, orgDatabase, orgDatabaseFromId, tenantDatabase }; |
@@ -1,1 +0,1 @@ | ||
import{PostgrestClient as y}from"@supabase/postgrest-js";function i(){let{JWT_TOKEN:r,POSTGREST_URL:e}=process.env;if(!r)throw new Error("missing JWT_TOKEN environment variable");if(!e)throw new Error("missing POSTGREST_URL environment variable");return new y(e,{headers:{Authorization:`Bearer ${r}`},fetch})}async function g(){let r=i(),{data:e,error:t}=await r.from("Application").select("*");if(t)throw t;return e}async function A(r){let e=i(),{data:t,error:n}=await e.from("Application").select("*").eq("id",r).single();if(n)throw n;return t}async function w(r){let e=i(),t=[];for(let s of r){let{data:a,error:c}=await e.from("Deployment").select("id").eq("applicationId",s).order("createdAt",{ascending:!1}).limit(1).maybeSingle();if(c)throw c;a!==null&&t.push(a.id)}let{data:n,error:o}=await e.from("Deployment").select("id, createdAt, applicationId, status").in("id",t);if(console.log("data",n),o)throw o;return n}async function h(r){let e=i(),{data:t,error:n}=await e.from("Deployment").select("deployment").eq("id",r).single();if(n)throw n;return t.deployment}import{randomBytes as p,pbkdf2 as I}from"node:crypto";import{promisify as P}from"node:util";var u=P(I),d="ds";function D(){let r=p(4).toString("hex"),e=p(12).toString("hex");return`${d}-${r}-${e}`}function f(r){let[e,t,n]=r.split("-");if(e!==d)throw new Error("Invalid API Key: incorrect prefix");if(typeof t!="string"||t.length!==8)throw new Error("Invalid API Key: incorrect identifier format");if(typeof n!="string"||n.length!==24)throw new Error("Invalid API Key: incorrect secret format");return{identifier:t,secret:n}}async function m(r,e=p(16).toString("hex")){let s=await u(r,e,1e4,64,"sha512");return`${e}:${s.toString("hex")}`}async function C(r,e=process.env.DS_APPLICATION_ID){if(!e)throw new Error("No applicationId given and DS_APPLICATION_ID environment variable not set");let t=D(),{identifier:n,secret:o}=f(t),s=await m(o);try{let{error:a}=await i().from("ApiKey").insert({identifier:n,hashedSecret:s,name:r||null,applicationId:e});if(a)throw new Error("Error creating API key: "+a.message);return t}catch(a){throw new Error("Unexpected error creating API key: "+a.message)}}async function L(r,e=process.env.DS_APPLICATION_ID){try{if(!e)throw new Error("No applicationId given and DS_APPLICATION_ID environment variable not set");let{identifier:t,secret:n}=f(r),{data:o,error:s}=await i().from("ApiKey").select("hashedSecret").eq("applicationId",e).eq("identifier",t).single();if(s||!o)return!1;let[a]=o.hashedSecret.split(":");if(!a)throw new Error("Hashed secret not in expected format");let c=await m(n,a);return i().from("ApiKey").update({lastUsedAt:new Date().toISOString()}).eq("applicationId",e).eq("identifier",t).then(({error:l})=>{l&&console.warn("Failed to update lastUsedAt for ApiKey:",l)}),c===o.hashedSecret}catch(t){throw new Error("Unexpected error verifying API key: "+t.message)}}async function q(r,e=process.env.DS_APPLICATION_ID){if(!e)throw new Error("No applicationId given and DS_APPLICATION_ID environment variable not set");try{let{data:t,error:n}=await i().from("ApiKey").select("identifier, name").eq("applicationId",e).or(`identifier.eq.${r},name.eq.${r}`).single();if(n||!t)throw new Error(`No API key found with identifier or name: ${r}`);let{error:o}=await i().from("ApiKey").delete().eq("applicationId",e).eq("identifier",t.identifier);if(o)throw new Error("Error revoking API key: "+o.message);return{identifier:t.identifier,name:t.name,applicationId:e}}catch(t){throw new Error("Unexpected error revoking API key: "+t.message)}}async function N(r=process.env.DS_APPLICATION_ID){if(!r)throw new Error("No applicationId given and DS_APPLICATION_ID environment variable not set");try{let{data:e,error:t}=await i().from("ApiKey").select("id, identifier, name, createdAt, updatedAt, lastUsedAt").eq("applicationId",r).order("createdAt",{ascending:!1});if(t)throw new Error("Error listing API keys: "+t.message);return e}catch(e){throw new Error("Unexpected error listing API keys: "+e.message)}}function $(r){let{identifier:e,secret:t}=f(r),n="*".repeat(t.length);return`${d}-${e}-${n}`}export{C as createApiKey,i as createPostgrestClient,A as getApplicationById,g as getApplications,h as getDeploymentJson,w as getLatestApplicationDeployments,N as listApiKeys,$ as maskApiKey,q as revokeApiKey,L as verifyApiKey}; | ||
import{PostgrestClient as m}from"@supabase/postgrest-js";var u=s=>{if(s)return s;let{POSTGREST_URL:e}=process.env;if(!e)throw new Error("missing POSTGREST_URL environment variable");return e},A=(s,e)=>{let t=s.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").substring(0,253),r=new URL(u(e));return r.hostname=`team.${r.hostname}`,r.pathname=`/team/team-${t}`,r.toString().replace(/\/$/,"")};function l(s,e){let t=typeof s=="string",r=t?s:void 0,n=t?e:s,a=n?.token||process.env.JWT_TOKEN;if(!a)throw new Error("missing Postgrest JWT token: use JWT_TOKEN environment variable or pass via options");let o={Authorization:`Bearer ${a}`};return r?n?.url&&n?.useProvidedUrlAsIs?new m(n.url,{headers:o,fetch}):new m(A(r,n?.url),{headers:o,fetch}):new m(u(n?.url),{headers:o,fetch})}import"@supabase/postgrest-js";import{randomBytes as T,pbkdf2 as w}from"node:crypto";import{promisify as h}from"node:util";var I=h(w),b="ds";function D(){let s=T(4).toString("hex"),e=T(12).toString("hex");return`${b}-${s}-${e}`}function d(s){let[e,t,r]=s.split("-");if(e!==b)throw new Error("Invalid API Key: incorrect prefix");if(typeof t!="string"||t.length!==8)throw new Error("Invalid API Key: incorrect identifier format");if(typeof r!="string"||r.length!==24)throw new Error("Invalid API Key: incorrect secret format");return{identifier:t,secret:r}}async function y(s,e=T(16).toString("hex")){let a=await I(s,e,1e4,64,"sha512");return`${e}:${a.toString("hex")}`}function O(s){let{identifier:e,secret:t}=d(s),r="*".repeat(t.length);return`${b}-${e}-${r}`}var p=class{postgrest;constructor(e,t){this.postgrest=l(e,t)}async getApplications(){let{data:e,error:t}=await this.postgrest.from("Application").select("*");if(t)throw t;return e}async getApplicationById(e){let{data:t,error:r}=await this.postgrest.from("Application").select("*").eq("id",e).single();if(r)throw r;return t}async getLatestApplicationDeployments(e){let t=this.postgrest,r=[];for(let o of e){let{data:i,error:g}=await t.from("Deployment").select("id").eq("applicationId",o).order("createdAt",{ascending:!1}).limit(1).maybeSingle();if(g)throw g;i!==null&&r.push(i.id)}let{data:n,error:a}=await t.from("Deployment").select("id, createdAt, applicationId, status").in("id",r);if(console.log("data",n),a)throw a;return n}async getDeploymentJson(e){let{data:t,error:r}=await this.postgrest.from("Deployment").select("deployment").eq("id",e).single().throwOnError();if(r)throw r;return t.deployment}async createApiKey(e,t=process.env.DS_APPLICATION_ID){if(!t)throw new Error("No applicationId given and DS_APPLICATION_ID environment variable not set");let r=D(),{identifier:n,secret:a}=d(r),o=await y(a);try{let{error:i}=await this.postgrest.from("ApiKey").insert({identifier:n,hashedSecret:o,name:e||null,applicationId:t,updatedAt:new Date().toISOString()});if(i)throw new Error("Error creating API key: "+i.message);return r}catch(i){throw new Error("Unexpected error creating API key: "+i.message)}}async verifyApiKey(e,t=process.env.DS_APPLICATION_ID){try{if(!t)throw new Error("No applicationId given and DS_APPLICATION_ID environment variable not set");let{identifier:r,secret:n}=d(e),{data:a,error:o}=await this.postgrest.from("ApiKey").select("hashedSecret").eq("applicationId",t).eq("identifier",r).single();if(o||!a)return!1;let[i]=a.hashedSecret.split(":");if(!i)throw new Error("Hashed secret not in expected format");let g=await y(n,i);return this.postgrest.from("ApiKey").update({lastUsedAt:new Date().toISOString()}).eq("applicationId",t).eq("identifier",r).then(({error:f})=>{f&&console.warn("Failed to update lastUsedAt for ApiKey:",f)}),g===a.hashedSecret}catch(r){throw new Error("Unexpected error verifying API key: "+r.message)}}async revokeApiKey(e,t=process.env.DS_APPLICATION_ID){if(!t)throw new Error("No applicationId given and DS_APPLICATION_ID environment variable not set");try{let{data:r,error:n}=await this.postgrest.from("ApiKey").select("identifier, name").eq("applicationId",t).or(`identifier.eq.${e},name.eq.${e}`).single();if(n||!r)throw new Error(`No API key found with identifier or name: ${e}`);let{error:a}=await this.postgrest.from("ApiKey").delete().eq("applicationId",t).eq("identifier",r.identifier);if(a)throw new Error("Error revoking API key: "+a.message);return{identifier:r.identifier,name:r.name,applicationId:t}}catch(r){throw new Error("Unexpected error revoking API key: "+r.message)}}async listApiKeys(e=process.env.DS_APPLICATION_ID){if(!e)throw new Error("No applicationId given and DS_APPLICATION_ID environment variable not set");try{let{data:t,error:r}=await this.postgrest.from("ApiKey").select("id, identifier, name, createdAt, updatedAt, lastUsedAt").eq("applicationId",e).order("createdAt",{ascending:!1});if(r)throw new Error("Error listing API keys: "+r.message);return t}catch(t){throw new Error("Unexpected error listing API keys: "+t.message)}}};import"@supabase/postgrest-js";var c=class{postgrest;constructor(e){this.postgrest=l(e)}async getTeam(e){let{data:t}=await this.postgrest.from("Team").select().eq("id",e).limit(1).single();return t}async getUser(e){let{data:t}=await this.postgrest.from("User").select().eq("email",e).limit(1).single();return t}};var P=s=>new c(s),V=(s,e)=>new p(s,e),F=async(s,e)=>{let t=await P(e).getTeam(s);if(!t)throw new Error(`No team found for teamId=${s}`);return new p(t.name,e)};export{p as OrgDatabase,c as TenantDatabase,l as createPostgrestClient,O as maskApiKey,V as orgDatabase,F as orgDatabaseFromId,P as tenantDatabase}; |
{ | ||
"name": "@deepstructure/tenant-db", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"access": "public", | ||
@@ -27,3 +27,3 @@ "license": "UNLICENSED", | ||
"typescript": "^5.3.3", | ||
"@ds/tsconfig": "2.3.2" | ||
"@ds/tsconfig": "2.4.0" | ||
}, | ||
@@ -30,0 +30,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
61913
707
13
6