feat: introduce streamers that handle the stream and anonymization from github

This commit is contained in:
tdurieux
2024-04-03 11:13:01 +01:00
parent 73019c1b44
commit 4d12641c7e
64 changed files with 419 additions and 257 deletions
@@ -0,0 +1,14 @@
import { model } from "mongoose";
import {
IAnonymizedRepositoryDocument,
IAnonymizedRepositoryModel,
} from "./anonymizedRepositories.types";
import AnonymizedRepositorySchema from "./anonymizedRepositories.schema";
const AnonymizedRepositoryModel = model<IAnonymizedRepositoryDocument>(
"AnonymizedRepository",
AnonymizedRepositorySchema
) as IAnonymizedRepositoryModel;
export default AnonymizedRepositoryModel;
@@ -0,0 +1,73 @@
import { Schema } from "mongoose";
const AnonymizedRepositorySchema = new Schema({
repoId: {
type: String,
index: { unique: true, collation: { locale: "en", strength: 2 } },
},
status: {
type: String,
default: "preparing",
},
statusDate: Date,
statusMessage: String,
anonymizeDate: Date,
lastView: Date,
pageView: Number,
accessToken: String,
owner: {
type: Schema.Types.ObjectId,
ref: "user",
index: true,
},
conference: String,
source: {
type: { type: String },
branch: String,
commit: String,
commitDate: Date,
repositoryId: String,
repositoryName: String,
accessToken: String,
},
truckedFileList: {
type: Boolean,
default: false,
},
originalFiles: Schema.Types.Mixed,
options: {
terms: [String],
expirationMode: { type: String },
expirationDate: Date,
update: Boolean,
image: Boolean,
pdf: Boolean,
notebook: Boolean,
link: Boolean,
page: Boolean,
pageSource: {
branch: String,
path: String,
},
},
dateOfEntry: {
type: Date,
default: new Date(),
},
size: {
storage: {
type: Number,
default: 0,
},
file: {
type: Number,
default: 0,
},
},
isReseted: {
type: Boolean,
default: false,
},
});
export default AnonymizedRepositorySchema;
@@ -0,0 +1,53 @@
import { Document, Model } from "mongoose";
import { RepositoryStatus, Tree } from "../../types";
export interface IAnonymizedRepository {
repoId: string;
status?: RepositoryStatus;
statusMessage?: string;
statusDate: Date;
anonymizeDate: Date;
source: {
type: "GitHubDownload" | "GitHubStream" | "Zip";
branch?: string;
commit?: string;
commitDate?: Date,
repositoryId?: string;
repositoryName?: string;
accessToken?: string;
};
owner: string;
truckedFileList: boolean;
originalFiles?: Tree;
conference: string;
options: {
terms: string[];
expirationMode: "never" | "redirect" | "remove";
expirationDate?: Date;
update: boolean;
image: boolean;
pdf: boolean;
notebook: boolean;
link: boolean;
page: boolean;
pageSource?: {
branch: string;
path: string;
};
};
pageView: number;
lastView: Date;
size: {
storage: number;
file: number;
};
isReseted: boolean;
}
export interface IAnonymizedRepositoryDocument
extends IAnonymizedRepository,
Document {
setLastUpdated: (this: IAnonymizedRepositoryDocument) => Promise<void>;
}
export interface IAnonymizedRepositoryModel
extends Model<IAnonymizedRepositoryDocument> {}