Skip to content

Commit 763548d

Browse files
authored
New Components - clearly_defined (#15455)
* new components * pnpm-lock.yaml
1 parent 7781048 commit 763548d

File tree

7 files changed

+447
-8
lines changed

7 files changed

+447
-8
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import clearlyDefined from "../../clearly_defined.app.mjs";
2+
3+
export default {
4+
key: "clearly_defined-create-definition",
5+
name: "Create Definition",
6+
description: "Request the creation of a resource. [See the documentation](https://api.clearlydefined.io/api-docs/#/definitions/post_definitions).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
clearlyDefined,
11+
type: {
12+
propDefinition: [
13+
clearlyDefined,
14+
"type",
15+
],
16+
},
17+
provider: {
18+
propDefinition: [
19+
clearlyDefined,
20+
"provider",
21+
],
22+
},
23+
namespace: {
24+
propDefinition: [
25+
clearlyDefined,
26+
"namespace",
27+
],
28+
},
29+
name: {
30+
propDefinition: [
31+
clearlyDefined,
32+
"name",
33+
],
34+
},
35+
revision: {
36+
propDefinition: [
37+
clearlyDefined,
38+
"revision",
39+
],
40+
},
41+
},
42+
async run({ $ }) {
43+
const component = `${this.type}/${this.provider}/${this.namespace}/${this.name}${this.revision
44+
? "/" + this.revision
45+
: ""}`;
46+
47+
const response = await this.clearlyDefined.createDefinition({
48+
$,
49+
data: [
50+
component,
51+
],
52+
});
53+
54+
if (response && Object.keys(response).length > 0) {
55+
$.export("$summary", "Successfully created definition");
56+
}
57+
58+
return response;
59+
},
60+
};
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import clearlyDefined from "../../clearly_defined.app.mjs";
2+
3+
export default {
4+
key: "clearly_defined-get-definitions",
5+
name: "Get Definitions",
6+
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).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
clearlyDefined,
11+
pattern: {
12+
type: "string",
13+
label: "Pattern",
14+
description: "The string to search for in definition coordinates to get coordinate suggestions",
15+
optional: true,
16+
},
17+
type: {
18+
propDefinition: [
19+
clearlyDefined,
20+
"type",
21+
],
22+
optional: true,
23+
},
24+
provider: {
25+
propDefinition: [
26+
clearlyDefined,
27+
"provider",
28+
],
29+
optional: true,
30+
},
31+
namespace: {
32+
propDefinition: [
33+
clearlyDefined,
34+
"namespace",
35+
],
36+
optional: true,
37+
},
38+
name: {
39+
propDefinition: [
40+
clearlyDefined,
41+
"name",
42+
],
43+
optional: true,
44+
},
45+
license: {
46+
type: "string",
47+
label: "License",
48+
description: "The SPDX license identifier",
49+
optional: true,
50+
},
51+
releasedAfter: {
52+
type: "string",
53+
label: "Released After",
54+
description: "The minimum release date for the component. E.g. `2025-01-01`",
55+
optional: true,
56+
},
57+
releasedBefore: {
58+
type: "string",
59+
label: "Released Before",
60+
description: "The maximum release date for the component. E.g. `2025-01-01`",
61+
optional: true,
62+
},
63+
minLicensedScore: {
64+
type: "integer",
65+
label: "Min Licensed Score",
66+
description: "The minimum effective licensed score for the component",
67+
optional: true,
68+
},
69+
maxLicensedScore: {
70+
type: "integer",
71+
label: "Max Licensed Score",
72+
description: "The maximum effective licensed score for the component",
73+
optional: true,
74+
},
75+
minDescribedScore: {
76+
type: "integer",
77+
label: "Min Described Score",
78+
description: "The minimum effective described score for the component",
79+
optional: true,
80+
},
81+
maxDescribedScore: {
82+
type: "integer",
83+
label: "Max Described Score",
84+
description: "The maximum effective described score for the component",
85+
optional: true,
86+
},
87+
sort: {
88+
propDefinition: [
89+
clearlyDefined,
90+
"sort",
91+
],
92+
},
93+
sortDirection: {
94+
propDefinition: [
95+
clearlyDefined,
96+
"sortDirection",
97+
],
98+
},
99+
continuationToken: {
100+
type: "string",
101+
label: "Continuation Token",
102+
description: "Used for pagination. Seeded from the results of the previous query",
103+
optional: true,
104+
},
105+
},
106+
async run({ $ }) {
107+
const response = await this.clearlyDefined.getDefinitions({
108+
$,
109+
params: {
110+
pattern: this.pattern,
111+
type: this.type,
112+
provider: this.provider,
113+
name: this.name,
114+
namespace: this.namespace,
115+
license: this.license,
116+
releasedAfter: this.releasedAfter,
117+
releasedBefore: this.releasedBefore,
118+
minLicensedScore: this.minLicensedScore,
119+
maxLicensedScore: this.maxLicensedScore,
120+
minDescribedScore: this.minDescribedScore,
121+
maxDescribedScore: this.maxDescribedScore,
122+
sort: this.sort,
123+
sortDesc: this.sortDirection === "descending",
124+
continuationToken: this.continuationToken,
125+
},
126+
});
127+
128+
const length = response.data
129+
? response.data.length
130+
: response.length
131+
? response.length
132+
: 0;
133+
134+
$.export("$summary", `Successfully retrieved ${length} definition${length === 1
135+
? ""
136+
: "s"}`);
137+
138+
return response;
139+
},
140+
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import clearlyDefined from "../../clearly_defined.app.mjs";
2+
3+
export default {
4+
key: "clearly_defined-get-harvests",
5+
name: "Get Harvests",
6+
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_).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
clearlyDefined,
11+
type: {
12+
propDefinition: [
13+
clearlyDefined,
14+
"type",
15+
],
16+
},
17+
provider: {
18+
propDefinition: [
19+
clearlyDefined,
20+
"provider",
21+
],
22+
},
23+
namespace: {
24+
propDefinition: [
25+
clearlyDefined,
26+
"namespace",
27+
],
28+
},
29+
name: {
30+
propDefinition: [
31+
clearlyDefined,
32+
"name",
33+
],
34+
},
35+
revision: {
36+
propDefinition: [
37+
clearlyDefined,
38+
"revision",
39+
],
40+
},
41+
form: {
42+
propDefinition: [
43+
clearlyDefined,
44+
"form",
45+
],
46+
},
47+
},
48+
async run({ $ }) {
49+
const response = await this.clearlyDefined.getHarvests({
50+
$,
51+
type: this.type,
52+
provider: this.provider,
53+
name: this.name,
54+
namespace: this.namespace,
55+
revision: this.revision,
56+
params: {
57+
form: this.form,
58+
},
59+
});
60+
61+
if (response && Object.keys(response).length > 0) {
62+
$.export("$summary", "Successfully retrieved harvest details");
63+
}
64+
65+
return response;
66+
},
67+
};
Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,94 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "clearly_defined",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
type: {
9+
type: "string",
10+
label: "Type",
11+
description: "The type of component",
12+
options: constants.COMPONENT_TYPES,
13+
},
14+
provider: {
15+
type: "string",
16+
label: "Provider",
17+
description: "Where the component can be found",
18+
options: constants.COMPONENT_PROVIDERS,
19+
},
20+
namespace: {
21+
type: "string",
22+
label: "Namespace",
23+
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).",
24+
},
25+
name: {
26+
type: "string",
27+
label: "Name",
28+
description: "The name of the component you want",
29+
},
30+
revision: {
31+
type: "string",
32+
label: "Revision",
33+
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).",
34+
optional: true,
35+
},
36+
sort: {
37+
type: "string",
38+
label: "Sort",
39+
description: "The field to sort the results by",
40+
options: constants.SORT_FIELDS,
41+
optional: true,
42+
},
43+
sortDirection: {
44+
type: "string",
45+
label: "Sort Direction",
46+
description: "The direction to sort the results by",
47+
options: constants.SORT_DIRECTIONS,
48+
optional: true,
49+
},
50+
form: {
51+
type: "string",
52+
label: "Form",
53+
description: "Form of the response",
54+
options: constants.RESPONSE_FORMS,
55+
optional: true,
56+
},
57+
},
558
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
59+
_baseUrl() {
60+
return `https://${this.$auth.environment}.clearlydefined.io`;
61+
},
62+
_makeRequest({
63+
$ = this,
64+
path,
65+
...opts
66+
}) {
67+
return axios($, {
68+
url: `${this._baseUrl()}${path}`,
69+
...opts,
70+
});
71+
},
72+
getDefinitions(opts = {}) {
73+
return this._makeRequest({
74+
path: "/definitions",
75+
...opts,
76+
});
77+
},
78+
getHarvests({
79+
type, provider, namespace, name, revision, ...opts
80+
}) {
81+
return this._makeRequest({
82+
path: `/harvest/${type}/${provider}/${namespace}/${name}/${revision}`,
83+
...opts,
84+
});
85+
},
86+
createDefinition(opts = {}) {
87+
return this._makeRequest({
88+
method: "POST",
89+
path: "/definitions",
90+
...opts,
91+
});
992
},
1093
},
11-
};
94+
};

0 commit comments

Comments
 (0)