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

feat: Teams communication adapter #4968

Merged
merged 36 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1c1d6ec
feat: add TeamsCommunicationAdapter WIP
capaj Jun 26, 2024
ad85a4c
add FE bits for the new AlertChannelType.MsteamsWebhook
capaj Jun 26, 2024
de45c44
add TeamsWebhookChannel resolver
capaj Jun 26, 2024
0dafe46
feat: add new adapter calls in all places on BE
capaj Jun 26, 2024
c9963d1
tests: add unit test for TeamsCommunicationAdapter
capaj Jun 26, 2024
95942a2
fix: CR feedback and types
capaj Jun 26, 2024
09061b8
docs: add capaj as author
capaj Jun 26, 2024
cafbb83
add missing entry in CodegenConfig
capaj Jun 26, 2024
6debdb0
feat: add TeamsCommunicationAdapter WIP
capaj Jun 5, 2024
6f95013
add FE bits for the new AlertChannelType.MsteamsWebhook
capaj Jun 11, 2024
f0732cf
feat: add new adapter calls in all places on BE
capaj Jun 13, 2024
d6f897e
docs: add requirements docker version and ports
capaj Jun 13, 2024
45c8a0a
cleanup: remove extraneus file
capaj Jun 13, 2024
50beda4
fix: lint errors
capaj Jun 13, 2024
61fc3ee
docs: amend readme
capaj Jun 13, 2024
ad095aa
refactor: simplify confiditon
capaj Jun 14, 2024
f6cf565
docs: add MS Teams docs to projects.mdx
capaj Jun 14, 2024
8f4710d
docs: add for image
capaj Jun 14, 2024
6b27f93
docs: add product update
capaj Jun 14, 2024
fd2de67
fix TSX 🙏
capaj Jun 26, 2024
5171f9f
docs: add docs link to product update
capaj Jun 27, 2024
c0c6f96
docs: update image as per CR request, fix docker compose
capaj Jun 27, 2024
72cf4a8
chore: remove gitignored file
capaj Jun 27, 2024
b8d0846
docs: remove duplicate picture
capaj Jun 27, 2024
887e7bb
Merge branch 'main' into TeamsCommunicationAdapter
capaj Jun 27, 2024
85f91db
Merge remote-tracking branch 'origin/main' into TeamsCommunicationAda…
capaj Jul 2, 2024
d07cc6b
fix: add truncation for messages longer than 27k characters
capaj Jul 2, 2024
72e1803
Merge branch 'main' into TeamsCommunicationAdapter
capaj Jul 2, 2024
02ddd1e
Merge remote-tracking branch 'upstream/main' into TeamsCommunicationA…
capaj Jul 4, 2024
beb4d45
fix: table styles to avoid overflow
capaj Jul 4, 2024
b3832a6
fix: tweak styles a bit more
capaj Jul 4, 2024
32c9676
pnpm prettier
kamilkisiela Jul 4, 2024
902fc72
Improve the product update
kamilkisiela Jul 4, 2024
fc3b0b0
Prettier
github-actions[bot] Jul 4, 2024
0faaf11
Merge branch 'main' into TeamsCommunicationAdapter
capaj Jul 6, 2024
903c95a
Merge branch 'main' of github.com:kamilkisiela/graphql-hive into Team…
kamilkisiela Jul 9, 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
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ packages/web/app/environment-*.mjs
packages/web/app/src/gql/*.ts
packages/web/app/src/gql/*.json
packages/web/app/src/graphql/*.ts
packages/web/docs/public/feed.xml
# Changelog
packages/web/app/src/components/ui/changelog/generated-changelog.ts

Expand All @@ -142,6 +143,4 @@ deployment/utils/contour.types.ts
schema.graphql
resolvers.generated.ts

# generated by tsup
configs/tsup/dev.config.*.mjs
packages/web/docs/public/feed.xml
docker/docker-compose.override.yml
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<!-- Graphql logo readme banner START -->
<p style="float: right; margin: 0 0 10px 10px;">
<a href="https://the-guild.dev">
<img src="https://the-guild-org.github.io/press-kit/full-dark-logo.svg" alt="Created by The guild" style="width: 100px;"/>
</a>
</p>
<!-- Graphql logo readme banner END -->

# GraphQL Hive

GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages,
Expand Down Expand Up @@ -51,10 +59,11 @@ GraphQL Hive helps you get a global overview of the usage of your GraphQL API wi

### Integrations

GraphQL Hive is well integrated with **Slack** and most **CI/CD** systems to get you up and running
as smoothly as possible!
GraphQL Hive is well integrated with **Slack**, **MS Teams** and most **CI/CD** systems to get you
up and running as smoothly as possible!

GraphQL Hive can notify your team when schema changes occur, either via Slack or a custom webhook.
GraphQL Hive can notify your team when schema changes occur, either via Slack, MS Teams or a custom
webhook.

Also, the Hive CLI allows integration of the schema checks mechanism to all CI/CD systems (GitHub,
BitBucket, Azure, and others). The same applies to schema publishing and operations checks.
Expand Down
1 change: 1 addition & 0 deletions codegen.mts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const config: CodegenConfig = {
AlertChannel: '../modules/alerts/module.graphql.mappers#AlertChannelMapper',
AlertSlackChannel: '../modules/alerts/module.graphql.mappers#AlertSlackChannelMapper',
AlertWebhookChannel: '../modules/alerts/module.graphql.mappers#AlertWebhookChannelMapper',
TeamsWebhookChannel: '../modules/alerts/module.graphql.mappers#TeamsWebhookChannelMapper',
Alert: '../modules/alerts/module.graphql.mappers#AlertMapper',
AdminQuery: '../modules/admin/module.graphql.mappers#AdminQueryMapper',
AdminStats: '../modules/admin/module.graphql.mappers#AdminStatsMapper',
Expand Down
5 changes: 3 additions & 2 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
Developing Hive locally requires you to have the following software installed locally:

- Node.js 21 (or `nvm` or `fnm`)
- pnpm v8
- Docker
- pnpm v9
- Docker version 26.1.1 or later(previous versions will not work correctly on arm64)
- make sure these ports are free: 5432, 6379, 9000, 9001, 8123, 9092, 8081, 8082, 9644, 3567, 7043

## Setup Instructions

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"build:web": "pnpm prebuild && pnpm turbo build --filter=./packages/web/* --color",
"cargo:fix": "bash ./scripts/fix-symbolic-link.sh",
"docker:build": "docker buildx bake -f docker/docker.hcl --load build",
"docker:override-up": "docker compose -f ./docker/docker-compose.override.yml up -d --remove-orphans",
"env:sync": "tsx scripts/sync-env-files.ts",
"generate": "pnpm --filter @hive/storage db:generate && pnpm graphql:generate",
"graphql:generate": "graphql-codegen --config codegen.mts",
Expand All @@ -33,7 +34,7 @@
"lint:env-template": "tsx scripts/check-env-template.ts",
"lint:fix": "pnpm lint --fix",
"lint:prettier": "prettier --cache --check .",
"local:setup": "docker-compose -f ./docker/docker-compose.dev.yml up -d --remove-orphans && pnpm --filter @hive/migrations db:init",
"local:setup": "docker compose -f ./docker/docker-compose.dev.yml up -d --remove-orphans && pnpm --filter @hive/migrations db:init",
"postinstall": "node ./scripts/patch-manifests.js && pnpm env:sync && node ./scripts/turborepo-cleanup.js && pnpm cargo:fix",
"pre-commit": "exit 0 && lint-staged",
"prebuild": "rimraf deploy-tmp && rimraf packages/**/deploy-tmp",
Expand Down
19 changes: 19 additions & 0 deletions packages/libraries/cli/examples/single.with.mutation.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
type Query {
foo: Int!
bar: String
test: String
last: Boolean
fooTwo: Int!
}

