Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "azure_devops_microsoft_entra_id_oauth",
propDefinitions: {},
propDefinitions: {
eventType: {
type: "string",
label: "Event Type",
description: "Event type to receive events for",
async options() {
const types = await this.listEventTypes();
return types?.map((type) => type.id);
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `https://dev.azure.com/${this.$auth.organization}/_apis`;
},
_makeRequest({
$ = this, path, params, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
"content-type": "application/json",
},
params: {
...params,
"api-version": "7.1",
},
...opts,
});
},
async listEventTypes(opts = {}) {
const { value } = await this._makeRequest({
path: "/hooks/publishers/tfs/eventtypes",
...opts,
});
return value;
},
createSubscription(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/hooks/subscriptions",
...opts,
});
},
deleteSubscription(subscriptionId, opts = {}) {
return this._makeRequest({
method: "DELETE",
path: `/hooks/subscriptions/${subscriptionId}`,
...opts,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/azure_devops_microsoft_entra_id_oauth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/azure_devops_microsoft_entra_id_oauth",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Azure DevOps (Microsoft Entra ID OAuth) Components",
"main": "azure_devops_microsoft_entra_id_oauth.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.1"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import azureDevops from "../../azure_devops_microsoft_entra_id_oauth.app.mjs";

export default {
key: "azure_devops_microsoft_entra_id_oauth-new-event",
name: "New Event (Instant)",
description: "Emit new event for the specified event type.",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
azureDevops,
db: "$.service.db",
http: "$.interface.http",
eventType: {
propDefinition: [
azureDevops,
"eventType",
],
},
},
hooks: {
async activate() {
const data = {
url: this.http.endpoint,
publisherId: "tfs",
resourceVersion: "1.0",
consumerId: "webHooks",
consumerActionId: "httpRequest",
consumerInputs: {
url: this.http.endpoint,
},
eventType: this.eventType,
};
const { id } = await this.azureDevops.createSubscription({
data,
});
this._setHookId(id);
},
async deactivate() {
const id = this._getHookId();
await this.azureDevops.deleteSubscription(id);
},
},
methods: {
_getHookId() {
return this.db.get("hookId");
},
_setHookId(hookId) {
this.db.set("hookId", hookId);
},
generateMeta(body) {
return {
id: body.id,
summary: `New ${this.eventType} event with ID ${body.id}`,
ts: Date.parse(body.createdDate),
};
},
},
async run(event) {
const { body } = event;
const meta = this.generateMeta(body);
this.$emit(body, meta);
},
};
Loading
Loading