Skip to content

Commit 5040561

Browse files
authored
Clone Apify (API Key) components to Apify (OAuth) (#18196)
* migrate components * pnpm-lock.yaml * update package.json * pnpm-lock.yaml
1 parent 5d04efc commit 5040561

File tree

11 files changed

+227
-7
lines changed

11 files changed

+227
-7
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../apify_oauth.app.mjs";
2+
import common from "@pipedream/apify/actions/get-dataset-items/get-dataset-items.mjs";
3+
4+
import { adjustPropDefinitions } from "../../common/utils.mjs";
5+
6+
const {
7+
name, description, type, ...others
8+
} = common;
9+
const props = adjustPropDefinitions(others.props, app);
10+
11+
export default {
12+
...others,
13+
key: "apify_oauth-get-dataset-items",
14+
version: "0.0.1",
15+
name,
16+
description,
17+
type,
18+
props: {
19+
apify: app,
20+
...props,
21+
},
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../apify_oauth.app.mjs";
2+
import common from "@pipedream/apify/actions/run-actor/run-actor.mjs";
3+
4+
import { adjustPropDefinitions } from "../../common/utils.mjs";
5+
6+
const {
7+
name, description, type, ...others
8+
} = common;
9+
const props = adjustPropDefinitions(others.props, app);
10+
11+
export default {
12+
...others,
13+
key: "apify_oauth-run-actor",
14+
version: "0.0.1",
15+
name,
16+
description,
17+
type,
18+
props: {
19+
apify: app,
20+
...props,
21+
},
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../apify_oauth.app.mjs";
2+
import common from "@pipedream/apify/actions/run-task-synchronously/run-task-synchronously.mjs";
3+
4+
import { adjustPropDefinitions } from "../../common/utils.mjs";
5+
6+
const {
7+
name, description, type, ...others
8+
} = common;
9+
const props = adjustPropDefinitions(others.props, app);
10+
11+
export default {
12+
...others,
13+
key: "apify_oauth-run-task-synchronously",
14+
version: "0.0.1",
15+
name,
16+
description,
17+
type,
18+
props: {
19+
apify: app,
20+
...props,
21+
},
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../apify_oauth.app.mjs";
2+
import common from "@pipedream/apify/actions/scrape-single-url/scrape-single-url.mjs";
3+
4+
import { adjustPropDefinitions } from "../../common/utils.mjs";
5+
6+
const {
7+
name, description, type, ...others
8+
} = common;
9+
const props = adjustPropDefinitions(others.props, app);
10+
11+
export default {
12+
...others,
13+
key: "apify_oauth-scrape-single-url",
14+
version: "0.0.1",
15+
name,
16+
description,
17+
type,
18+
props: {
19+
apify: app,
20+
...props,
21+
},
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../apify_oauth.app.mjs";
2+
import common from "@pipedream/apify/actions/set-key-value-store-record/set-key-value-store-record.mjs";
3+
4+
import { adjustPropDefinitions } from "../../common/utils.mjs";
5+
6+
const {
7+
name, description, type, ...others
8+
} = common;
9+
const props = adjustPropDefinitions(others.props, app);
10+
11+
export default {
12+
...others,
13+
key: "apify_oauth-set-key-value-store-record",
14+
version: "0.0.1",
15+
name,
16+
description,
17+
type,
18+
props: {
19+
apify: app,
20+
...props,
21+
},
22+
};
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
import common from "@pipedream/apify";
2+
13
export default {
24
type: "app",
35
app: "apify_oauth",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
...common.propDefinitions,
8+
},
59
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
10+
...common.methods,
11+
_headers() {
12+
return {
13+
"Content-Type": "application/json",
14+
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
15+
"x-apify-integration-platform": "pipedream",
16+
};
917
},
1018
},
1119
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export function adjustPropDefinitions(props, app) {
2+
return Object.fromEntries(
3+
Object.entries(props).map(([
4+
key,
5+
prop,
6+
]) => {
7+
if (typeof prop === "string") return [
8+
key,
9+
prop,
10+
];
11+
const {
12+
propDefinition, ...otherValues
13+
} = prop;
14+
if (propDefinition) {
15+
const [
16+
, ...otherDefs
17+
] = propDefinition;
18+
return [
19+
key,
20+
{
21+
propDefinition: [
22+
app,
23+
...otherDefs,
24+
],
25+
...otherValues,
26+
},
27+
];
28+
}
29+
return [
30+
key,
31+
otherValues.type === "app"
32+
? null
33+
: otherValues,
34+
];
35+
})
36+
.filter(([
37+
, value,
38+
]) => value),
39+
);
40+
}

components/apify_oauth/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/apify_oauth",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Apify (OAuth) Components",
55
"main": "apify_oauth.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/apify": "^0.3.0"
1417
}
15-
}
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../apify_oauth.app.mjs";
2+
import common from "@pipedream/apify/sources/new-finished-actor-run-instant/new-finished-actor-run-instant.mjs";
3+
4+
import { adjustPropDefinitions } from "../../common/utils.mjs";
5+
6+
const {
7+
name, description, type, ...others
8+
} = common;
9+
const props = adjustPropDefinitions(others.props, app);
10+
11+
export default {
12+
...others,
13+
key: "apify_oauth-new-finished-actor-run-instant",
14+
version: "0.0.1",
15+
name,
16+
description,
17+
type,
18+
props: {
19+
apify: app,
20+
...props,
21+
},
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../apify_oauth.app.mjs";
2+
import common from "@pipedream/apify/sources/new-finished-task-run-instant/new-finished-task-run-instant.mjs";
3+
4+
import { adjustPropDefinitions } from "../../common/utils.mjs";
5+
6+
const {
7+
name, description, type, ...others
8+
} = common;
9+
const props = adjustPropDefinitions(others.props, app);
10+
11+
export default {
12+
...others,
13+
key: "apify_oauth-new-finished-task-run-instant",
14+
version: "0.0.1",
15+
name,
16+
description,
17+
type,
18+
props: {
19+
apify: app,
20+
...props,
21+
},
22+
};

0 commit comments

Comments
 (0)