Skip to content

Commit 7d2aed5

Browse files
authored
refactor: expose virtual id field on the ITeam interface (#1117)
Needed in the upstream fork and putting it here will make the merges easier long term.
1 parent 9c4c5f4 commit 7d2aed5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/api/src/models/team.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type TeamCHSettings = {
1111

1212
export type ITeam = {
1313
_id: ObjectId;
14+
id: string;
1415
name: string;
1516
allowedAuthMethods?: 'password'[];
1617
apiKey: string;
@@ -49,6 +50,8 @@ export default mongoose.model<ITeam>(
4950
},
5051
{
5152
timestamps: true,
53+
toJSON: { virtuals: true },
54+
toObject: { virtuals: true },
5255
},
5356
),
5457
);

packages/api/src/routers/api/__tests__/team.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('team router', () => {
2626

2727
expect(new Date(resp.body.createdAt).toString()).not.toBe('Invalid Date');
2828

29-
expect(_.omit(resp.body, ['_id', 'apiKey', 'createdAt']))
29+
expect(_.omit(resp.body, ['_id', 'id', 'apiKey', 'createdAt']))
3030
.toMatchInlineSnapshot(`
3131
Object {
3232
"allowedAuthMethods": Array [],
@@ -55,7 +55,7 @@ Object {
5555
.expect(200);
5656

5757
await agent.post('/sources').send({
58-
team: team._id,
58+
team: team.id,
5959
kind: 'log',
6060
name: 'My New Source',
6161
connection: 'local',
@@ -87,11 +87,11 @@ Object {
8787
const { agent, team } = await getLoggedInAgent(server);
8888
const user1 = await User.create({
8989
90-
team: team._id,
90+
team: team.id,
9191
});
9292
const user2 = await User.create({
9393
94-
team: team._id,
94+
team: team.id,
9595
});
9696
const resp = await agent.get('/team/members').expect(200);
9797

@@ -182,7 +182,7 @@ Array [
182182

183183
const user1 = await User.create({
184184
185-
team: team._id,
185+
team: team.id,
186186
});
187187

188188
await agent.delete(`/team/member/${user1._id}`).expect(200);
@@ -198,7 +198,7 @@ Array [
198198
const invite = await TeamInvite.create({
199199
200200
name: 'Fake Invite',
201-
teamId: team._id,
201+
teamId: team.id,
202202
token: 'fake_token',
203203
});
204204

0 commit comments

Comments
 (0)