Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
395 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "@activepieces/pieces-framework", | ||
"version": "0.7.21", | ||
"version": "0.7.22", | ||
"type": "commonjs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"extends": [ | ||
"../../../../.eslintrc.json" | ||
], | ||
"ignorePatterns": [ | ||
"!**/*" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx", | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# pieces-webhook | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Building | ||
|
||
Run `nx build pieces-webhook` to build the library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@activepieces/piece-webhook", | ||
"version": "0.0.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "pieces-webhook", | ||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/pieces/community/webhook/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/js:tsc", | ||
"outputs": [ | ||
"{options.outputPath}" | ||
], | ||
"options": { | ||
"outputPath": "dist/packages/pieces/community/webhook", | ||
"tsConfig": "packages/pieces/community/webhook/tsconfig.lib.json", | ||
"packageJson": "packages/pieces/community/webhook/package.json", | ||
"main": "packages/pieces/community/webhook/src/index.ts", | ||
"assets": [ | ||
"packages/pieces/community/webhook/*.md" | ||
], | ||
"buildableProjectDepsInPackageJsonType": "dependencies", | ||
"updateBuildableProjectDepsInPackageJson": true | ||
} | ||
}, | ||
"publish": { | ||
"command": "node tools/scripts/publish.mjs pieces-webhook {args.ver} {args.tag}", | ||
"dependsOn": [ | ||
"build" | ||
] | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": [ | ||
"{options.outputFile}" | ||
], | ||
"options": { | ||
"lintFilePatterns": [ | ||
"packages/pieces/community/webhook/**/*.ts" | ||
] | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
import { createPiece, PieceAuth } from "@activepieces/pieces-framework"; | ||
import { catchRequest } from "./lib/triggers/catch-hook"; | ||
|
||
export const webhook = createPiece({ | ||
displayName: "Webhook", | ||
auth: PieceAuth.None(), | ||
minimumSupportedRelease: '0.21.0', | ||
logoUrl: "https://cdn.activepieces.com/pieces/webhook.svg", | ||
authors: [], | ||
actions: [], | ||
triggers: [catchRequest], | ||
}); |
36 changes: 36 additions & 0 deletions
36
packages/pieces/community/webhook/src/lib/triggers/catch-hook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
import { createTrigger, Property, TriggerStrategy } from '@activepieces/pieces-framework'; | ||
|
||
const message = ` | ||
Copy the following URL: | ||
**{{webhookUrl}}** | ||
If you are expecting a reply from this webhook, append **/sync** to the URL. | ||
In that case, you will also have to add an HTTP step with **return response** to the end of your flow. | ||
If the flow takes more than **30 seconds**, it will give a **408 Request Timeout** response. | ||
`; | ||
|
||
export const catchRequest = createTrigger({ | ||
name: 'catch_request', | ||
displayName: 'Catch Request', | ||
description: 'Receive incoming HTTP/webhooks using any HTTP method such as GET, POST, PUT, DELETE, etc.', | ||
props: { | ||
markdown: Property.MarkDown({ | ||
value: message | ||
}), | ||
}, | ||
sampleData: null, | ||
type: TriggerStrategy.WEBHOOK, | ||
async onEnable() { | ||
// ignore | ||
}, | ||
async onDisable() { | ||
// ignore | ||
}, | ||
async run(context) { | ||
return [context.payload] | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "../../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], | ||
"include": ["src/**/*.ts"] | ||
} |
81 changes: 81 additions & 0 deletions
81
packages/server/api/src/app/database/migration/common/1709581196563-migrate-webhook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { logger } from 'server-shared' | ||
import { MigrationInterface, QueryRunner } from 'typeorm' | ||
|
||
const FLOW_VERSION_TABLE = 'flow_version' | ||
|
||
export class MigrateWebhook1709581196563 implements MigrationInterface { | ||
name = 'MigrateWebhook1709581196563' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
logger.info('MigrateWebhook1709581196563, started') | ||
|
||
let count = 0 | ||
const flowVersionsIds = await queryRunner.query('SELECT id FROM flow_version') | ||
|
||
for (const { id } of flowVersionsIds) { | ||
const [flowVersion] = await queryRunner.query('SELECT * FROM flow_version WHERE id = $1', [id]) | ||
const step = parseJson(flowVersion.trigger) | ||
const isString = typeof flowVersion.trigger === 'string' | ||
if (step.type === 'WEBHOOK') { | ||
step.type = 'PIECE_TRIGGER' | ||
step.settings = { | ||
input: {}, | ||
'inputUiInfo': step.settings.inputUiInfo, | ||
triggerName: 'catch_request', | ||
pieceName: '@activepieces/piece-webhook', | ||
pieceVersion: '~0.0.1', | ||
'pieceType': 'OFFICIAL', | ||
'packageType': 'REGISTRY', | ||
} | ||
count++ | ||
const result = isString ? JSON.stringify(step) : step | ||
await queryRunner.query( | ||
`UPDATE ${FLOW_VERSION_TABLE} SET trigger = $1 WHERE id = $2`, | ||
[result, flowVersion.id], | ||
) | ||
} | ||
} | ||
logger.info('MigrateWebhook1709581196563, finished flows ' + count) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
logger.info('rolling back MigrateWebhook1709581196563, started') | ||
|
||
let count = 0 | ||
const flowVersionsIds = await queryRunner.query('SELECT id FROM flow_version') | ||
|
||
for (const { id } of flowVersionsIds) { | ||
const [flowVersion] = await queryRunner.query('SELECT * FROM flow_version WHERE id = $1', [id]) | ||
|
||
const step = parseJson(flowVersion.trigger) | ||
const isString = typeof flowVersion.trigger === 'string' | ||
if (step.type === 'PIECE_TRIGGER') { | ||
if (step.settings.pieceName === '@activepieces/piece-webhook') { | ||
step.type = 'WEBHOOK' | ||
step.settings = { | ||
'inputUiInfo': step.settings.inputUiInfo, | ||
} | ||
count++ | ||
const result = isString ? JSON.stringify(step) : step | ||
await queryRunner.query( | ||
`UPDATE ${FLOW_VERSION_TABLE} SET trigger = $1 WHERE id = $2`, | ||
[result, flowVersion.id], | ||
) | ||
} | ||
} | ||
} | ||
logger.info( | ||
'rolling back MigrateWebhook1709581196563, finished flows ' + count, | ||
) | ||
} | ||
} | ||
|
||
|
||
const parseJson = (json: string) => { | ||
try { | ||
return JSON.parse(json) | ||
} | ||
catch (e) { | ||
return json | ||
} | ||
} |
File renamed without changes.
79 changes: 79 additions & 0 deletions
79
...server/api/src/app/database/migration/postgres/1709581196564-migrate-webhook-templates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { logger } from 'server-shared' | ||
import { MigrationInterface, QueryRunner } from 'typeorm' | ||
|
||
export class MigrateWebhookTemplate1709581196564 implements MigrationInterface { | ||
name = 'MigrateWebhookTemplate1709581196564' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
logger.info('MigrateWebhookTemplate1709581196564, started') | ||
|
||
let count = 0 | ||
const flowVersionsIds = await queryRunner.query('SELECT id FROM flow_template') | ||
|
||
for (const { id } of flowVersionsIds) { | ||
const [flowVersion] = await queryRunner.query('SELECT * FROM flow_template WHERE id = $1', [id]) | ||
const step = parseJson(flowVersion.template.trigger) | ||
const isString = typeof flowVersion.template.trigger === 'string' | ||
if (step.type === 'WEBHOOK') { | ||
step.type = 'PIECE_TRIGGER' | ||
step.settings = { | ||
input: {}, | ||
'inputUiInfo': step.settings.inputUiInfo, | ||
triggerName: 'catch_request', | ||
pieceName: '@activepieces/piece-webhook', | ||
pieceVersion: '~0.0.1', | ||
'pieceType': 'OFFICIAL', | ||
'packageType': 'REGISTRY', | ||
} | ||
count++ | ||
const result = isString ? JSON.stringify(step) : step | ||
await queryRunner.query( | ||
'UPDATE flow_template SET template = $1 WHERE id = $2', | ||
[result, flowVersion.id], | ||
) | ||
} | ||
} | ||
logger.info('MigrateWebhookTemplate1709581196564, finished flows ' + count) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
logger.info('rolling back MigrateWebhookTemplate1709581196564, started') | ||
|
||
let count = 0 | ||
const flowVersionsIds = await queryRunner.query('SELECT id FROM flow_template') | ||
|
||
for (const { id } of flowVersionsIds) { | ||
const [flowVersion] = await queryRunner.query('SELECT * FROM flow_template WHERE id = $1', [id]) | ||
|
||
const step = parseJson(flowVersion.template.trigger) | ||
const isString = typeof flowVersion.template.trigger === 'string' | ||
if (step.type === 'PIECE_TRIGGER') { | ||
if (step.settings.pieceName === '@activepieces/piece-webhook') { | ||
step.type = 'WEBHOOK' | ||
step.settings = { | ||
'inputUiInfo': step.settings.inputUiInfo, | ||
} | ||
count++ | ||
const result = isString ? JSON.stringify(step) : step | ||
await queryRunner.query( | ||
'UPDATE flow_template SET template = $1 WHERE id = $2', | ||
[result, flowVersion.id], | ||
) | ||
} | ||
} | ||
} | ||
logger.info( | ||
'rolling back MigrateWebhookTemplate1709581196564, finished flows ' + count, | ||
) | ||
} | ||
} | ||
|
||
|
||
const parseJson = (json: string) => { | ||
try { | ||
return JSON.parse(json) | ||
} | ||
catch (e) { | ||
return json | ||
} | ||
} |
Oops, something went wrong.