Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
job.statusDate = moment().toISOString();
});
}
// If job isn't finished yet, allow values to expire 3 seconds after being added to the cache
const metadata = {};
if (job.status !== 'Error' && job.status !== 'Canceled' || job.status !== 'Finished') {
metadata.$expires = -3000;
}
// Return values
pathValues.push({
path: [ 'videosById', videoId, 'status' ],
value: $atom(job.status, metadata)
});
pathValues.push({
path: [ 'videosById', videoId, 'statusDate' ],
value: $atom(job.statusDate, metadata)
});
});
}
job.statusDate = moment().toISOString();
});
}
// If job isn't finished yet, allow values to expire 3 seconds after being added to the cache
const metadata = {};
if (job.status !== 'Error' && job.status !== 'Canceled' || job.status !== 'Finished') {
metadata.$expires = -3000;
}
// Return values
pathValues.push({
path: [ 'videosById', videoId, 'status' ],
value: $atom(job.status, metadata)
});
pathValues.push({
path: [ 'videosById', videoId, 'statusDate' ],
value: $atom(job.statusDate, metadata)
});
});
}
// If job isn't finished yet, allow values to expire 3 seconds after being added to the cache
const metadata = {};
if (job.status !== 'Error' && job.status !== 'Canceled' || job.status !== 'Finished') {
metadata.$expires = -3000;
}
// Return values
pathValues.push({
path: [ 'videosById', videoId, 'status' ],
value: $atom(job.status, metadata)
});
pathValues.push({
path: [ 'videosById', videoId, 'statusDate' ],
value: $atom(job.statusDate, metadata)
});
});
}
// If job isn't finished yet, allow values to expire 3 seconds after being added to the cache
const metadata = {};
if (job.status !== 'Error' && job.status !== 'Canceled' || job.status !== 'Finished') {
metadata.$expires = -3000;
}
// Return values
pathValues.push({
path: [ 'videosById', videoId, 'status' ],
value: $atom(job.status, metadata)
});
pathValues.push({
path: [ 'videosById', videoId, 'statusDate' ],
value: $atom(job.statusDate, metadata)
});
});
.reduce((acc, videoId) => {
let v = videosByIdStore[videoId];
if (isUndefined(v)) {
v = $error('Video not found');
} else {
const isUpload = v.locationType === 1;
// Pick out the properties requested
v = pick(v, videoProps);
if (v.tags) v.tags = $atom(v.tags); // Tags are meant to be retrieved together so wrap in an atom
if (v.author) v.author = $ref([ 'usersById', v.author ]); // Author should be a reference to users by id
// Allow null locations on uploads to be refreshed periodically
if (isUpload) {
if (v.previewImageLocation === null) v.previewImageLocation = $atom(null, { $expires: -3000 });
if (v.location === null) v.location = $atom(null, { $expires: -3000 });
}
}
acc[videoId] = v;
return acc;
}, {});
.reduce((acc, videoId) => {
let v = videosByIdStore[videoId];
if (isUndefined(v)) {
v = $error('Video not found');
} else {
const isUpload = v.locationType === 1;
// Pick out the properties requested
v = pick(v, videoProps);
if (v.tags) v.tags = $atom(v.tags); // Tags are meant to be retrieved together so wrap in an atom
if (v.author) v.author = $ref([ 'usersById', v.author ]); // Author should be a reference to users by id
// Allow null locations on uploads to be refreshed periodically
if (isUpload) {
if (v.previewImageLocation === null) v.previewImageLocation = $atom(null, { $expires: -3000 });
if (v.location === null) v.location = $atom(null, { $expires: -3000 });
}
}
acc[videoId] = v;
return acc;
}, {});
.reduce((acc, videoId) => {
let v = videosByIdStore[videoId];
if (isUndefined(v)) {
v = $error('Video not found');
} else {
const isUpload = v.locationType === 1;
// Pick out the properties requested
v = pick(v, videoProps);
if (v.tags) v.tags = $atom(v.tags); // Tags are meant to be retrieved together so wrap in an atom
if (v.author) v.author = $ref([ 'usersById', v.author ]); // Author should be a reference to users by id
// Allow null locations on uploads to be refreshed periodically
if (isUpload) {
if (v.previewImageLocation === null) v.previewImageLocation = $atom(null, { $expires: -3000 });
if (v.location === null) v.location = $atom(null, { $expires: -3000 });
}
}
acc[videoId] = v;
return acc;
}, {});
it("directly", function() {
var cache = {};
var version = 0;
setPathMaps(
getModel({ cache: cache, version: version++ }), [
$pathMapEnvelope("movies['pulp-fiction'].title", "Pulp Fiction"),
$pathMapEnvelope("movies['pulp-fiction']", "Pulp Fiction")
]
);
expect(strip(cache)).toEqual(strip({
movies: { "pulp-fiction": $atom("Pulp Fiction") }
}));
});
it("directly", function() {
var cache = {};
var version = 0;
setPathValues(
getModel({ cache: cache, version: version++ }), [
$pathValue("movies['pulp-fiction'].title", "Pulp Fiction"),
$pathValue("movies['pulp-fiction']", "Pulp Fiction")
]
);
expect(strip(cache)).toEqual(strip({
movies: { "pulp-fiction": $atom("Pulp Fiction") }
}));
});
const keySet02: KeySet = [stringKey];
const KeySet03: KeySet = {from: 1, to: 10};
const KeySet04: KeySet = ["name", {from: 0, length: 10}];
const path0: Path = ["productsById", "1234", "name"];
const path1: Path = [stringKey, numberKey, booleanKey];
const pathSet01: PathSet = ["productsById", ["1234", "5678"], ["name", "price"]];
const pathSet02: PathSet = ["products", [{from: 0, length: 10}, "length"], ["name", "price"]];
var ref01 = ref(['hoge']);
var ref02 = ref(['hoge'], {$expires: 1000});
console.log(ref02.$type, ref02.value, ref02.$expires);
var atom01 = atom('hoge');
var atom02 = atom('hoge', {$expires: 1000});
console.log(atom02.$type, atom02.value, atom02.$expires);
var err01 = error('some error!');
var err02 = error('some error!', {$expires: 1000});
console.log(err02.$type === 'error', ref02.value, ref02.$expires);
var pv01 = pathValue('hoge', 'FOO');
var pv02 = pathValue('hoge[0].bar', 'FOO');
var pv03 = pathValue('hoge[0...100].bar', 'FOO');
var pv04 = pathValue(['hoge', {from: 0, to: 100}, 'bar'], 'FOO');
console.log(pv04.path, pv04.value);
var ip01 = pathInvalidation('hoge');
console.log(ip01.path, ip01.invalidate);