type Mutation {
addFooAnother(foo: Int!): Int!
addBar(bar: String): String
addTest(test: String): String
}

schema {
query: Query
mutation: Mutation
}
# test 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { type MigrationExecutor } from '../pg-migrator';

export default {
name: '2024.06.11T10-10-00.ms-teams-webhook.ts',
run: ({ sql }) => sql`
ALTER TYPE alert_channel_type ADD VALUE 'MSTEAMS_WEBHOOK';
capaj marked this conversation as resolved.
Show resolved Hide resolved
`,
} satisfies MigrationExecutor;
2 changes: 2 additions & 0 deletions packages/migrations/src/run-pg-migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import migration_2024_01_12_01T00_00_00_contracts from './actions/2024.01.26T00.
import migration_2024_01_12_01T00_00_00_schema_check_pagination_index_update from './actions/2024.01.26T00.00.01.schema-check-pagination-index-update';
import migration_2024_02_19_01T00_00_00_schema_check_store_breaking_change_metadata from './actions/2024.02.19T00.00.01.schema-check-store-breaking-change-metadata';
import migration_2024_04_09T10_10_00_check_approval_comment from './actions/2024.04.09T10-10-00.check-approval-comment';
import migration_2024_06_11T10_10_00_ms_teams_webhook from './actions/2024.06.11T10-10-00.ms-teams-webhook';
import { runMigrations } from './pg-migrator';

