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

Teams communication adapter #4965

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,5 @@ deployment/utils/vector.types.ts
deployment/utils/contour.types.ts

schema.graphql

docker/docker-compose.override.yml
2 changes: 2 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: 'hive-dev'
services:
db:
image: postgres:14.12-alpine
user: '${UID}:${GID}'
networks:
- 'stack'
healthcheck:
Expand All @@ -22,6 +23,7 @@ services:

redis:
image: bitnami/redis:7.2.5
user: '${UID}:${GID}'
networks:
- 'stack'
healthcheck:
Expand Down
2 changes: 1 addition & 1 deletion docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Developing Hive locally requires you to have the following software installed locally:

- Node.js 21 (or `nvm` or `fnm`)
- pnpm v8
- pnpm v9
- Docker

## 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
2 changes: 1 addition & 1 deletion packages/libraries/apollo/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.33.0';
export const version = '0.33.1';
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
2 changes: 1 addition & 1 deletion packages/libraries/core/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.3.0';
export const version = '0.3.1';
2 changes: 1 addition & 1 deletion packages/libraries/envelop/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.33.0';
export const version = '0.33.1';
2 changes: 1 addition & 1 deletion packages/libraries/yoga/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.33.0';
export const version = '0.33.1';
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';
`,
} 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,
],
});
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