@pipedream/muna 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import app from "../../muna.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "muna-create-prediction",
|
|
5
|
+
name: "Create A Prediction",
|
|
6
|
+
description: "Creates a new prediction using Muna AI. [See the documentation](https://docs.muna.ai/reference/predictions/create)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
app,
|
|
16
|
+
tag: {
|
|
17
|
+
type: "string",
|
|
18
|
+
label: "Predictor Tag",
|
|
19
|
+
description: "The predictor tag to use for the prediction. E.g., `@username/predictor-name`",
|
|
20
|
+
},
|
|
21
|
+
clientId: {
|
|
22
|
+
propDefinition: [
|
|
23
|
+
app,
|
|
24
|
+
"clientId",
|
|
25
|
+
({ tag }) => ({
|
|
26
|
+
tag,
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
configurationId: {
|
|
31
|
+
type: "string",
|
|
32
|
+
label: "Configuration ID",
|
|
33
|
+
description: "Prediction configuration identifier",
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
36
|
+
deviceId: {
|
|
37
|
+
type: "string",
|
|
38
|
+
label: "Device ID",
|
|
39
|
+
description: "Device identifier, used for choosing optimal implementation to respond with",
|
|
40
|
+
optional: true,
|
|
41
|
+
},
|
|
42
|
+
predictionId: {
|
|
43
|
+
type: "string",
|
|
44
|
+
label: "Prediction ID",
|
|
45
|
+
description: "For making predictions with embedded predictors, providing the original prediction identifier ensures that the same prediction implementation is provided to the device",
|
|
46
|
+
optional: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
async run({ $ }) {
|
|
50
|
+
const response = await this.app.createPrediction({
|
|
51
|
+
$,
|
|
52
|
+
data: {
|
|
53
|
+
tag: this.tag,
|
|
54
|
+
clientId: this.clientId,
|
|
55
|
+
configurationId: this.configurationId,
|
|
56
|
+
deviceId: this.deviceId,
|
|
57
|
+
predictionId: this.predictionId,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
$.export("$summary", `Successfully created prediction with ID: ${response.id}`);
|
|
62
|
+
return response;
|
|
63
|
+
},
|
|
64
|
+
};
|
package/muna.app.mjs
CHANGED
|
@@ -1,11 +1,56 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "app",
|
|
3
5
|
app: "muna",
|
|
4
|
-
propDefinitions: {
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
clientId: {
|
|
8
|
+
type: "string",
|
|
9
|
+
label: "Client ID",
|
|
10
|
+
description: "Prediction client identifier",
|
|
11
|
+
async options({ tag }) {
|
|
12
|
+
const { targets } = await this.getPredictor({
|
|
13
|
+
tag,
|
|
14
|
+
});
|
|
15
|
+
return targets;
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
5
19
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
getBaseUrl() {
|
|
21
|
+
return "https://api.muna.ai/v1";
|
|
22
|
+
},
|
|
23
|
+
getHeaders() {
|
|
24
|
+
return {
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
"Authorization": `Bearer ${this.$auth.api_key}`,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
makeRequest({
|
|
30
|
+
$ = this,
|
|
31
|
+
path,
|
|
32
|
+
...args
|
|
33
|
+
} = {}) {
|
|
34
|
+
return axios($, {
|
|
35
|
+
url: `${this.getBaseUrl()}${path}`,
|
|
36
|
+
headers: this.getHeaders(),
|
|
37
|
+
...args,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
getPredictor({
|
|
41
|
+
tag, ...args
|
|
42
|
+
}) {
|
|
43
|
+
return this.makeRequest({
|
|
44
|
+
path: `/predictors/${tag}`,
|
|
45
|
+
...args,
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
createPrediction(args = {}) {
|
|
49
|
+
return this.makeRequest({
|
|
50
|
+
method: "POST",
|
|
51
|
+
path: "/predictions",
|
|
52
|
+
...args,
|
|
53
|
+
});
|
|
9
54
|
},
|
|
10
55
|
},
|
|
11
|
-
};
|
|
56
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/muna",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pipedream Muna Components",
|
|
5
5
|
"main": "muna.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -11,5 +11,8 @@
|
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^3.2.2"
|
|
14
17
|
}
|
|
15
18
|
}
|