Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions on relationship links #6545

Open
wants to merge 37 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
464cefd
correct add-migration
LaszloKecskes Feb 22, 2024
71af259
add raw migration
LaszloKecskes Feb 22, 2024
0eee116
add migration types
LaszloKecskes Feb 22, 2024
8230e43
unchanged fixtures and tests
LaszloKecskes Feb 22, 2024
085c3ac
full fixtures
LaszloKecskes Feb 22, 2024
956e72d
full tests
LaszloKecskes Feb 22, 2024
fdeb22e
implemented migration
LaszloKecskes Feb 22, 2024
3a29f61
change metadata object type
LaszloKecskes Feb 23, 2024
6bb3c3d
published prop added to denormalization functions
LaszloKecskes Feb 26, 2024
df0da9e
remove published prop from denormalizeRelated
LaszloKecskes Feb 26, 2024
925be41
test denormalization triggered by permission change
LaszloKecskes Feb 26, 2024
bfd0f22
implement denormalization
LaszloKecskes Feb 27, 2024
7efb6d0
eslint cleanup
LaszloKecskes Feb 27, 2024
a7a970d
update and fix failing tests
LaszloKecskes Feb 27, 2024
640fc1d
remove test log
LaszloKecskes Feb 27, 2024
4277e88
remove await in validator
LaszloKecskes Feb 27, 2024
f32d0aa
add indexing to denormalization flow
LaszloKecskes Feb 28, 2024
473c727
Merge branch 'development' into i66-permissions-on-relationship-links
LaszloKecskes Jul 8, 2024
29e11d7
rename migration folder
LaszloKecskes Jul 8, 2024
b9fc6f2
rename migration test
LaszloKecskes Jul 8, 2024
c8d1b12
renumber migration
LaszloKecskes Jul 8, 2024
0a9bfac
fix typo on test
LaszloKecskes Jul 8, 2024
d827c4b
test relationship-to-any in migration
LaszloKecskes Jul 8, 2024
11b025e
smoke test relationship-to-any
LaszloKecskes Jul 8, 2024
aa0e779
fix denormalization for relationship-to-any
LaszloKecskes Jul 8, 2024
a65d9d6
add flag to metadata
LaszloKecskes Jul 9, 2024
38aca51
remove flag on db save
LaszloKecskes Jul 9, 2024
e96d738
add post process metadata function
LaszloKecskes Jul 9, 2024
34d5744
test entity get
LaszloKecskes Jul 9, 2024
07cc92a
add metadata postprocessing to entity get
LaszloKecskes Jul 10, 2024
5ca9ad3
add metadata postprocessing to search results
LaszloKecskes Jul 10, 2024
75509e1
fix typo in test
LaszloKecskes Jul 10, 2024
86bf42e
fix error on missing template properties
LaszloKecskes Jul 10, 2024
eb356c0
update entity tests
LaszloKecskes Jul 10, 2024
4addc02
update old route tests
LaszloKecskes Jul 11, 2024
88998d8
Merge branch 'development' into i66-permissions-on-relationship-links
daneryl Jul 15, 2024
70f43a8
Merge branch 'development' into i66-permissions-on-relationship-links
daneryl Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
full fixtures
LaszloKecskes committed Feb 22, 2024
commit 085c3aca2b316b100ac248b72fbdb2cc279e9e54
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ export default {

reindex: false,

batchSize: 1000,

async up(db: Db) {
process.stdout.write(`${this.name}...\r\n`);
},
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ const initTest = async (fixture: Fixture) => {
await testingDB.setupFixturesAndContext(fixture);
db = testingDB.mongodb!;
migration.reindex = false;
migration.batchSize = 2;
await migration.up(db);
metadata = (await db.collection<Entity>('entities').find().toArray()).map(e => e.metadata || {});
};
@@ -45,9 +46,6 @@ describe('migration test', () => {
{
text_property: [{ value: 'A', label: 'A' }],
},
{
relationship: [{ value: 'unpublishedDoc', label: 'unpublishedDoc' }],
},
]);
});

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ObjectId } from 'mongodb';
import { Fixture, Template } from '../types';
import { Fixture } from '../types';

const sourceTemplate = {
_id: new ObjectId(),
@@ -14,60 +14,149 @@ const sourceTemplate = {
],
};

