diff --git a/components/linearb/actions/create-incident/create-incident.mjs b/components/linearb/actions/create-incident/create-incident.mjs index db656a26fe4c7..3d5b1ef6633e3 100644 --- a/components/linearb/actions/create-incident/create-incident.mjs +++ b/components/linearb/actions/create-incident/create-incident.mjs @@ -4,7 +4,7 @@ export default { key: "linearb-create-incident", name: "Create Incident", description: "Create a new incident within the LinearB platform. [See the documentation](https://docs.linearb.io/api-incidents/#create-incident)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, @@ -52,15 +52,17 @@ export default { optional: true, }, teams: { - type: "string[]", - label: "Teams", - description: "The list of LinearB teams names related to this incident. (lowercase only)", + propDefinition: [ + app, + "teams", + ], optional: true, }, services: { - type: "string[]", - label: "Services", - description: "The list of LinearB services related to this incident.", + propDefinition: [ + app, + "services", + ], optional: true, }, repositoryUrls: { diff --git a/components/linearb/actions/search-incidents/search-incidents.mjs b/components/linearb/actions/search-incidents/search-incidents.mjs new file mode 100644 index 0000000000000..8ec2a6f69f388 --- /dev/null +++ b/components/linearb/actions/search-incidents/search-incidents.mjs @@ -0,0 +1,106 @@ +import app from "../../linearb.app.mjs"; + +export default { + key: "linearb-search-incidents", + name: "Search Incidents", + description: "Search for incidents within the LinearB platform. [See the documentation](https://docs.linearb.io/api-incidents/#search-incidents)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + app, + teams: { + propDefinition: [ + app, + "teams", + ], + optional: true, + }, + services: { + propDefinition: [ + app, + "services", + ], + optional: true, + }, + repositoryUrls: { + type: "string[]", + label: "Repository URLs", + description: "The list of repos urls related to this incident. **Lowercase only**", + optional: true, + }, + issuedAtBefore: { + type: "string", + label: "Issued At Before", + description: "The specific date when the incident was logged and officially opened. (Format: `YYYY-MM-DD`)", + optional: true, + }, + issuedAtAfter: { + type: "string", + label: "Issued At After", + description: "The specific date when the incident was logged and officially opened. (Format: `YYYY-MM-DD`)", + optional: true, + }, + startedAt: { + type: "string", + label: "Started At", + description: "The specific date when work on the incident commenced. (Format: `YYYY-MM-DD`)", + optional: true, + }, + endedAt: { + type: "string", + label: "Ended At", + description: "The specific date when the incident was successfully resolved. (Format: `YYYY-MM-DD`)", + optional: true, + }, + statuses: { + type: "string[]", + label: "Statuses", + description: "A list of statuses of the incident", + options: [ + "open", + "in-progress", + "closed", + "deleted", + ], + optional: true, + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of results to return", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.app.paginate({ + $, + resourceFn: this.app.getIncidents, + resourceName: "items", + resourceFnArgs: { + data: { + issued_at: { + before: this.issuedAtBefore, + after: this.issuedAtAfter, + }, + started_at: this.startedAt, + ended_at: this.endedAt, + statuses: this.statuses, + teams: this.teams, + services: this.services, + repository_urls: this.repositoryUrls, + }, + }, + max: this.maxResults, + }); + + $.export("$summary", `Successfully searched ${response.length} incident${response.length > 1 + ? "s" + : ""}`); + return response; + }, +}; diff --git a/components/linearb/linearb.app.mjs b/components/linearb/linearb.app.mjs index a347ab39012b2..6974b185d8250 100644 --- a/components/linearb/linearb.app.mjs +++ b/components/linearb/linearb.app.mjs @@ -5,12 +5,41 @@ import utils from "./common/utils.mjs"; export default { type: "app", app: "linearb", - propDefinitions: {}, + propDefinitions: { + teams: { + type: "string[]", + label: "Teams", + description: "The list of LinearB teams names related to this incident. (lowercase only)", + async options({ page }) { + const { items } = await this.getTeams({ + params: { + page, + }, + }); + + return items.map(({ name }) => name); + }, + }, + services: { + type: "string[]", + label: "Services", + description: "The list of LinearB services related to this incident. (lowercase only)", + async options({ page }) { + const { items } = await this.getServices({ + params: { + page, + }, + }); + + return items.map(({ name }) => name); + }, + }, + }, methods: { getUrl(path, versionPath = constants.VERSION_PATH.V1) { return `${constants.BASE_URL}${versionPath}${path}`; }, - getHeaders(headers) { + getHeaders(headers = {}) { return { "Content-Type": "application/json", "x-api-key": this.$auth.api_key, @@ -38,6 +67,26 @@ export default { ...args, }); }, + getTeams(args = {}) { + return this._makeRequest({ + path: "/teams", + versionPath: constants.VERSION_PATH.V2, + ...args, + }); + }, + getServices(args = {}) { + return this._makeRequest({ + path: "/services", + ...args, + }); + }, + getIncidents(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/incidents/search", + ...args, + }); + }, async *getIterations({ resourceFn, resourceFnArgs, resourceName, max = constants.DEFAULT_MAX, diff --git a/components/linearb/package.json b/components/linearb/package.json index 99d4673846499..e6d61379c995c 100644 --- a/components/linearb/package.json +++ b/components/linearb/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/linearb", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream LinearB Components", "main": "linearb.app.mjs", "keywords": [ @@ -13,6 +13,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.6.0" + "@pipedream/platform": "^3.1.0" } } diff --git a/components/linearb/sources/new-deploy-created/new-deploy-created.mjs b/components/linearb/sources/new-deploy-created/new-deploy-created.mjs index 40893a5aa200d..3f62669064d44 100644 --- a/components/linearb/sources/new-deploy-created/new-deploy-created.mjs +++ b/components/linearb/sources/new-deploy-created/new-deploy-created.mjs @@ -1,12 +1,12 @@ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; -import app from "../../linearb.app.mjs"; import constants from "../../common/constants.mjs"; +import app from "../../linearb.app.mjs"; export default { key: "linearb-new-deploy-created", name: "New Deploy Created", description: "Emit new event when a new deploy is created in LinearB. [See the documentation](https://docs.linearb.io/api-deployments/)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9a6f3c9068b3b..29f659eafa48c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1924,8 +1924,7 @@ importers: components/braintree: {} - components/brandblast: - specifiers: {} + components/brandblast: {} components/brandfetch: {} @@ -8018,8 +8017,8 @@ importers: components/linearb: dependencies: '@pipedream/platform': - specifier: ^1.6.0 - version: 1.6.6 + specifier: ^3.1.0 + version: 3.1.0 components/linguapop: dependencies: