Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private: { type: 'boolean' },
baselineBranch: { type: 'string' },
},
})
static relationMappings = {
builds: {
relation: BaseModel.HasManyRelation,
modelClass: 'Build',
join: {
from: 'repositories.id',
to: 'builds.repositoryId',
},
},
organization: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Organization',
join: {
from: 'repositories.organizationId',
to: 'organizations.id',
},
},
user: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'User',
join: {
from: 'repositories.userId',
to: 'users.id',
},
},
}
modelClass: 'Build',
join: {
from: 'repositories.id',
to: 'builds.repositoryId',
},
},
organization: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Organization',
join: {
from: 'repositories.organizationId',
to: 'organizations.id',
},
},
user: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'User',
join: {
from: 'repositories.userId',
to: 'users.id',
},
},
}
static getUsers(repositoryId) {
return User.query()
.select('users.*')
.join(
'user_repository_rights',
'users.id',
'=',
'user_repository_rights.userId',
maximum: 1,
},
validationStatus: {
type: 'string',
enum: [
VALIDATION_STATUSES.unknown,
VALIDATION_STATUSES.accepted,
VALIDATION_STATUSES.rejected,
],
},
},
})
static relationMappings = {
build: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Build',
join: {
from: 'screenshot_diffs.buildId',
to: 'builds.id',
},
},
baseScreenshot: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Screenshot',
join: {
from: 'screenshot_diffs.baseScreenshotId',
to: 'screenshots.id',
},
},
compareScreenshot: {
relation: BaseModel.BelongsToOneRelation,
userId: { type: 'string' },
organizationId: { type: 'string' },
},
})
static relationMappings = {
user: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'User',
join: {
from: 'user_organization_rights.userId',
to: 'users.id',
},
},
organization: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Organization',
join: {
from: 'user_organization_rights.organizationId',
to: 'organizations.id',
},
},
}
}
export default class Screenshot extends BaseModel {
static tableName = 'screenshots'
static jsonSchema = mergeSchemas(BaseModel.jsonSchema, {
required: ['name', 's3Id', 'screenshotBucketId'],
properties: {
name: { type: 'string' },
s3Id: { type: 'string' },
screenshotBucketId: { type: 'string' },
},
})
static relationMappings = {
screenshotBucket: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'ScreenshotBucket',
join: {
from: 'screenshots.screenshotBucketId',
to: 'screenshot_buckets.id',
},
},
}
}
branch: { type: 'string' },
repositoryId: { type: 'string' },
},
})
static relationMappings = {
screenshots: {
relation: BaseModel.HasManyRelation,
modelClass: 'Screenshot',
join: {
from: 'screenshot_buckets.id',
to: 'screenshots.screenshotBucketId',
},
},
repository: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Repository',
join: {
from: 'screenshot_buckets.repositoryId',
to: 'repositories.id',
},
},
}
}
userId: { type: 'string' },
repositoryId: { type: 'string' },
},
})
static relationMappings = {
user: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'User',
join: {
from: 'user_repository_rights.userId',
to: 'users.id',
},
},
repository: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Repository',
join: {
from: 'user_repository_rights.repositoryId',
to: 'repositories.id',
},
},
}
}
static tableName = 'synchronizations'
static jsonSchema = mergeSchemas(BaseModel.jsonSchema, jobModelSchema, {
required: ['userId', 'type'],
properties: {
userId: { type: 'string' },
type: {
type: 'string',
enum: ['github'],
},
},
})
static relationMappings = {
user: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'User',
join: {
from: 'synchronizations.userId',
to: 'users.id',
},
},
}
}
modelClass: 'Build',
join: {
from: 'screenshot_diffs.buildId',
to: 'builds.id',
},
},
baseScreenshot: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Screenshot',
join: {
from: 'screenshot_diffs.baseScreenshotId',
to: 'screenshots.id',
},
},
compareScreenshot: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'Screenshot',
join: {
from: 'screenshot_diffs.compareScreenshotId',
to: 'screenshots.id',
},
},
}
$parseDatabaseJson(json) {
const newJson = super.$parseDatabaseJson(json)
if (typeof newJson.score === 'string') {
newJson.score = Number(newJson.score)
}
return newJson
static jsonSchema = mergeSchemas(BaseModel.jsonSchema, jobModelSchema, {
required: ['compareScreenshotBucketId', 'repositoryId'],
properties: {
baseScreenshotBucketId: { types: ['string', null] },
compareScreenshotBucketId: { type: 'string' },
repositoryId: { type: 'string' },
number: { type: 'integer' },
externalId: { type: ['string', null] },
batchCount: { type: ['integer', null] },
},
})
static relationMappings = {
baseScreenshotBucket: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'ScreenshotBucket',
join: {
from: 'builds.baseScreenshotBucketId',
to: 'screenshot_buckets.id',
},
},
compareScreenshotBucket: {
relation: BaseModel.BelongsToOneRelation,
modelClass: 'ScreenshotBucket',
join: {
from: 'builds.compareScreenshotBucketId',
to: 'screenshot_buckets.id',
},
},
repository: {
relation: BaseModel.BelongsToOneRelation,