diff --git a/components/launchdarkly/actions/evaluate-feature-flag/evaluate-feature-flag.mjs b/components/launchdarkly/actions/evaluate-feature-flag/evaluate-feature-flag.mjs index 310f7ad6f9c1d..f0b2dea7cb5c7 100644 --- a/components/launchdarkly/actions/evaluate-feature-flag/evaluate-feature-flag.mjs +++ b/components/launchdarkly/actions/evaluate-feature-flag/evaluate-feature-flag.mjs @@ -4,7 +4,7 @@ export default { key: "launchdarkly-evaluate-feature-flag", name: "Evaluate Feature Flag", description: "Evaluates an existing feature flag for a specific user or in a general context. [See the documentation](https://apidocs.launchdarkly.com/tag/Contexts#operation/evaluateContextInstance).", - version: "0.0.1", + version: "0.0.2", type: "action", props: { app, diff --git a/components/launchdarkly/actions/get-feature-flag-status/get-feature-flag-status.mjs b/components/launchdarkly/actions/get-feature-flag-status/get-feature-flag-status.mjs new file mode 100644 index 0000000000000..7bf6f4a30eefa --- /dev/null +++ b/components/launchdarkly/actions/get-feature-flag-status/get-feature-flag-status.mjs @@ -0,0 +1,50 @@ +import app from "../../launchdarkly.app.mjs"; + +export default { + key: "launchdarkly-get-feature-flag-status", + name: "Get Feature Flag Status", + description: "Get the status of a feature flag. [See the documentation](https://launchdarkly.com/docs/api/feature-flags/get-feature-flag-status).", + version: "0.0.1", + type: "action", + props: { + app, + projectKey: { + propDefinition: [ + app, + "project", + ], + }, + environmentKey: { + propDefinition: [ + app, + "environment", + ({ projectKey }) => ({ + projectKey, + }), + ], + }, + featureFlagKey: { + propDefinition: [ + app, + "flag", + ({ + projectKey, environmentKey, + }) => ({ + projectKey, + environmentKey, + }), + ], + description: "The key of the feature flag to retrieve the status of", + }, + }, + async run({ $ }) { + const status = await this.app.getFeatureFlagStatus({ + $, + projectKey: this.projectKey, + environmentKey: this.environmentKey, + featureFlagKey: this.featureFlagKey, + }); + $.export("$summary", `Found feature flag status: ${status.name}`); + return status; + }, +}; diff --git a/components/launchdarkly/actions/get-feature-flag/get-feature-flag.mjs b/components/launchdarkly/actions/get-feature-flag/get-feature-flag.mjs new file mode 100644 index 0000000000000..9fa6cd758add0 --- /dev/null +++ b/components/launchdarkly/actions/get-feature-flag/get-feature-flag.mjs @@ -0,0 +1,49 @@ +import app from "../../launchdarkly.app.mjs"; + +export default { + key: "launchdarkly-get-feature-flag", + name: "Get Feature Flag", + description: "Get a feature flag by key. [See the documentation](https://launchdarkly.com/docs/api/feature-flags/get-feature-flag).", + version: "0.0.1", + type: "action", + props: { + app, + projectKey: { + propDefinition: [ + app, + "project", + ], + }, + environmentKey: { + propDefinition: [ + app, + "environment", + ({ projectKey }) => ({ + projectKey, + }), + ], + }, + featureFlagKey: { + propDefinition: [ + app, + "flag", + ({ + projectKey, environmentKey, + }) => ({ + projectKey, + environmentKey, + }), + ], + description: "The key of the feature flag to retrieve", + }, + }, + async run({ $ }) { + const flag = await this.app.getFeatureFlag({ + $, + projectKey: this.projectKey, + featureFlagKey: this.featureFlagKey, + }); + $.export("$summary", `Found feature flag ${flag.key}`); + return flag; + }, +}; diff --git a/components/launchdarkly/actions/get-project/get-project.mjs b/components/launchdarkly/actions/get-project/get-project.mjs new file mode 100644 index 0000000000000..60cb2cd988ac7 --- /dev/null +++ b/components/launchdarkly/actions/get-project/get-project.mjs @@ -0,0 +1,25 @@ +import app from "../../launchdarkly.app.mjs"; + +export default { + key: "launchdarkly-get-project", + name: "Get Project", + description: "Get a project by key. [See the documentation](https://launchdarkly.com/docs/api/projects/get-project).", + version: "0.0.1", + type: "action", + props: { + app, + projectKey: { + propDefinition: [ + app, + "project", + ], + }, + }, + async run({ $ }) { + const project = await this.app.getProject({ + projectKey: this.projectKey, + }); + $.export("$summary", `Found project: ${project.name}`); + return project; + }, +}; diff --git a/components/launchdarkly/actions/list-environments/list-environments.mjs b/components/launchdarkly/actions/list-environments/list-environments.mjs new file mode 100644 index 0000000000000..0d6adeb260660 --- /dev/null +++ b/components/launchdarkly/actions/list-environments/list-environments.mjs @@ -0,0 +1,76 @@ +import app from "../../launchdarkly.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + key: "launchdarkly-list-environments", + name: "List Environments", + description: "List all environments. [See the documentation](https://launchdarkly.com/docs/api/environments/get-environments-by-project).", + version: "0.0.1", + type: "action", + props: { + app, + projectKey: { + propDefinition: [ + app, + "project", + ], + }, + filter: { + type: "string[]", + label: "Filter", + description: "A list of filters. Each filter is of the form `field:value`. Example: `query:abc`. [See the documentation](https://launchdarkly.com/docs/api/environments/get-environments-by-project#filtering-environments) for supported fields.", + optional: true, + }, + sort: { + type: "string", + label: "Sort Field", + description: "The field to sort by. Fields prefixed by a dash ( - ) sort in descending order.", + options: [ + "createdOn", + "-createdOn", + "critical", + "-critical", + "name", + "-name", + ], + optional: true, + }, + maxResults: { + propDefinition: [ + app, + "maxResults", + ], + }, + }, + async run({ $ }) { + // validate array props + if (this.filter && !Array.isArray(this.filter)) { + throw new ConfigurationError("Filter must be an array"); + } + + const params = { + filter: this.filter?.join(","), + sort: this.sort, + }; + + const environments = this.app.paginate({ + fn: this.app.listEnvironments, + args: { + $, + projectKey: this.projectKey, + params, + }, + max: this.maxResults, + }); + + const results = []; + for await (const environment of environments) { + results.push(environment); + } + + $.export("$summary", `Found ${results.length} environment${results.length === 1 + ? "" + : "s"}`); + return results; + }, +}; diff --git a/components/launchdarkly/actions/list-feature-flags/list-feature-flags.mjs b/components/launchdarkly/actions/list-feature-flags/list-feature-flags.mjs new file mode 100644 index 0000000000000..2959628f690b1 --- /dev/null +++ b/components/launchdarkly/actions/list-feature-flags/list-feature-flags.mjs @@ -0,0 +1,109 @@ +import app from "../../launchdarkly.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + key: "launchdarkly-list-feature-flags", + name: "List Feature Flags", + description: "List all feature flags. [See the documentation](https://launchdarkly.com/docs/api/feature-flags/get-feature-flags).", + version: "0.0.1", + type: "action", + props: { + app, + projectKey: { + propDefinition: [ + app, + "project", + ], + }, + environmentKey: { + propDefinition: [ + app, + "environment", + ({ projectKey }) => ({ + projectKey, + }), + ], + }, + filter: { + type: "string[]", + label: "Filter", + description: "A list of filters. Each filter is of the form `field:value`. Example: `query:dark-mode`. [See the documentation](https://launchdarkly.com/docs/api/feature-flags/get-feature-flags#filtering-flags) for supported fields.", + optional: true, + }, + expand: { + type: "string[]", + label: "Expand", + description: "A list of properties that can reveal additional information in the response", + options: [ + "codeReferences", + "evaluation", + "migrationSettings", + ], + optional: true, + }, + sort: { + type: "string", + label: "Sort Field", + description: "The field to sort by. Fields prefixed by a dash ( - ) sort in descending order.", + options: [ + "creationDate", + "-creationDate", + "key", + "-key", + "maintainerId", + "-maintainerId", + "name", + "-name", + "tags", + "-tags", + "targetingModifiedDate", + "-targetingModifiedDate", + "type", + "-type", + ], + optional: true, + }, + maxResults: { + propDefinition: [ + app, + "maxResults", + ], + }, + }, + async run({ $ }) { + // validate array props + if (this.filter && !Array.isArray(this.filter)) { + throw new ConfigurationError("Filter must be an array"); + } + if (this.expand && !Array.isArray(this.expand)) { + throw new ConfigurationError("Expand must be an array"); + } + + const params = { + filter: this.filter?.join(","), + expand: this.expand?.join(","), + sort: this.sort, + env: this.environmentKey, + }; + + const flags = this.app.paginate({ + fn: this.app.listFeatureFlags, + args: { + $, + projectKey: this.projectKey, + params, + }, + max: this.maxResults, + }); + + const results = []; + for await (const flag of flags) { + results.push(flag); + } + + $.export("$summary", `Found ${results.length} feature flag${results.length === 1 + ? "" + : "s"}`); + return results; + }, +}; diff --git a/components/launchdarkly/actions/list-members/list-members.mjs b/components/launchdarkly/actions/list-members/list-members.mjs new file mode 100644 index 0000000000000..39bca88ae559e --- /dev/null +++ b/components/launchdarkly/actions/list-members/list-members.mjs @@ -0,0 +1,81 @@ +import app from "../../launchdarkly.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + key: "launchdarkly-list-members", + name: "List Members", + description: "List all members in an account. [See the documentation](https://launchdarkly.com/docs/api/account-members/get-members).", + version: "0.0.1", + type: "action", + props: { + app, + filter: { + type: "string[]", + label: "Filter", + description: "A list of filters. Each filter is of the form `field:value`. Example: `query:abc`. [See the documentation](https://launchdarkly.com/docs/api/account-members/get-members#filtering-members) for supported fields.", + optional: true, + }, + expand: { + type: "string[]", + label: "Expand", + description: "A list of properties that can reveal additional information in the response", + options: [ + "customRoles", + "roleAttributes", + ], + optional: true, + }, + sort: { + type: "string", + label: "Sort Field", + description: "The field to sort by. Fields prefixed by a dash ( - ) sort in descending order.", + options: [ + "displayName", + "-displayName", + "lastSeen", + "-lastSeen", + ], + optional: true, + }, + maxResults: { + propDefinition: [ + app, + "maxResults", + ], + }, + }, + async run({ $ }) { + // validate array props + if (this.filter && !Array.isArray(this.filter)) { + throw new ConfigurationError("Filter must be an array"); + } + if (this.expand && !Array.isArray(this.expand)) { + throw new ConfigurationError("Expand must be an array"); + } + + const params = { + filter: this.filter?.join(","), + expand: this.expand?.join(","), + sort: this.sort, + }; + + const members = this.app.paginate({ + fn: this.app.listAccountMembers, + args: { + $, + params, + }, + max: this.maxResults, + }); + + const results = []; + for await (const member of members) { + results.push(member); + } + + $.export("$summary", `Found ${results.length} member${results.length === 1 + ? "" + : "s"}`); + return results; + }, +}; diff --git a/components/launchdarkly/actions/list-projects/list-projects.mjs b/components/launchdarkly/actions/list-projects/list-projects.mjs new file mode 100644 index 0000000000000..4b3ec9610d0c6 --- /dev/null +++ b/components/launchdarkly/actions/list-projects/list-projects.mjs @@ -0,0 +1,80 @@ +import app from "../../launchdarkly.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + key: "launchdarkly-list-projects", + name: "List Projects", + description: "List all projects. [See the documentation](https://launchdarkly.com/docs/api/projects/get-projects).", + version: "0.0.1", + type: "action", + props: { + app, + filter: { + type: "string[]", + label: "Filter", + description: "A list of filters. Each filter is of the form `field:value`. Example: `query:abc`. [See the documentation](https://launchdarkly.com/docs/api/projects/get-projects#filtering-projects) for supported fields.", + optional: true, + }, + expand: { + type: "string[]", + label: "Expand", + description: "A list of properties that can reveal additional information in the response", + options: [ + "environments", + ], + optional: true, + }, + sort: { + type: "string", + label: "Sort Field", + description: "The field to sort by. Fields prefixed by a dash ( - ) sort in descending order.", + options: [ + "createdOn", + "-createdOn", + "name", + "-name", + ], + optional: true, + }, + maxResults: { + propDefinition: [ + app, + "maxResults", + ], + }, + }, + async run({ $ }) { + // validate array props + if (this.filter && !Array.isArray(this.filter)) { + throw new ConfigurationError("Filter must be an array"); + } + if (this.expand && !Array.isArray(this.expand)) { + throw new ConfigurationError("Expand must be an array"); + } + + const params = { + filter: this.filter?.join(","), + expand: this.expand?.join(","), + sort: this.sort, + }; + + const projects = this.app.paginate({ + fn: this.app.listProjects, + args: { + $, + params, + }, + max: this.maxResults, + }); + + const results = []; + for await (const project of projects) { + results.push(project); + } + + $.export("$summary", `Found ${results.length} project${results.length === 1 + ? "" + : "s"}`); + return results; + }, +}; diff --git a/components/launchdarkly/actions/toggle-feature-flag/toggle-feature-flag.mjs b/components/launchdarkly/actions/toggle-feature-flag/toggle-feature-flag.mjs index 890a97f43ecc7..7ae78def28a84 100644 --- a/components/launchdarkly/actions/toggle-feature-flag/toggle-feature-flag.mjs +++ b/components/launchdarkly/actions/toggle-feature-flag/toggle-feature-flag.mjs @@ -4,7 +4,7 @@ export default { key: "launchdarkly-toggle-feature-flag", name: "Toggle Feature Flag", description: "Toggles the status of a feature flag, switching it from active to inactive, or vice versa. [See the documentation](https://apidocs.launchdarkly.com/tag/Feature-flags#operation/patchFeatureFlag)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { app, diff --git a/components/launchdarkly/actions/update-feature-flag/update-feature-flag.mjs b/components/launchdarkly/actions/update-feature-flag/update-feature-flag.mjs index 96ba7203d488f..ad5ead94c2616 100644 --- a/components/launchdarkly/actions/update-feature-flag/update-feature-flag.mjs +++ b/components/launchdarkly/actions/update-feature-flag/update-feature-flag.mjs @@ -5,7 +5,7 @@ export default { key: "launchdarkly-update-feature-flag", name: "Update Feature Flag", description: "Updates an existing feature flag using a JSON object. [See the documentation](https://apidocs.launchdarkly.com/tag/Feature-flags#operation/patchFeatureFlag)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { app, diff --git a/components/launchdarkly/launchdarkly.app.mjs b/components/launchdarkly/launchdarkly.app.mjs index 8868132f45f22..a86aa74171b7d 100644 --- a/components/launchdarkly/launchdarkly.app.mjs +++ b/components/launchdarkly/launchdarkly.app.mjs @@ -128,6 +128,13 @@ export default { return items.map(mapper); }, }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of results to return", + optional: true, + default: 100, + }, }, methods: { getUrl(path) { @@ -227,5 +234,48 @@ export default { ...args, }); }, + getFeatureFlagStatus({ + projectKey, environmentKey, featureFlagKey, ...args + } = {}) { + return this._makeRequest({ + path: `/flag-statuses/${projectKey}/${environmentKey}/${featureFlagKey}`, + ...args, + }); + }, + getProject({ + projectKey, ...args + } = {}) { + return this._makeRequest({ + path: `/projects/${projectKey}`, + ...args, + }); + }, + async *paginate({ + fn, args = {}, max, + }) { + args = { + ...args, + params: { + ...args?.params, + limit: 100, + offset: 0, + }, + }; + let totalItems, count = 0; + do { + const { + items, totalCount, + } = await fn(args); + for (const item of items) { + yield item; + count++; + if (max && count >= max) { + return; + } + } + totalItems = totalCount; + args.params.offset += args.params.limit; + } while (count < totalItems); + }, }, }; diff --git a/components/launchdarkly/package.json b/components/launchdarkly/package.json index 4c2789a3025a5..88db7c4970e78 100644 --- a/components/launchdarkly/package.json +++ b/components/launchdarkly/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/launchdarkly", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream LaunchDarkly Components", "main": "launchdarkly.app.mjs", "keywords": [ diff --git a/components/launchdarkly/sources/new-access-token-event/new-access-token-event.mjs b/components/launchdarkly/sources/new-access-token-event/new-access-token-event.mjs index 1488f57efbcfb..97f3a9306dc4b 100644 --- a/components/launchdarkly/sources/new-access-token-event/new-access-token-event.mjs +++ b/components/launchdarkly/sources/new-access-token-event/new-access-token-event.mjs @@ -5,7 +5,7 @@ export default { key: "launchdarkly-new-access-token-event", name: "New Access Token Event", description: "Emit new event when a new access token activity happens. [See the documentation](https://apidocs.launchdarkly.com/tag/Webhooks#operation/postWebhook).", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { diff --git a/components/launchdarkly/sources/new-flag-event/new-flag-event.mjs b/components/launchdarkly/sources/new-flag-event/new-flag-event.mjs index 3d82355ee93ae..26691406ef143 100644 --- a/components/launchdarkly/sources/new-flag-event/new-flag-event.mjs +++ b/components/launchdarkly/sources/new-flag-event/new-flag-event.mjs @@ -5,7 +5,7 @@ export default { key: "launchdarkly-new-flag-event", name: "New Flag Event", description: "Emit new event when flag activity occurs. [See the documentation](https://apidocs.launchdarkly.com/tag/Webhooks#operation/postWebhook).", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/components/launchdarkly/sources/new-user-event/new-user-event.mjs b/components/launchdarkly/sources/new-user-event/new-user-event.mjs index 36239f3d33daa..8d774ddbbdf1d 100644 --- a/components/launchdarkly/sources/new-user-event/new-user-event.mjs +++ b/components/launchdarkly/sources/new-user-event/new-user-event.mjs @@ -5,7 +5,7 @@ export default { key: "launchdarkly-new-user-event", name: "New User Event", description: "Emit new event when user activity is noted. [See the documentation](https://apidocs.launchdarkly.com/tag/Webhooks#operation/postWebhook).", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", methods: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bcf01d1b69a95..0713945550989 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8982,8 +8982,7 @@ importers: components/mozilla_observatory: {} - components/mqtt: - specifiers: {} + components/mqtt: {} components/msg91: dependencies: @@ -9660,8 +9659,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/onesimpleapi: - specifiers: {} + components/onesimpleapi: {} components/onethread: {} @@ -40189,6 +40187,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: