Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
params: { repo: repoPath }
})
);
factory.addResource('plugin-configs')
.withAttributes({ module: '@cardstack/git' });
factory.addResource('grants')
.withAttributes({
mayCreateResource: true,
mayUpdateResource: true,
mayDeleteResource: true,
mayWriteField: true
}).withRelated('who', factory.addResource('groups', user.id));
let container = await wireItUp(crypto.randomBytes(32), factory.getModels(), false);
let writers = container.lookup('hub:writers');
for (let model of inDependencyOrder(initialModels)) {
// TODO: this one-by-one creation is still slower than is nice for
// tests -- each time we write a schema model it invalidates the
// schema cache, which needs to get rebuilt before we can write
// the next one. Which also requires us to use inDependencyOrder,
// which is kinda lame.
//
// On the other hand, this is a high-quality test of our ability
// to build up the entire state in the same way an end user would
// via JSONAPI requests. If we optimize this away, we should also
// add some tests like that that are similarly comprehensive.
let response = await writers.create('master', user.data, model.type, model);
head = response.meta.version;
mayLogin: true,
})
.withRelated('who', [{ type: user.data.type, id: user.data.id }]);
let models = factory.getModels();
let [foreignInitialModels, ephemeralInitialModels] = partitionInitialModels(models);
opts.disableAutomaticIndexing = true;
opts.environment = 'test';
opts.seeds = () => ephemeralInitialModels;
opts.pgBossConfig = opts.pgBossConfig || {
newJobCheckInterval: 100, // set to minimum to speed up tests
};
container = await wireItUp(projectDir, crypto.randomBytes(32), defaultDataSource.getModels(), opts);
if (foreignInitialModels.length) {
await loadSeeds(container, foreignInitialModels);
} else {
await container.lookup('hub:indexers').update({ forceRefresh: true });
}
let ephemeralStorage = await container.lookup(`plugin-services:${require.resolve('@cardstack/ephemeral/service')}`);
let searchers = await container.lookup(`hub:searchers`);
await ephemeralStorage.validateModels(models, async (type, id) => {
let result;
try {
result = await searchers.get(Session.INTERNAL_PRIVILEGED, 'local-hub', type, id);
} catch (err) {
if (err.status !== 404) {
throw err;
}