Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[Sort.Oldest]: 'old'
};
const htmlEntitiesDecoder = new XmlEntities();
const ApiSchema = {
[Entities.Comment]: new Schema(Entities.Comment),
[Entities.Post]: new Schema(Entities.Post)
};
ApiSchema[Entities.Comment].define({
replies: arrayOf(ApiSchema[Entities.Comment])
});
ApiSchema[Entities.Post].define({
comments: arrayOf(ApiSchema[Entities.Comment])
});
// TODO: proper snoocore init
const reddit = new Snoocore({
userAgent: 'supercomments',
oauth: {
type: 'implicit',
key: 'CRcRenqfbTCNLw',
redirectUri: 'http://localhost:3000',
scope: ['identity', 'read', 'submit', 'vote']
}
});
const mapRedditReplies = replies => replies.map(({ data }) => ({
id: data.id,
name: data.name,
[DIRECTORY_LOADED]: (state, action) => {
const {path, collections, tracks, compacts } = action.payload;
const normCollection = normalize(collections, arrayOf(collectionSchema));
const normCompacts = normalize(compacts, arrayOf(compactSchema));
const normTracks = normalize(
// insert metaDataLoading State into each track
tracks.map((track) => {
track.metadataLoadingState = MetaDataLoadingStates.idle;
return track;
}),
arrayOf(trackSchema)
);
const receivedEntities = {
...normCollection.entities,
...normTracks.entities,
...normCompacts.entities,
};
const mergedEntities = mergeEntities(state.entities, receivedEntities);
return {
});
const contributions = ({
owner: campaign,
individual: arrayOf(indivContribution),
business: arrayOf(businessContribution),
pac: arrayOf(pacContribution),
states: arrayOf(stateContribution)
});
campaign.define({
listByName: valuesOf(campaign, {
schemaAttribute: 'candidateName'
})
});
const search = new Schema('searches');
search.define({
list: arrayOf(campaign)
});
// contribution.define({
// owner: campaign
// });
indivContribution.define({
owner: campaign,
listByType: valuesOf(transaction, {
schemaAttribute: 'bookType'
})
});
donor.define({
owner: transaction,
listByName: valuesOf(transaction, {
schemaAttribute: 'contributorPayee'
}),
relationships: valuesOf(campaign)
return async (dispatch, getState) => {
while (true) {
const action = await dispatch({
types: [null, types.GET_NOTES_SUCCESS, null],
url: 'note/getSyncNotes',
query: {
afterUsn: getState().user.localUsn.note,
maxEntry: 100,
},
schema: arrayOf(noteSchema),
});
// Dispatch all networks at the same time will cause 404 error.
action.payload.result
.map(noteId => action.payload.entities.notes[noteId])
.filter(note => !note.isDeleted && !note.isTrash)
.reduce((promise, note) => {
return promise.then(() => {
return dispatch(fetchNoteAndContent(note.noteId));
});
}, Promise.resolve());
if (action.payload.result.length === 0) {
break;
}
}
}
}
.then(json => {
const songs = json.filter(song => songTitle !== song.title)
const normalized = normalize(songs, arrayOf(songSchema))
dispatch(receiveSongs(normalized.result, normalized.entities, songTitle))
})
.catch(error => console.log(error))
.then(function(json) {
return {
count: json.count,
results: normalize(json.results, arrayOf(templateSchema))
}
})
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Schema, arrayOf } from 'normalizr';
import { ENTITY_TYPES } from '@app/constants/Constants';
import dataset from './dataset';
import file from './file';
import folder from './folder';
import physicalDataset from './physicalDataset';
const space = new Schema(ENTITY_TYPES.space);
space.define({
contents: {
datasets: arrayOf(dataset),
files: arrayOf(file),
folders: arrayOf(folder),
physicalDatasets: arrayOf(physicalDataset)
}
});
export default space;
topic.define({
user: user
});
reply.define({
user: user
});
notification.define({
actor: user,
topic: topic,
reply: reply
});
user.define({
topics: arrayOf(topic),
replies: arrayOf(reply),
followers: arrayOf(user),
following: arrayOf(user)
});
export const topicSchema = topic;
export const userSchema = user;
export const replySchema = reply;
export const notificationSchema = notification;
*/
import { Schema, arrayOf, normalize } from 'normalizr'
const playlistSchema = new Schema('playlists', {
idAttribute: 'id'
});
const watchlistSchema = new Schema('watchlist', {
idAttribute: '_id'
});
export default {
PLAYLIST: playlistSchema,
PLAYLIST_ARRAY: arrayOf(playlistSchema),
WATCHLIST: watchlistSchema,
WATCHLIST_ARRAY: arrayOf(watchlistSchema)
};
json => normalize(json.data, arrayOf(pluginsSchema))
),