const baseTemplates: Record<string, Template> = {
source: sourceTemplate,
withRelationship: {
_id: new ObjectId(),
name: 'Template With Relationship',
properties: [
{
_id: new ObjectId(),
label: 'Relationship To Source',
name: 'relationship_to_source',
type: 'relationship',
content: sourceTemplate._id.toString(),
},
],
},
};

const unpublishedEntityTitle = 'unpublishedDoc';
const unpublishedSourceTitle1 = 'unpublishedDoc1';

const unchangedFixtures: Fixture = {
templates: Object.values(baseTemplates),
templates: [sourceTemplate],
entities: [
{
_id: new ObjectId(),
title: unpublishedEntityTitle,
sharedId: unpublishedEntityTitle,
title: unpublishedSourceTitle1,
sharedId: unpublishedSourceTitle1,
language: 'en',
template: baseTemplates.source._id,
template: sourceTemplate._id,
published: false,
metadata: {
text_property: [{ value: 'A', label: 'A' }],
},
},
],
};

const sourceTemplate2 = {
_id: new ObjectId(),
name: 'source_template_2',
properties: [
{
_id: new ObjectId(),
title: 'nonChangingEntity',
sharedId: 'nonChangingEntity',
language: 'en',
template: baseTemplates.withRelationship._id,
published: false,
metadata: {
relationship: [{ value: unpublishedEntityTitle, label: unpublishedEntityTitle }],
},
label: 'Text Property',
name: 'text_property',
type: 'text' as 'text',
},
],
};

const templateWithRelationship = {
_id: new ObjectId(),
name: 'Template With Relationship',
properties: [
{
_id: new ObjectId(),
label: 'Relationship To Source',
name: 'relationship_to_source',
type: 'relationship',
content: sourceTemplate._id.toString(),
},
],
};

const templateWithTwoRelationships = {
_id: new ObjectId(),
name: 'Template With Two Relationships',
properties: [
{
_id: new ObjectId(),
label: 'Relationship To Source',
name: 'relationship_to_source',
type: 'relationship' as 'relationship',
content: sourceTemplate._id.toString(),
},
{
_id: new ObjectId(),
label: 'Relationship To Source 2',
name: 'relationship_to_source_2',
type: 'relationship' as 'relationship',
content: sourceTemplate2._id.toString(),
},
],
};

const unpublishedSourceTitle2 = 'unpublishedDoc2';

const publishedSourceTitle1 = 'publishedDoc1';

const publishedSourceTitle2 = 'publishedDoc2';

const fixtures: Fixture = {
templates: {
...unchangedFixtures.templates,
},
entities: {
templates: [...unchangedFixtures.templates, sourceTemplate2, templateWithTwoRelationships],
entities: [
...unchangedFixtures.entities,
},
{
_id: new ObjectId(),
title: unpublishedSourceTitle2,
sharedId: unpublishedSourceTitle2,
language: 'en',
template: sourceTemplate2._id,
published: false,
metadata: {
text_property: [{ value: 'B', label: 'B' }],
},
},
{
_id: new ObjectId(),
title: publishedSourceTitle1,
sharedId: publishedSourceTitle1,
language: 'en',
template: sourceTemplate._id,
published: true,
metadata: {
text_property: [{ value: 'C', label: 'C' }],
},
},
{
_id: new ObjectId(),
title: publishedSourceTitle2,
sharedId: publishedSourceTitle2,
language: 'en',
template: sourceTemplate2._id,
published: true,
metadata: {
text_property: [{ value: 'D', label: 'D' }],
},
},
{
_id: new ObjectId(),
title: 'docWithPublishedRelationship',
sharedId: 'docWithPublishedRelationship',
language: 'en',
template: templateWithRelationship._id,
published: true,
metadata: {
relationship_to_source: [
{ value: publishedSourceTitle1, label: publishedSourceTitle1 },
{ value: unpublishedSourceTitle1, label: unpublishedSourceTitle1 },
],
},
},
{
id: new ObjectId(),
title: 'docWithTwoRelationships',
sharedId: 'docWithTwoRelationships',
language: 'en',
template: templateWithTwoRelationships._id,
published: true,
metadata: {
relationship_to_source: [
{ value: publishedSourceTitle1, label: publishedSourceTitle1 },
{ value: unpublishedSourceTitle1, label: unpublishedSourceTitle1 },
],
relationship_to_source_2: [
{ value: publishedSourceTitle2, label: publishedSourceTitle2 },
{ value: unpublishedSourceTitle2, label: unpublishedSourceTitle2 },
],
},
},
],
};

export { fixtures, unchangedFixtures };