@rooted-software/piece-sitestacker-http-request 0.1.4 → 0.1.6
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.
|
@@ -4,7 +4,7 @@ export declare const sendRequest: import("@activepieces/pieces-framework").IActi
|
|
|
4
4
|
secretAccessKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
5
|
}>, {
|
|
6
6
|
method: import("@activepieces/pieces-framework").StaticDropdownProperty<HttpMethod, true>;
|
|
7
|
-
|
|
7
|
+
path: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
8
|
headers: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
9
9
|
body_type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
10
10
|
body: import("@activepieces/pieces-framework").JsonProperty<false>;
|
|
@@ -66,9 +66,9 @@ exports.sendRequest = (0, pieces_framework_1.createAction)({
|
|
|
66
66
|
],
|
|
67
67
|
},
|
|
68
68
|
}),
|
|
69
|
-
|
|
70
|
-
displayName: '
|
|
71
|
-
description: 'The
|
|
69
|
+
path: pieces_framework_1.Property.ShortText({
|
|
70
|
+
displayName: 'Path',
|
|
71
|
+
description: 'The API path (e.g. /api/users). Base URL is read from SS_URL environment variable.',
|
|
72
72
|
required: true,
|
|
73
73
|
}),
|
|
74
74
|
headers: pieces_framework_1.Property.Object({
|
|
@@ -107,7 +107,12 @@ exports.sendRequest = (0, pieces_framework_1.createAction)({
|
|
|
107
107
|
}),
|
|
108
108
|
},
|
|
109
109
|
async run(context) {
|
|
110
|
-
const { method,
|
|
110
|
+
const { method, path, headers, body_type, body, body_raw, timeout } = context.propsValue;
|
|
111
|
+
const baseUrl = (process.env.SS_URL || '').replace(/\/+$/, '');
|
|
112
|
+
if (!baseUrl) {
|
|
113
|
+
throw new Error('SS_URL environment variable is not set');
|
|
114
|
+
}
|
|
115
|
+
const url = `${baseUrl}${path.startsWith('/') ? path : '/' + path}`;
|
|
111
116
|
const accessKeyId = context.auth.props['accessKeyId'];
|
|
112
117
|
const secretAccessKey = context.auth.props['secretAccessKey'];
|
|
113
118
|
const now = new Date();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rooted-software/piece-sitestacker-http-request",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "HTTP request piece with SiteStacker HMAC authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,6 +32,14 @@
|
|
|
32
32
|
"homepage": "https://github.com/Rooted-Software/piece-sitestacker#readme",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@activepieces/pieces-common": "0.11.5",
|
|
35
|
-
"@activepieces/pieces-framework": "0.25.3"
|
|
35
|
+
"@activepieces/pieces-framework": "0.25.3",
|
|
36
|
+
"@activepieces/shared": "0.34.0",
|
|
37
|
+
"@sinclair/typebox": "0.34.11",
|
|
38
|
+
"deepmerge-ts": "7.1.0",
|
|
39
|
+
"i18next": "23.13.0",
|
|
40
|
+
"nanoid": "3.3.8",
|
|
41
|
+
"semver": "7.6.0",
|
|
42
|
+
"socket.io-client": "4.8.1",
|
|
43
|
+
"tslib": "2.6.2"
|
|
36
44
|
}
|
|
37
45
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Deploy piece to Activepieces server
|
|
5
|
+
# Usage: ./scripts/deploy.sh [version]
|
|
6
|
+
# If version is omitted, reads from package.json
|
|
7
|
+
|
|
8
|
+
PIECE_NAME="@rooted-software/piece-sitestacker-http-request"
|
|
9
|
+
SERVER_HOST="146.190.148.135"
|
|
10
|
+
SSH_KEY="$HOME/.ssh/nh_sync"
|
|
11
|
+
SSH_USER="marshal"
|
|
12
|
+
CONTAINER="activepieces-activepieces-1"
|
|
13
|
+
DB_CONTAINER="activepieces-postgres-1"
|
|
14
|
+
DB_USER="activepieces"
|
|
15
|
+
JWT_SECRET="7UCmOGbVu2PoVOCLADqyYDCAEUfQq4xUzGRPJQ023DU="
|
|
16
|
+
|
|
17
|
+
# Get version from argument or package.json
|
|
18
|
+
VERSION="${1:-$(node -p "require('./package.json').version")}"
|
|
19
|
+
echo "Deploying ${PIECE_NAME}@${VERSION}"
|
|
20
|
+
|
|
21
|
+
SSH_CMD="ssh -i ${SSH_KEY} -o StrictHostKeyChecking=accept-new ${SSH_USER}@${SERVER_HOST}"
|
|
22
|
+
|
|
23
|
+
# Get IDs from database
|
|
24
|
+
USER_ID=$(${SSH_CMD} "docker exec ${DB_CONTAINER} psql -U ${DB_USER} -t -A -c \"SELECT id FROM \\\"user\\\" LIMIT 1;\"")
|
|
25
|
+
PROJECT_ID=$(${SSH_CMD} "docker exec ${DB_CONTAINER} psql -U ${DB_USER} -t -A -c \"SELECT id FROM project LIMIT 1;\"")
|
|
26
|
+
PLATFORM_ID=$(${SSH_CMD} "docker exec ${DB_CONTAINER} psql -U ${DB_USER} -t -A -c \"SELECT id FROM platform LIMIT 1;\"")
|
|
27
|
+
TOKEN_VERSION=$(${SSH_CMD} "docker exec ${DB_CONTAINER} psql -U ${DB_USER} -t -A -c \"SELECT ui.\\\"tokenVersion\\\" FROM \\\"user\\\" u JOIN user_identity ui ON u.\\\"identityId\\\" = ui.id WHERE u.id = '${USER_ID}';\"")
|
|
28
|
+
|
|
29
|
+
echo "User: ${USER_ID}, Project: ${PROJECT_ID}, Platform: ${PLATFORM_ID}"
|
|
30
|
+
|
|
31
|
+
# Mint JWT inside the container
|
|
32
|
+
TOKEN=$(${SSH_CMD} "docker exec ${CONTAINER} node -e \"
|
|
33
|
+
const jwt = require('/usr/src/app/dist/packages/server/api/node_modules/jsonwebtoken');
|
|
34
|
+
const token = jwt.sign({
|
|
35
|
+
id:'${USER_ID}',
|
|
36
|
+
type:'USER',
|
|
37
|
+
projectId:'${PROJECT_ID}',
|
|
38
|
+
platform:{id:'${PLATFORM_ID}'},
|
|
39
|
+
tokenVersion:'${TOKEN_VERSION}'
|
|
40
|
+
}, '${JWT_SECRET}', {expiresIn:'5m', issuer:'activepieces', algorithm:'HS256'});
|
|
41
|
+
console.log(token);
|
|
42
|
+
\"")
|
|
43
|
+
|
|
44
|
+
echo "Got auth token"
|
|
45
|
+
|
|
46
|
+
# Delete existing version if present
|
|
47
|
+
echo "Removing old version if exists..."
|
|
48
|
+
${SSH_CMD} "docker exec ${DB_CONTAINER} psql -U ${DB_USER} -c \"DELETE FROM piece_metadata WHERE name = '${PIECE_NAME}' AND version = '${VERSION}';\"" > /dev/null 2>&1 || true
|
|
49
|
+
|
|
50
|
+
# Install via API
|
|
51
|
+
echo "Installing piece via API..."
|
|
52
|
+
RESULT=$(${SSH_CMD} "docker exec ${CONTAINER} curl -s -w '\n%{http_code}' -X POST http://localhost:80/api/v1/pieces \
|
|
53
|
+
-H 'Content-Type: application/json' \
|
|
54
|
+
-H 'Authorization: Bearer ${TOKEN}' \
|
|
55
|
+
-d '{\"pieceName\":\"${PIECE_NAME}\",\"pieceVersion\":\"${VERSION}\",\"projectId\":\"${PROJECT_ID}\",\"packageType\":\"REGISTRY\",\"scope\":\"PLATFORM\"}'")
|
|
56
|
+
|
|
57
|
+
HTTP_CODE=$(echo "$RESULT" | tail -1)
|
|
58
|
+
BODY=$(echo "$RESULT" | sed '$d')
|
|
59
|
+
|
|
60
|
+
if [ "$HTTP_CODE" = "201" ]; then
|
|
61
|
+
echo "Successfully installed ${PIECE_NAME}@${VERSION}"
|
|
62
|
+
else
|
|
63
|
+
echo "Failed with HTTP ${HTTP_CODE}:"
|
|
64
|
+
echo "$BODY"
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
@@ -43,9 +43,9 @@ export const sendRequest = createAction({
|
|
|
43
43
|
],
|
|
44
44
|
},
|
|
45
45
|
}),
|
|
46
|
-
|
|
47
|
-
displayName: '
|
|
48
|
-
description: 'The
|
|
46
|
+
path: Property.ShortText({
|
|
47
|
+
displayName: 'Path',
|
|
48
|
+
description: 'The API path (e.g. /api/users). Base URL is read from SS_URL environment variable.',
|
|
49
49
|
required: true,
|
|
50
50
|
}),
|
|
51
51
|
headers: Property.Object({
|
|
@@ -85,8 +85,13 @@ export const sendRequest = createAction({
|
|
|
85
85
|
}),
|
|
86
86
|
},
|
|
87
87
|
async run(context) {
|
|
88
|
-
const { method,
|
|
88
|
+
const { method, path, headers, body_type, body, body_raw, timeout } =
|
|
89
89
|
context.propsValue;
|
|
90
|
+
const baseUrl = (process.env.SS_URL || '').replace(/\/+$/, '');
|
|
91
|
+
if (!baseUrl) {
|
|
92
|
+
throw new Error('SS_URL environment variable is not set');
|
|
93
|
+
}
|
|
94
|
+
const url = `${baseUrl}${path.startsWith('/') ? path : '/' + path}`;
|
|
90
95
|
const accessKeyId = context.auth.props['accessKeyId'] as string;
|
|
91
96
|
const secretAccessKey = context.auth.props['secretAccessKey'] as string;
|
|
92
97
|
|