export const runPGMigrations = (args: { slonik: DatabasePool; runTo?: string }) =>
Expand Down Expand Up @@ -134,5 +135,6 @@ export const runPGMigrations = (args: { slonik: DatabasePool; runTo?: string })
migration_2024_01_12_01T00_00_00_schema_check_pagination_index_update,
migration_2024_02_19_01T00_00_00_schema_check_store_breaking_change_metadata,
migration_2024_04_09T10_10_00_check_approval_comment,
migration_2024_06_11T10_10_00_ms_teams_webhook,
],
});
1 change: 1 addition & 0 deletions packages/services/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"slonik": "30.4.4",
"supertokens-node": "15.2.1",
"tslib": "2.6.3",
"vitest": "1.6.0",
"zod": "3.23.8",
"zod-validation-error": "3.3.0"
}
Expand Down
8 changes: 7 additions & 1 deletion packages/services/api/src/modules/alerts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createModule } from 'graphql-modules';
import { TeamsCommunicationAdapter } from './providers/adapters/msteams';
import { SlackCommunicationAdapter } from './providers/adapters/slack';
import { WebhookCommunicationAdapter } from './providers/adapters/webhook';
import { AlertsManager } from './providers/alerts-manager';
Expand All @@ -10,5 +11,10 @@ export const alertsModule = createModule({
dirname: __dirname,
typeDefs,
resolvers,
providers: [AlertsManager, SlackCommunicationAdapter, WebhookCommunicationAdapter],
providers: [
AlertsManager,
SlackCommunicationAdapter,
WebhookCommunicationAdapter,
TeamsCommunicationAdapter,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import type { Alert, AlertChannel } from '../../shared/entities';
export type AlertChannelMapper = AlertChannel;
export type AlertSlackChannelMapper = AlertChannel;
export type AlertWebhookChannelMapper = AlertChannel;
export type TeamsWebhookChannelMapper = AlertChannel;
export type AlertMapper = Alert;
8 changes: 8 additions & 0 deletions packages/services/api/src/modules/alerts/module.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default gql`
enum AlertChannelType {
SLACK
WEBHOOK
MSTEAMS_WEBHOOK
}

enum AlertType {
Expand Down Expand Up @@ -140,6 +141,13 @@ export default gql`
endpoint: String!
}

type TeamsWebhookChannel implements AlertChannel {
id: ID!
name: String!
type: AlertChannelType!
endpoint: String!
}

type Alert {
id: ID!
type: AlertType!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import type {
Target,
} from '../../../../shared/entities';

interface NotificationIntegrations {
slack: {
token: string | null | undefined;
};
}

export interface SchemaChangeNotificationInput {
event: {
organization: Pick<Organization, 'id' | 'cleanId' | 'name'>;
Expand All @@ -25,11 +31,7 @@ export interface SchemaChangeNotificationInput {
};
alert: Alert;
channel: AlertChannel;
integrations: {
slack: {
token: string;
};
};
integrations: NotificationIntegrations;
}

export interface ChannelConfirmationInput {
Expand All @@ -39,11 +41,7 @@ export interface ChannelConfirmationInput {
project: Pick<Project, 'id' | 'cleanId' | 'name'>;
};
channel: AlertChannel;
integrations: {
slack: {
token: string;
};
};
integrations: NotificationIntegrations;
}

export interface CommunicationAdapter {
Expand All @@ -59,9 +57,13 @@ export function quotesTransformer(msg: string, symbols = '**') {
const findSingleQuotes = /'([^']+)'/gim;
const findDoubleQuotes = /"([^"]+)"/gim;

function transformm(_: string, value: string) {
function transform(_: string, value: string) {
return `${symbols}${value}${symbols}`;
}

return msg.replace(findSingleQuotes, transformm).replace(findDoubleQuotes, transformm);
return msg.replace(findSingleQuotes, transform).replace(findDoubleQuotes, transform);
}

export const createMDLink = ({ text, url }: { text: string; url: string }) => {
return `[${text}](${url})`;
};
Loading
Loading