Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
cells: {
[uuid: string]: NCell
}
labels: {
[uuid: string]: Label
}
views: {
[uuid: string]: View
}
}
const views = new schema.Entity('views')
// Define cell schema
const cells = new schema.Entity(
'cells',
{
views: [views],
},
{
// add dashboardID to cell
processStrategy: (entity, parent) => ({...entity, dashboardID: parent.id}),
}
)
// Define label schema
export const labels = new schema.Entity('labels')
// Define dashboard schema
export const dashboards = new schema.Entity('dashboards', {
cells: [cells],
public constructor() {
this.idOption = { idAttribute: 'uid' };
// run schemas
this.job = new schema.Entity('jobs', {}, this.idOption);
this.task = new schema.Entity('tasks', {}, this.idOption);
this.provider_task = new schema.Entity('provider_tasks', { tasks: new schema.Array(this.task) }, this.idOption);
this.provider_tasks = new schema.Array(this.provider_task);
this.run = new schema.Entity('runs', { job: this.job, provider_tasks: this.provider_tasks }, this.idOption);
this.runs = new schema.Array(this.run);
}
describe('parsing an array of entities and collections', () => {
const articleSchema = new Schema.Entity('articles');
const userSchema = new Schema.Entity('users');
const collectionSchema = new Schema.Entity('collections');
articleSchema.define({
author: userSchema,
collections: new Schema.Array(collectionSchema),
});
collectionSchema.define({
curator: userSchema,
});
const article1 = {
id: 1,
title: 'Some Article',
author: {
id: 1,
name: 'Dan',
describe('parsing entities and collections', () => {
const articleSchema = new Schema.Entity('articles');
const userSchema = new Schema.Entity('users');
const collectionSchema = new Schema.Entity('collections');
articleSchema.define({
author: userSchema,
collections: new Schema.Array(collectionSchema),
});
collectionSchema.define({
curator: userSchema,
});
const article1 = {
id: 1,
title: 'Some Article',
author: {
import users from './users'
import cloneDeep from 'lodash/cloneDeep'
export {
users
}
const UserSchema = new schema.Entity(
'User',
{},
{
idAttribute: 'id'
}
)
const PostSchema = new schema.Entity(
'Post',
{
author: UserSchema
},
{
idAttribute: 'id'
}
)
export const models = {
PostSchema: PostSchema,
UserSchema: UserSchema
}
export const getAppData = (app) => JSON.parse(app.find('#data').text())
export const userDenormalizationSchema = function() {
return new schema.Entity('users', {
savedChallenges: [ challengeSchema() ],
topChallenges: [ challengeSchema() ],
savedTasks: [ taskDenormalizationSchema() ],
})
}
export const gallerySchema = new schema.Entity('galleries');
export const quoteSchema = new schema.Entity('quotes', {
comments: [commentSchema]
});
export const pollSchema = new schema.Entity('polls');
export const podcastSchema = new schema.Entity('podcasts');
export const pageSchema = new schema.Entity(
'pages',
{},
{ idAttribute: 'slug' }
);
export const companySemesterSchema = new schema.Entity('companySemesters');
export const companyInterestSchema = new schema.Entity('companyInterest', {
semesters: [companySemesterSchema]
});
export const companySchema = new schema.Entity('companies', {
studentContact: userSchema,
comments: [commentSchema]
});
export const joblistingsSchema = new schema.Entity('joblistings');
export const announcementsSchema = new schema.Entity('announcements');
export const feedActivitySchema = new schema.Entity('feedActivities');
export const oauth2ApplicationSchema = new schema.Entity('oauth2Application');
export const oauth2GrantSchema = new schema.Entity('oauth2Grant');
export const membershipSchema = new schema.Entity('memberships', {
user: userSchema
});
export const meetingInvitationSchema = new schema.Entity(
export const taskBundleSchema = function() {
return new schema.Entity('taskBundles', {tasks: [ taskSchema() ]})
}
export const podcastSchema = new schema.Entity('podcasts');
export const pageSchema = new schema.Entity(
'pages',
{},
{ idAttribute: 'slug' }
);
export const companySemesterSchema = new schema.Entity('companySemesters');
export const companyInterestSchema = new schema.Entity('companyInterest', {
semesters: [companySemesterSchema]
});
export const companySchema = new schema.Entity('companies', {
studentContact: userSchema,
comments: [commentSchema]
});
export const joblistingsSchema = new schema.Entity('joblistings');
export const announcementsSchema = new schema.Entity('announcements');
export const feedActivitySchema = new schema.Entity('feedActivities');
export const oauth2ApplicationSchema = new schema.Entity('oauth2Application');
export const oauth2GrantSchema = new schema.Entity('oauth2Grant');
export const membershipSchema = new schema.Entity('memberships', {
user: userSchema
});
export const meetingInvitationSchema = new schema.Entity(
'meetingInvitations',
{
user: userSchema
},
{
idAttribute: invite =>
getMeetingInvitationId(invite.meeting, invite.user.username)
}
response => {
const athlete = response.data;
const shoes = new schema.Entity("shoes", {}, { idAttribute: "id" });
const bikes = new schema.Entity("bikes", {}, { idAttribute: "id" });
const clubs = new schema.Entity("clubs", {}, { idAttribute: "id" });
const athleteSchema = new schema.Entity(
"athletes",
{
shoes: [shoes],
bikes: [bikes],
clubs: [clubs]
},
{
idAttribute: "id",
processStrategy: entity =>
pick(entity, [
"firstname",
"lastname",
"profile",