🗑️ chore: Remove Deprecated Project Model and Associated Fields (#11773)

* chore: remove projects and projectIds usage

* chore: empty line linting

* chore: remove isCollaborative property across agent models and related tests

- Removed the isCollaborative property from agent models, controllers, and tests, as it is deprecated in favor of ACL permissions.
- Updated related validation schemas and data provider types to reflect this change.
- Ensured all references to isCollaborative were stripped from the codebase to maintain consistency and clarity.
This commit is contained in:
Danny Avila 2026-02-13 03:04:15 -05:00
parent 3398f6a17a
commit 37cc5faff5
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
41 changed files with 94 additions and 821 deletions

View file

@ -24,7 +24,6 @@ const agentSchema = new Schema({
id: { type: String, required: true },
name: { type: String, required: true },
author: { type: String },
isCollaborative: { type: Boolean, default: false },
});
const promptGroupSchema = new Schema({
@ -107,7 +106,7 @@ describeIfFerretDB('Migration anti-join → $nin - FerretDB compatibility', () =
_id: { $nin: migratedIds },
author: { $exists: true, $ne: null },
})
.select('_id id name author isCollaborative')
.select('_id id name author')
.lean();
expect(toMigrate).toHaveLength(2);
@ -197,7 +196,6 @@ describeIfFerretDB('Migration anti-join → $nin - FerretDB compatibility', () =
id: 'proj_agent',
name: 'Field Test',
author: 'user1',
isCollaborative: true,
});
const migratedIds = await AclEntry.distinct('resourceId', {
@ -209,7 +207,7 @@ describeIfFerretDB('Migration anti-join → $nin - FerretDB compatibility', () =
_id: { $nin: migratedIds },
author: { $exists: true, $ne: null },
})
.select('_id id name author isCollaborative')
.select('_id id name author')
.lean();
expect(toMigrate).toHaveLength(1);
@ -218,7 +216,6 @@ describeIfFerretDB('Migration anti-join → $nin - FerretDB compatibility', () =
expect(agent).toHaveProperty('id', 'proj_agent');
expect(agent).toHaveProperty('name', 'Field Test');
expect(agent).toHaveProperty('author', 'user1');
expect(agent).toHaveProperty('isCollaborative', true);
});
});

View file

@ -27,7 +27,6 @@ const promptGroupSchema = new Schema(
author: { type: Schema.Types.ObjectId, required: true, index: true },
authorName: { type: String, required: true },
command: { type: String },
projectIds: { type: [Schema.Types.ObjectId], default: [] },
},
{ timestamps: true },
);
@ -51,7 +50,6 @@ type PromptGroupDoc = mongoose.Document & {
oneliner: string;
numberOfGenerations: number;
command?: string;
projectIds: Types.ObjectId[];
createdAt: Date;
updatedAt: Date;
};
@ -226,7 +224,7 @@ describeIfFerretDB('Prompt $lookup replacement - FerretDB compatibility', () =>
.skip(skip)
.limit(limit)
.select(
'name numberOfGenerations oneliner category projectIds productionId author authorName createdAt updatedAt',
'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt',
)
.lean(),
PromptGroup.countDocuments(query),
@ -273,7 +271,7 @@ describeIfFerretDB('Prompt $lookup replacement - FerretDB compatibility', () =>
.sort({ updatedAt: -1, _id: 1 })
.limit(normalizedLimit + 1)
.select(
'name numberOfGenerations oneliner category projectIds productionId author authorName createdAt updatedAt',
'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt',
)
.lean();
@ -303,7 +301,7 @@ describeIfFerretDB('Prompt $lookup replacement - FerretDB compatibility', () =>
const groups = await PromptGroup.find({ _id: { $in: accessibleIds } })
.sort({ updatedAt: -1, _id: 1 })
.select(
'name numberOfGenerations oneliner category projectIds productionId author authorName createdAt updatedAt',
'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt',
)
.lean();
@ -326,7 +324,7 @@ describeIfFerretDB('Prompt $lookup replacement - FerretDB compatibility', () =>
const groups = await PromptGroup.find({})
.select(
'name numberOfGenerations oneliner category projectIds productionId author authorName createdAt updatedAt',
'name numberOfGenerations oneliner category productionId author authorName createdAt updatedAt',
)
.lean();
const result = await attachProductionPrompts(
@ -339,7 +337,6 @@ describeIfFerretDB('Prompt $lookup replacement - FerretDB compatibility', () =>
expect(item.numberOfGenerations).toBe(5);
expect(item.oneliner).toBe('A test prompt');
expect(item.category).toBe('testing');
expect(item.projectIds).toEqual([]);
expect(item.productionId).toBeDefined();
expect(item.author).toBeDefined();
expect(item.authorName).toBe('Test User');

View file

@ -37,7 +37,6 @@ const projectSchema = new Schema({
const agentSchema = new Schema({
name: { type: String, required: true },
projectIds: { type: [String], default: [] },
tool_resources: { type: Schema.Types.Mixed, default: {} },
});
@ -197,23 +196,6 @@ describeIfFerretDB('$pullAll FerretDB compatibility', () => {
expect(doc.agentIds).toEqual(['a2', 'a4']);
});
it('should remove projectIds from an agent', async () => {
await Agent.create({
name: 'Test Agent',
projectIds: ['p1', 'p2', 'p3'],
});
await Agent.findOneAndUpdate(
{ name: 'Test Agent' },
{ $pullAll: { projectIds: ['p1', 'p3'] } },
{ new: true },
);
const updated = await Agent.findOne({ name: 'Test Agent' }).lean();
const doc = updated as Record<string, unknown>;
expect(doc.projectIds).toEqual(['p2']);
});
it('should handle removing from nested dynamic paths (tool_resources)', async () => {
await Agent.create({
name: 'Resource Agent',