Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
buttonsbond authored Mar 17, 2024
2 parents 62ae5b6 + 22dfb3c commit 00d4e4e
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 77 deletions.
12 changes: 11 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@
"avatar_url": "https://avatars.githubusercontent.com/u/10012140?v=4",
"profile": "https://github.com/yann120",
"contributions": [
"plugin"
"plugin",
"bug"
]
},
{
Expand Down Expand Up @@ -863,6 +864,15 @@
"contributions": [
"plugin"
]
},
{
"login": "AliasKingsWorth",
"name": "M Abdul Rauf",
"avatar_url": "https://avatars.githubusercontent.com/u/47811610?v=4",
"profile": "https://github.com/AliasKingsWorth",
"contributions": [
"doc"
]
}
],
"commitType": "docs"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Not into coding but still interested in contributing? Come join our [Discord](ht
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Autumnlight02"><img src="https://avatars.githubusercontent.com/u/68244453?v=4?s=100" width="100px;" alt="Aykut Akgün"/><br /><sub><b>Aykut Akgün</b></sub></a><br /><a href="https://github.com/activepieces/activepieces/commits?author=Autumnlight02" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yann120"><img src="https://avatars.githubusercontent.com/u/10012140?v=4?s=100" width="100px;" alt="Yann Petitjean"/><br /><sub><b>Yann Petitjean</b></sub></a><br /><a href="#plugin-yann120" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yann120"><img src="https://avatars.githubusercontent.com/u/10012140?v=4?s=100" width="100px;" alt="Yann Petitjean"/><br /><sub><b>Yann Petitjean</b></sub></a><br /><a href="#plugin-yann120" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/activepieces/activepieces/issues?q=author%3Ayann120" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/pfernandez98"><img src="https://avatars.githubusercontent.com/u/54374282?v=4?s=100" width="100px;" alt="pfernandez98"/><br /><sub><b>pfernandez98</b></sub></a><br /><a href="#plugin-pfernandez98" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://denieler.com"><img src="https://avatars.githubusercontent.com/u/2836281?v=4?s=100" width="100px;" alt="Daniel O."/><br /><sub><b>Daniel O.</b></sub></a><br /><a href="#plugin-denieler" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://myh.tw"><img src="https://avatars.githubusercontent.com/u/12458706?v=4?s=100" width="100px;" alt="Meng-Yuan Huang"/><br /><sub><b>Meng-Yuan Huang</b></sub></a><br /><a href="https://github.com/activepieces/activepieces/commits?author=MrMYHuang" title="Documentation">📖</a></td>
Expand All @@ -254,6 +254,7 @@ Not into coding but still interested in contributing? Come join our [Discord](ht
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AdamSelene"><img src="https://avatars.githubusercontent.com/u/79495?v=4?s=100" width="100px;" alt="Olivier Sambourg"/><br /><sub><b>Olivier Sambourg</b></sub></a><br /><a href="#plugin-AdamSelene" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Verlich"><img src="https://avatars.githubusercontent.com/u/30838131?v=4?s=100" width="100px;" alt="Ahmad(Ed)"/><br /><sub><b>Ahmad(Ed)</b></sub></a><br /><a href="#plugin-Verlich" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/leenmashni"><img src="https://avatars.githubusercontent.com/u/102361544?v=4?s=100" width="100px;" alt="leenmashni"/><br /><sub><b>leenmashni</b></sub></a><br /><a href="#plugin-leenmashni" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AliasKingsWorth"><img src="https://avatars.githubusercontent.com/u/47811610?v=4?s=100" width="100px;" alt="M Abdul Rauf"/><br /><sub><b>M Abdul Rauf</b></sub></a><br /><a href="https://github.com/activepieces/activepieces/commits?author=AliasKingsWorth" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion docs/embedding/configuration/initialize-embed.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The following scripts shouldn't contain async or defer attributes.
<script>
activepieces.configure(
{
prefix: "/";
prefix: "/",
instanceUrl:"http://your-instance-url.com",
jwtToken:"GENERATED_JWT_TOKEN",
embedding: {
Expand Down
90 changes: 50 additions & 40 deletions docs/install/configurations/environment-variables.mdx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionType, FlowRunResponse, FlowRunStatus, LoopStepOutput, PauseMetadata, StepOutput, StepOutputStatus, StopResponse, assertEqual, isNil } from '@activepieces/shared'
import { ActionType, FlowError, FlowRunResponse, FlowRunStatus, LoopStepOutput, PauseMetadata, StepOutput, StepOutputStatus, StopResponse, assertEqual, isNil, spreadIfDefined } from '@activepieces/shared'
import { StepExecutionPath } from './step-execution-path'
import { loggingUtils } from '../../helper/logging-utils'
import { nanoid } from 'nanoid'
Expand Down Expand Up @@ -29,6 +29,7 @@ export class FlowExecutorContext {
verdict: ExecutionVerdict
verdictResponse: VerdictResponse | undefined
currentPath: StepExecutionPath
error?: FlowError

/**
* Execution time in milliseconds
Expand All @@ -44,6 +45,7 @@ export class FlowExecutorContext {
this.currentState = copyFrom?.currentState ?? {}
this.verdict = copyFrom?.verdict ?? ExecutionVerdict.RUNNING
this.verdictResponse = copyFrom?.verdictResponse ?? undefined
this.error = copyFrom?.error ?? undefined
this.currentPath = copyFrom?.currentPath ?? StepExecutionPath.empty()
}

Expand Down Expand Up @@ -117,13 +119,19 @@ export class FlowExecutorContext {
const targetMap = getStateAtPath({ currentPath: this.currentPath, steps })
targetMap[stepName] = stepOutput

const error = stepOutput.status === StepOutputStatus.FAILED ? {
stepName,
message: stepOutput.errorMessage,
} : this.error

return new FlowExecutorContext({
...this,
tasks: this.tasks,
currentState: {
...this.currentState,
[stepName]: stepOutput.output,
},
...spreadIfDefined('error', error),
steps,
})
}
Expand Down Expand Up @@ -188,11 +196,13 @@ export class FlowExecutorContext {
if (verdictResponse?.reason === FlowRunStatus.INTERNAL_ERROR) {
return {
...baseExecutionOutput,
error: this.error,
status: FlowRunStatus.INTERNAL_ERROR,
}
}
return {
...baseExecutionOutput,
error: this.error,
status: FlowRunStatus.FAILED,
}
}
Expand Down
6 changes: 6 additions & 0 deletions packages/engine/src/lib/helper/execution-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export class ConnectionLoadingError extends EngineError {
}
}

export class ConnectionExpiredError extends UserError {
constructor(connectionName: string, cause?: unknown) {
super('ConnectionExpired', `connection (${connectionName}) expired, reconnect again`, cause)
}
}

export class StorageError extends EngineError {
constructor(key: string, cause?: unknown) {
super('StorageError', `Failed to read/write key (${key})`, cause)
Expand Down
10 changes: 6 additions & 4 deletions packages/engine/src/lib/services/connections.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StatusCodes } from 'http-status-codes'
import { AppConnection, AppConnectionType, CloudOAuth2ConnectionValue, BasicAuthConnectionValue, OAuth2ConnectionValueWithApp } from '@activepieces/shared'
import { AppConnection, AppConnectionType, CloudOAuth2ConnectionValue, BasicAuthConnectionValue, OAuth2ConnectionValueWithApp, AppConnectionStatus } from '@activepieces/shared'
import { EngineConstants } from '../handler/context/engine-constants'
import { ConnectionLoadingError, ConnectionNotFoundError, ExecutionError, FetchError } from '../helper/execution-errors'
import { ConnectionExpiredError, ConnectionLoadingError, ConnectionNotFoundError, ExecutionError, FetchError } from '../helper/execution-errors'

export const createConnectionService = ({ projectId, workerToken }: CreateConnectionServiceParams): ConnectionService => {
return {
Expand All @@ -22,8 +22,10 @@ export const createConnectionService = ({ projectId, workerToken }: CreateConnec
httpStatus: response.status,
})
}

const connection = await response.json()
const connection: AppConnection = await response.json()
if (connection.status === AppConnectionStatus.ERROR) {
throw new ConnectionExpiredError(connectionName)
}
return getConnectionValue(connection)
}
catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/common/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@activepieces/pieces-common",
"version": "0.2.11",
"version": "0.2.12",
"type": "commonjs"
}
6 changes: 4 additions & 2 deletions packages/pieces/community/common/src/lib/polling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ export const pollingHelper = {
): Promise<unknown[]> {
switch (polling.strategy) {
case DedupeStrategy.TIMEBASED: {
const lastEpochMilliSeconds =
(await store.get<number>('lastPoll')) ?? 0;
const lastEpochMilliSeconds = (await store.get<number>('lastPoll'));
if (isNil(lastEpochMilliSeconds)) {
throw new Error("lastPoll doesn't exist in the store.");
}
const items = await polling.items({
store,
auth,
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/imap/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-imap",
"version": "0.2.8"
"version": "0.2.9"
}
2 changes: 1 addition & 1 deletion packages/pieces/community/imap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const imapAuth = PieceAuth.CustomAuth({

export const imapPiece = createPiece({
displayName: 'IMAP',
description: 'Receive new emaiil trigger',
description: 'Receive new email trigger',

minimumSupportedRelease: '0.5.0',
logoUrl: 'https://cdn.activepieces.com/pieces/imap.png',
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@activepieces/shared",
"version": "0.10.95",
"version": "0.10.96",
"type": "commonjs"
}
3 changes: 2 additions & 1 deletion packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export * from './lib/project'
export { FileResponseInterface } from './lib/forms'
export * from './lib/platform'
import { TypeSystem } from '@sinclair/typebox/system'
export { FlowError } from './lib/flow-run/execution/flow-execution'
export { StopResponse } from './lib/flow-run/execution/flow-execution'
export { PauseType, FlowRunStatus, FlowRunResponse } from './lib/flow-run/execution/flow-execution'
export { DelayPauseMetadata, PauseMetadata, WebhookPauseMetadata } from './lib/flow-run/execution/flow-execution'
Expand All @@ -61,4 +62,4 @@ export { RetryFlowRequestBody } from './lib/flow-run/test-flow-run-request'
export * from './lib/flows/dto/flow-template-request'
// Look at https://github.com/sinclairzx81/typebox/issues/350
TypeSystem.ExactOptionalPropertyTypes = false
export * from './lib/support-url'
export * from './lib/support-url'
12 changes: 8 additions & 4 deletions packages/shared/src/lib/flow-run/execution/flow-execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ export const StopResponse = Type.Object({

export type StopResponse = Static<typeof StopResponse>

export const FlowError = Type.Object({
stepName: Type.String(),
message: Type.String(),
})

export type FlowError = Static<typeof FlowError>

const BaseExecutionResponse = {
...ExecutionState,
duration: Type.Number(),
tasks: Type.Number(),
tags: Type.Optional(Type.Array(Type.String())),
error: Type.Optional(Type.Object({
stepName: Type.String(),
message: Type.String(),
})),
error: Type.Optional(FlowError),
stopResponse: Type.Optional(StopResponse),
}

Expand Down
10 changes: 5 additions & 5 deletions tools/scripts/pieces/publish-pieces-to-npm.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { publishNxProject } from '../utils/publish-nx-project'
import { findAllPieces, findPiece, getSourceDirectory } from '../utils/piece-script-utils'
import { findAllPieces, findAllPiecesDirectoryInSource } from '../utils/piece-script-utils'

const publishPiece = async (nxProjectPath: string, pieceName: string): Promise<void> => {
console.info(`[publishPiece] pieceName=${pieceName}`)
const publishPiece = async (nxProjectPath: string): Promise<void> => {
console.info(`[publishPiece] nxProjectPath=${nxProjectPath}`)
await publishNxProject(nxProjectPath)
}

const main = async () => {
const piecesDirectory = await findAllPieces()
const publishResults = piecesDirectory.map(p => publishPiece(getSourceDirectory(p.directoryPath!), p.name))
const piecesSource = await findAllPiecesDirectoryInSource()
const publishResults = piecesSource.map(p => publishPiece(p))
await Promise.all(publishResults)
}

Expand Down
10 changes: 7 additions & 3 deletions tools/scripts/utils/package-pre-publish-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { readPackageJson } from './files'
const getLatestPublishedVersion = async (packageName: string, maxRetries: number = 5): Promise<string | null> => {
console.info(`[getLatestPublishedVersion] packageName=${packageName}`);

const retryDelay = (attempt: number) => Math.pow(4, attempt - 1) * 2000;
const retryDelay = (attempt: number) => Math.pow(4, attempt - 1) * 2000;

for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
Expand Down Expand Up @@ -36,10 +36,14 @@ const getLatestPublishedVersion = async (packageName: string, maxRetries: number


const packageChangedFromMainBranch = async (path: string): Promise<boolean> => {
console.info(`[packageChangedFromMainBranch] path=${path}`)
const cleaned = path.includes('/packages') ? `packages/` + path.split('packages/')[1] : path
if (!cleaned.startsWith('packages/')) {
throw new Error(`[packageChangedFromMainBranch] path=${cleaned} is not a valid package path`)
}
console.info(`[packageChangedFromMainBranch] path=${cleaned}`)

try {
const diff = await exec(`git diff --quiet origin/main -- ${path}`)
const diff = await exec(`git diff --quiet origin/main -- ${cleaned}`)
return false
}
catch (e) {
Expand Down
7 changes: 0 additions & 7 deletions tools/scripts/utils/piece-script-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ export async function findPiece(pieceName: string): Promise<PieceMetadata | null
return pieces.find((p) => p.name === pieceName) ?? null
}


export function getSourceDirectory(directoryPath: string): string {
const normalizedPath = normalize(directoryPath);
const sourceDirectory = normalizedPath.replace(join('dist', ''), '');
return sourceDirectory;
}

export async function findAllPiecesDirectoryInSource(): Promise<string[]> {
const piecesPath = resolve(cwd(), 'packages', 'pieces')
const paths = await traverseFolder(piecesPath)
Expand Down
6 changes: 3 additions & 3 deletions tools/scripts/validate-publishable-packages.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { findAllPieces } from './utils/piece-script-utils';
import {findAllPiecesDirectoryInSource } from './utils/piece-script-utils';
import { packagePrePublishChecks } from './utils/package-pre-publish-checks';

const main = async () => {
const piecesMetadata = await findAllPieces()
const piecesMetadata = await findAllPiecesDirectoryInSource()

const packages = [
...piecesMetadata.map(p => p.directoryPath!),
...piecesMetadata,
'packages/pieces/community/framework',
'packages/shared',
'packages/pieces/community/common',
Expand Down

0 comments on commit 00d4e4e

Please sign in to comment.