-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38dc892
commit edace47
Showing
122 changed files
with
10,275 additions
and
10,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"overrides": [], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
"sourceType": "module", | ||
"project": "./tsconfig.json" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": {} | ||
"rules": {}, | ||
"ignorePatterns": [ | ||
"coverage", | ||
"dist", | ||
"__tests__/", | ||
"jest.config.ts", | ||
"*.yml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"printWidth": 120, | ||
"trailingComma": "all", | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,86 @@ | ||
import { Announcement, IAnnouncement } from '@togethercrew.dev/db'; | ||
import { Types } from 'mongoose'; | ||
|
||
type AnnouncementDataFixture = Array<IAnnouncement['data'][0] & { type: string }> | ||
type AnnouncementFixture = Pick<IAnnouncement, 'title' | 'scheduledAt' | 'draft' | 'community' | 'createdBy' | 'updatedBy'> & { _id: Types.ObjectId, data: AnnouncementDataFixture }; | ||
type AnnouncementDataFixture = Array<IAnnouncement['data'][0] & { type: string }>; | ||
type AnnouncementFixture = Pick< | ||
IAnnouncement, | ||
'title' | 'scheduledAt' | 'draft' | 'community' | 'createdBy' | 'updatedBy' | ||
> & { _id: Types.ObjectId; data: AnnouncementDataFixture }; | ||
|
||
export const generatePublicDiscordAnnouncement = (communityId: Types.ObjectId, platformId: Types.ObjectId, channelIds: string[]): AnnouncementFixture => ({ | ||
_id: new Types.ObjectId(), | ||
title: "Announcement One", | ||
scheduledAt: new Date(), | ||
draft: false, | ||
community: communityId, | ||
data: [{ | ||
platform: platformId, | ||
type: "discord_public", | ||
template: "Hello World", | ||
options: { | ||
channelIds: channelIds, | ||
}, | ||
}], | ||
createdBy: new Types.ObjectId(), | ||
updatedBy: new Types.ObjectId(), | ||
export const generatePublicDiscordAnnouncement = ( | ||
communityId: Types.ObjectId, | ||
platformId: Types.ObjectId, | ||
channelIds: string[], | ||
): AnnouncementFixture => ({ | ||
_id: new Types.ObjectId(), | ||
title: 'Announcement One', | ||
scheduledAt: new Date(), | ||
draft: false, | ||
community: communityId, | ||
data: [ | ||
{ | ||
platform: platformId, | ||
type: 'discord_public', | ||
template: 'Hello World', | ||
options: { | ||
channelIds: channelIds, | ||
}, | ||
}, | ||
], | ||
createdBy: new Types.ObjectId(), | ||
updatedBy: new Types.ObjectId(), | ||
}); | ||
|
||
export const generatePrivateUserDiscordAnnouncement = (communityId: Types.ObjectId, platformId: Types.ObjectId, userIds: any[]): AnnouncementFixture => ({ | ||
_id: new Types.ObjectId(), | ||
title: "Announcement Two", | ||
scheduledAt: new Date(), | ||
draft: false, | ||
community: communityId, | ||
data: [{ | ||
platform: platformId, | ||
type: "discord_private", | ||
template: "Hello api world", | ||
options: { | ||
userIds: userIds, | ||
}, | ||
}], | ||
createdBy: new Types.ObjectId(), | ||
updatedBy: new Types.ObjectId(), | ||
}) | ||
export const generatePrivateUserDiscordAnnouncement = ( | ||
communityId: Types.ObjectId, | ||
platformId: Types.ObjectId, | ||
userIds: any[], | ||
): AnnouncementFixture => ({ | ||
_id: new Types.ObjectId(), | ||
title: 'Announcement Two', | ||
scheduledAt: new Date(), | ||
draft: false, | ||
community: communityId, | ||
data: [ | ||
{ | ||
platform: platformId, | ||
type: 'discord_private', | ||
template: 'Hello api world', | ||
options: { | ||
userIds: userIds, | ||
}, | ||
}, | ||
], | ||
createdBy: new Types.ObjectId(), | ||
updatedBy: new Types.ObjectId(), | ||
}); | ||
|
||
export const generatePrivateRoleDiscordAnnouncement = (communityId: Types.ObjectId, platformId: Types.ObjectId, roleIds: any[]): AnnouncementFixture => ({ | ||
_id: new Types.ObjectId(), | ||
title: "Announcement Three", | ||
scheduledAt: new Date(), | ||
draft: false, | ||
community: communityId, | ||
data: [{ | ||
platform: platformId, | ||
type: "discord_private", | ||
template: "Sample Template", | ||
options: { | ||
roleIds: roleIds, | ||
}, | ||
}], | ||
createdBy: new Types.ObjectId(), | ||
updatedBy: new Types.ObjectId(), | ||
}) | ||
export const generatePrivateRoleDiscordAnnouncement = ( | ||
communityId: Types.ObjectId, | ||
platformId: Types.ObjectId, | ||
roleIds: any[], | ||
): AnnouncementFixture => ({ | ||
_id: new Types.ObjectId(), | ||
title: 'Announcement Three', | ||
scheduledAt: new Date(), | ||
draft: false, | ||
community: communityId, | ||
data: [ | ||
{ | ||
platform: platformId, | ||
type: 'discord_private', | ||
template: 'Sample Template', | ||
options: { | ||
roleIds: roleIds, | ||
}, | ||
}, | ||
], | ||
createdBy: new Types.ObjectId(), | ||
updatedBy: new Types.ObjectId(), | ||
}); | ||
|
||
export const insertAnnouncement = async (announcements: AnnouncementFixture[]) => { | ||
for (const announcement of announcements) { | ||
await Announcement.create(announcement); | ||
} | ||
} | ||
|
||
for (const announcement of announcements) { | ||
await Announcement.create(announcement); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.