Skip to content

New Components - clearly_defined #15455

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Feb 3, 2025
Merged
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
@@ -0,0 +1,60 @@
import clearlyDefined from "../../clearly_defined.app.mjs";

export default {
key: "clearly_defined-create-definition",
name: "Create Definition",
description: "Request the creation of a resource. [See the documentation](https://api.clearlydefined.io/api-docs/#/definitions/post_definitions).",
version: "0.0.1",
type: "action",
props: {
clearlyDefined,
type: {
propDefinition: [
clearlyDefined,
"type",
],
},
provider: {
propDefinition: [
clearlyDefined,
"provider",
],
},
namespace: {
propDefinition: [
clearlyDefined,
"namespace",
],
},
name: {
propDefinition: [
clearlyDefined,
"name",
],
},
revision: {
propDefinition: [
clearlyDefined,
"revision",
],
},
},
async run({ $ }) {
const component = `${this.type}/${this.provider}/${this.namespace}/${this.name}${this.revision
? "/" + this.revision
: ""}`;

const response = await this.clearlyDefined.createDefinition({
$,
data: [
component,
],
});

if (response && Object.keys(response).length > 0) {
$.export("$summary", "Successfully created definition");
}

return response;
},
};
140 changes: 140 additions & 0 deletions components/clearly_defined/actions/get-definitions/get-definitions.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import clearlyDefined from "../../clearly_defined.app.mjs";

export default {
key: "clearly_defined-get-definitions",
name: "Get Definitions",
description: "Gets the coordinates for all definitions that match the given pattern in the specified part of the definition. [See the documentation](https://api.clearlydefined.io/api-docs/#/definitions/get_definitions).",
version: "0.0.1",
type: "action",
props: {
clearlyDefined,
pattern: {
type: "string",
label: "Pattern",
description: "The string to search for in definition coordinates to get coordinate suggestions",
optional: true,
},
type: {
propDefinition: [
clearlyDefined,
"type",
],
optional: true,
},
provider: {
propDefinition: [
clearlyDefined,
"provider",
],
optional: true,
},
namespace: {
propDefinition: [
clearlyDefined,
"namespace",
],
optional: true,
},
name: {
propDefinition: [
clearlyDefined,
"name",
],
optional: true,
},
license: {
type: "string",
label: "License",
description: "The SPDX license identifier",
optional: true,
},
releasedAfter: {
type: "string",
label: "Released After",
description: "The minimum release date for the component. E.g. `2025-01-01`",
optional: true,
},
releasedBefore: {
type: "string",
label: "Released Before",
description: "The maximum release date for the component. E.g. `2025-01-01`",
optional: true,
},
minLicensedScore: {
type: "integer",
label: "Min Licensed Score",
description: "The minimum effective licensed score for the component",
optional: true,
},
maxLicensedScore: {
type: "integer",
label: "Max Licensed Score",
description: "The maximum effective licensed score for the component",
optional: true,
},
minDescribedScore: {
type: "integer",
label: "Min Described Score",
description: "The minimum effective described score for the component",
optional: true,
},
maxDescribedScore: {
type: "integer",
label: "Max Described Score",
description: "The maximum effective described score for the component",
optional: true,
},
sort: {
propDefinition: [
clearlyDefined,
"sort",
],
},
sortDirection: {
propDefinition: [
clearlyDefined,
"sortDirection",
],
},
continuationToken: {
type: "string",
label: "Continuation Token",
description: "Used for pagination. Seeded from the results of the previous query",
optional: true,
},
},
async run({ $ }) {
const response = await this.clearlyDefined.getDefinitions({
$,
params: {
pattern: this.pattern,
type: this.type,
provider: this.provider,
name: this.name,
namespace: this.namespace,
license: this.license,
releasedAfter: this.releasedAfter,
releasedBefore: this.releasedBefore,
minLicensedScore: this.minLicensedScore,
maxLicensedScore: this.maxLicensedScore,
minDescribedScore: this.minDescribedScore,
maxDescribedScore: this.maxDescribedScore,
sort: this.sort,
sortDesc: this.sortDirection === "descending",
continuationToken: this.continuationToken,
},
});

const length = response.data
? response.data.length
: response.length
? response.length
: 0;

$.export("$summary", `Successfully retrieved ${length} definition${length === 1
? ""
: "s"}`);

return response;
},
};
67 changes: 67 additions & 0 deletions components/clearly_defined/actions/get-harvests/get-harvests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import clearlyDefined from "../../clearly_defined.app.mjs";

export default {
key: "clearly_defined-get-harvests",
name: "Get Harvests",
description: "Get all the harvested data for a component revision. [See the documentation](https://api.clearlydefined.io/api-docs/#/harvest/get_harvest__type___provider___namespace___name___revision_).",
version: "0.0.1",
type: "action",
props: {
clearlyDefined,
type: {
propDefinition: [
clearlyDefined,
"type",
],
},
provider: {
propDefinition: [
clearlyDefined,
"provider",
],
},
namespace: {
propDefinition: [
clearlyDefined,
"namespace",
],
},
name: {
propDefinition: [
clearlyDefined,
"name",
],
},
revision: {
propDefinition: [
clearlyDefined,
"revision",
],
},
form: {
propDefinition: [
clearlyDefined,
"form",
],
},
},
async run({ $ }) {
const response = await this.clearlyDefined.getHarvests({
$,
type: this.type,
provider: this.provider,
name: this.name,
namespace: this.namespace,
revision: this.revision,
params: {
form: this.form,
},
});

if (response && Object.keys(response).length > 0) {
$.export("$summary", "Successfully retrieved harvest details");
}

return response;
},
};
93 changes: 88 additions & 5 deletions components/clearly_defined/clearly_defined.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,94 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "clearly_defined",
propDefinitions: {},
propDefinitions: {
type: {
type: "string",
label: "Type",
description: "The type of component",
options: constants.COMPONENT_TYPES,
},
provider: {
type: "string",
label: "Provider",
description: "Where the component can be found",
options: constants.COMPONENT_PROVIDERS,
},
namespace: {
type: "string",
label: "Namespace",
description: "Many component systems have namespaces. GitHub orgs, NPM namespace, Maven group id, Conda Subdir/Architecture. If your component does not have a namespace, use '-' (ASCII hyphen).",
},
name: {
type: "string",
label: "Name",
description: "The name of the component you want",
},
revision: {
type: "string",
label: "Revision",
description: "Components typically have some differentiator like a version or commit id. Use that here. If this segment is omitted, the latest revision is used (if that makes sense for the provider).",
optional: true,
},
sort: {
type: "string",
label: "Sort",
description: "The field to sort the results by",
options: constants.SORT_FIELDS,
optional: true,
},
sortDirection: {
type: "string",
label: "Sort Direction",
description: "The direction to sort the results by",
options: constants.SORT_DIRECTIONS,
optional: true,
},
form: {
type: "string",
label: "Form",
description: "Form of the response",
options: constants.RESPONSE_FORMS,
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `https://${this.$auth.environment}.clearlydefined.io`;
},
_makeRequest({
$ = this,
path,
...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
...opts,
});
},
getDefinitions(opts = {}) {
return this._makeRequest({
path: "/definitions",
...opts,
});
},
getHarvests({
type, provider, namespace, name, revision, ...opts
}) {
return this._makeRequest({
path: `/harvest/${type}/${provider}/${namespace}/${name}/${revision}`,
...opts,
});
},
createDefinition(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/definitions",
...opts,
});
},
},
};
};
Loading
Loading