import { RenameId } from "../utils/mongoDB/types.js";
import { User, UserAPI } from "./user.types.js";
import { Organization, OrganizationAPI } from "./organization.types.js";
import { IntlayerConfig } from "@intlayer/types";
import { Document, Model, ObjectIdToString, Types } from "mongoose";
import { Token } from "oauth2-server";

//#region src/types/project.types.d.ts
type ProjectCreationData = {
  name: Project['name'];
};
type ProjectConfigInternationalization = Pick<IntlayerConfig['internationalization'], 'locales' | 'defaultLocale'>;
type ProjectConfigEditor = Pick<IntlayerConfig['editor'], 'applicationURL' | 'cmsURL'>;
type ProjectConfiguration = {
  internationalization: ProjectConfigInternationalization;
  editor: ProjectConfigEditor;
};
type ProjectData = {
  organizationId: Organization['id'];
  name: string;
  membersIds: User['id'][];
  adminsIds: User['id'][];
  creatorId: User['id'];
  configuration?: ProjectConfiguration;
};
type AccessKeyData = {
  name: string;
  grants: string[];
  expiresAt?: Date;
};
type OAuth2AccessData = AccessKeyData & {
  clientId: string;
  clientSecret: string;
  accessToken: string[];
  userId: User['id'];
};
type OAuth2AccessContext = {
  accessToken: Token;
  user?: UserAPI;
  project?: ProjectAPI;
  organization?: OrganizationAPI;
  grants: Token['grants'];
};
type OAuth2Access = OAuth2AccessData & {
  id: Types.ObjectId;
  createdAt: number;
  updatedAt: number;
};
type OAuth2AccessAPI = ObjectIdToString<OAuth2Access>;
type Project = ProjectData & {
  id: Types.ObjectId;
  createdAt: number;
  updatedAt: number;
  oAuth2Access: OAuth2Access[];
};
type ProjectAPI = ObjectIdToString<Project>;
type ProjectSchema = RenameId<Project>;
type ProjectModelType = Model<Project>;
type ProjectDocument = Document<unknown, {}, Project> & Project;
//#endregion
export { AccessKeyData, OAuth2Access, OAuth2AccessAPI, OAuth2AccessContext, OAuth2AccessData, Project, ProjectAPI, ProjectConfiguration, ProjectCreationData, ProjectData, ProjectDocument, ProjectModelType, ProjectSchema };
//# sourceMappingURL=project.types.d.ts.map