Skip to content

Commit

Permalink
Merge pull request #5612 from gooddata/mkn-f1-928
Browse files Browse the repository at this point in the history
feat: in-platform notification channels
  • Loading branch information
kandl authored Nov 28, 2024
2 parents 005da39 + ad95b44 commit 8c239af
Show file tree
Hide file tree
Showing 57 changed files with 3,356 additions and 3,197 deletions.
2 changes: 1 addition & 1 deletion libs/api-client-tiger/api/api-client-tiger.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14881,7 +14881,7 @@ export type MetadataGetEntitiesOptions = {
export type MetadataGetEntitiesParams = MetadataGetEntitiesWorkspaceParams | MetadataGetEntitiesUserParams | MetadataGetEntitiesThemeParams | MetadataGetEntitiesColorPaletteParams;

// @internal
export type MetadataGetEntitiesResult = JsonApiVisualizationObjectOutList | JsonApiAnalyticalDashboardOutList | JsonApiDashboardPluginOutList | JsonApiDatasetOutList | JsonApiAttributeOutList | JsonApiLabelOutList | JsonApiMetricOutList | JsonApiFactOutList | JsonApiFilterContextOutList | JsonApiApiTokenOutList | JsonApiThemeOutList | JsonApiColorPaletteOutList | JsonApiExportDefinitionOutList | JsonApiAutomationOutList | JsonApiUserOutList;
export type MetadataGetEntitiesResult = JsonApiVisualizationObjectOutList | JsonApiAnalyticalDashboardOutList | JsonApiDashboardPluginOutList | JsonApiDatasetOutList | JsonApiAttributeOutList | JsonApiLabelOutList | JsonApiMetricOutList | JsonApiFactOutList | JsonApiFilterContextOutList | JsonApiApiTokenOutList | JsonApiThemeOutList | JsonApiColorPaletteOutList | JsonApiExportDefinitionOutList | JsonApiAutomationOutList | JsonApiUserOutList | JsonApiNotificationChannelOutList;

// @internal
export type MetadataGetEntitiesThemeParams = {
Expand Down
4 changes: 3 additions & 1 deletion libs/api-client-tiger/src/metadataUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
JsonApiExportDefinitionOutList,
JsonApiAutomationOutList,
JsonApiUserOutList,
JsonApiNotificationChannelOutList,
} from "./generated/metadata-json-api/index.js";

const DefaultPageSize = 250;
Expand Down Expand Up @@ -124,7 +125,8 @@ export type MetadataGetEntitiesResult =
| JsonApiColorPaletteOutList
| JsonApiExportDefinitionOutList
| JsonApiAutomationOutList
| JsonApiUserOutList;
| JsonApiUserOutList
| JsonApiNotificationChannelOutList;

/**
* All API client getEntities* functions follow this signature.
Expand Down
63 changes: 9 additions & 54 deletions libs/sdk-backend-base/src/dummyBackend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,11 @@ import {
defWithBuckets,
IRelativeDateFilter,
IAbsoluteDateFilter,
IWebhookDefinitionObject,
IWebhookDefinition,
ISmtpDefinitionObject,
ISmtpDefinition,
IAutomationMetadataObjectDefinition,
IAutomationMetadataObject,
ILlmEndpointOpenAI,
ISeparators,
INotificationChannelMetadataObject,
} from "@gooddata/sdk-model";
import isEqual from "lodash/isEqual.js";
import isEmpty from "lodash/isEmpty.js";
Expand Down Expand Up @@ -883,59 +880,17 @@ class DummyOrganization implements IOrganization {

notificationChannels(): IOrganizationNotificationChannelService {
return {
getCount: () => Promise.resolve(0),
getAll: () => Promise.resolve([]),
deleteChannel: () => Promise.resolve(),
testChannel: () =>
testNotificationChannel: () =>
Promise.resolve({
successful: true,
}),
//emails
createEmail: (webhook: ISmtpDefinition) =>
Promise.resolve({
...(webhook as ISmtpDefinitionObject),
id: "dummySmtp",
}),
deleteEmail: () => Promise.resolve(),
getEmail: () =>
Promise.resolve({
id: "dummySmtp",
type: "smtp",
triggers: [],
destination: {
type: "custom",
name: "",
address: "",
login: "",
password: "",
person: "",
from: "",
hasPassword: true,
port: 25,
},
}),
getEmails: () => Promise.resolve([]),
updateEmail: (smtp) => Promise.resolve(smtp),
//webhooks
createWebhook: (webhook: IWebhookDefinition) =>
Promise.resolve({
...(webhook as IWebhookDefinitionObject),
id: "dummyWebhook",
}),
deleteWebhook: () => Promise.resolve(),
getWebhook: () =>
Promise.resolve({
id: "dummyWebhook",
type: "webhook",
destination: {
name: "Dummy webhook",
endpoint: "https://dummy.webhook",
token: "dummyToken",
},
triggers: [],
}),
getWebhooks: () => Promise.resolve([]),
updateWebhook: (webhook) => Promise.resolve(webhook),
getNotificationChannel: () => Promise.resolve({} as INotificationChannelMetadataObject),
createNotificationChannel: () => Promise.resolve({} as INotificationChannelMetadataObject),
updateNotificationChannel: () => Promise.resolve({} as INotificationChannelMetadataObject),
deleteNotificationChannel: () => Promise.resolve(),
getNotificationChannelsQuery: () => {
throw new NotSupported("not supported");
},
};
}

Expand Down
97 changes: 0 additions & 97 deletions libs/sdk-backend-base/src/dummyBackend/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,103 +6,6 @@ import { dummyBackend } from "../index.js";
import { idRef } from "@gooddata/sdk-model";

describe("dummyBackend", () => {
describe("organization", () => {
describe("notificationChannels", () => {
const ORGANIZATION_ID = "myOrganizationId";

it("empty list of webhooks", async () => {
const data = await dummyBackend()
.organization(ORGANIZATION_ID)
.notificationChannels()
.getWebhooks();

expect(data).toEqual([]);
});

it("create webhook", async () => {
const data = await dummyBackend()
.organization(ORGANIZATION_ID)
.notificationChannels()
.createWebhook({
name: "name",
endpoint: "endpoint",
token: "token",
triggers: [
{
type: "SCHEDULE",
allowOn: ["dashboard", "visualization"],
},
{
type: "ALERT",
},
],
});

expect(data).toEqual({
endpoint: "endpoint",
id: "dummyWebhook",
name: "name",
token: "token",
triggers: [
{
allowOn: ["dashboard", "visualization"],
type: "SCHEDULE",
},
{
type: "ALERT",
},
],
});
});

it("update webhook", async () => {
const data = await dummyBackend()
.organization(ORGANIZATION_ID)
.notificationChannels()
.updateWebhook({
id: "webhook-id",
name: "name",
endpoint: "endpoint",
token: "token",
triggers: [
{
type: "SCHEDULE",
allowOn: ["dashboard", "visualization"],
},
{
type: "ALERT",
},
],
});

expect(data).toEqual({
endpoint: "endpoint",
id: "webhook-id",
name: "name",
token: "token",
triggers: [
{
allowOn: ["dashboard", "visualization"],
type: "SCHEDULE",
},
{
type: "ALERT",
},
],
});
});

it("delete webhook", async () => {
const data = await dummyBackend()
.organization(ORGANIZATION_ID)
.notificationChannels()
.deleteWebhook("webhook-id");

expect(data).toBeUndefined();
});
});
});

describe("workspace", () => {
const WORKSPACE_ID = "workspaceId";

Expand Down
63 changes: 9 additions & 54 deletions libs/sdk-backend-mockingbird/src/recordedBackend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,10 @@ import {
IThemeMetadataObject,
IUser,
IWorkspacePermissions,
IWebhookDefinition,
IWebhookDefinitionObject,
ISmtpDefinition,
ISmtpDefinitionObject,
idRef,
ObjRef,
ILlmEndpointOpenAI,
INotificationChannelMetadataObject,
} from "@gooddata/sdk-model";
import RecordedAttributeHierarchiesService from "./attributeHierarchies.js";
import { RecordedAttributes } from "./attributes.js";
Expand Down Expand Up @@ -460,59 +457,17 @@ function recordedOrganization(organizationId: string, implConfig: RecordedBacken
},
notificationChannels(): IOrganizationNotificationChannelService {
return {
getCount: () => Promise.resolve(0),
getAll: () => Promise.resolve([]),
deleteChannel: () => Promise.resolve(),
testChannel: () =>
testNotificationChannel: () =>
Promise.resolve({
successful: true,
}),
//emails
createEmail: (webhook: ISmtpDefinition) =>
Promise.resolve({
...(webhook as ISmtpDefinitionObject),
id: "dummySmtp",
}),
deleteEmail: () => Promise.resolve(),
getEmail: () =>
Promise.resolve({
id: "dummySmtp",
type: "smtp",
triggers: [],
destination: {
type: "custom",
name: "",
address: "",
person: "",
login: "",
password: "",
from: "",
hasPassword: true,
port: 25,
},
}),
getEmails: () => Promise.resolve([]),
updateEmail: (smtp) => Promise.resolve(smtp),
//webhooks
createWebhook: (webhook: IWebhookDefinition) =>
Promise.resolve({
...(webhook as IWebhookDefinitionObject),
id: "dummyWebhook",
}),
deleteWebhook: () => Promise.resolve(),
getWebhook: () =>
Promise.resolve({
id: "dummyWebhook",
type: "webhook",
destination: {
name: "Dummy webhook",
endpoint: "https://dummy.webhook",
token: "dummyToken",
},
triggers: [],
}),
getWebhooks: () => Promise.resolve([]),
updateWebhook: (webhook) => Promise.resolve(webhook),
getNotificationChannel: () => Promise.resolve({} as INotificationChannelMetadataObject),
createNotificationChannel: () => Promise.resolve({} as INotificationChannelMetadataObject),
updateNotificationChannel: () => Promise.resolve({} as INotificationChannelMetadataObject),
deleteNotificationChannel: () => Promise.resolve(),
getNotificationChannelsQuery: () => {
throw new NotSupported("not supported");
},
};
},
permissions(): IOrganizationPermissionService {
Expand Down
Loading

0 comments on commit 8c239af

Please sign in to comment.