Skip to content

Commit

Permalink
feat(core): add pieceConfig mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSelene committed Oct 14, 2024
1 parent 9b4fa60 commit 0cbb53a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/engine/src/lib/handler/piece-executor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { URL } from 'url'
import { ActionContext, ConnectionsManager, PauseHook, PauseHookParams, PiecePropertyMap, StaticPropsValue, StopHook, StopHookParams, TagsManager } from '@activepieces/pieces-framework'
import { SharedSystemProp } from '@activepieces/server-shared'
import { ActionType, assertNotNullOrUndefined, AUTHENTICATION_PROPERTY_NAME, ExecutionType, FlowRunStatus, GenericStepOutput, isNil, PauseType, PieceAction, StepOutputStatus } from '@activepieces/shared'
import dayjs from 'dayjs'
import { continueIfFailureHandler, handleExecutionError, runWithExponentialBackoff } from '../helper/error-handling'
Expand Down Expand Up @@ -116,6 +117,7 @@ const executeAction: ActionHandler<PieceAction> = async ({ action, executionStat
url.search = new URLSearchParams(params.queryParams).toString()
return url.toString()
},
pieceConfig: JSON.parse(SharedSystemProp.PIECES_CONFIG)?.[action.settings.pieceName] || {},
}
const runMethodToExecute = (constants.testSingleStepMode && !isNil(pieceAction.test)) ? pieceAction.test : pieceAction.run
const output = await runMethodToExecute(context)
Expand Down
3 changes: 2 additions & 1 deletion packages/pieces/community/framework/src/lib/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export type BaseActionContext<
generateResumeUrl: (params: {
queryParams: Record<string, string>
}) => string;
pieceConfig: object;
};

type BeginExecutionActionContext<
Expand Down Expand Up @@ -194,4 +195,4 @@ export enum StoreScope {
// Collection were deprecated in favor of project
PROJECT = 'COLLECTION',
FLOW = 'FLOW',
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ export const httpSendRequestAction = createAction({
} else {
proxyUrl = `http://${proxySettings.proxy_host}:${proxySettings.proxy_port}`;
}
const httpsAgent = new HttpsProxyAgent(proxyUrl)

const httpsAgent = new HttpsProxyAgent(proxyUrl);
const axiosClient = axios.create({
httpsAgent,
});
Expand Down
6 changes: 4 additions & 2 deletions packages/server/shared/src/lib/system/system-prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export enum SharedSystemProp {
MAX_FILE_SIZE_MB = 'MAX_FILE_SIZE_MB',

FRONTEND_URL = 'FRONTEND_URL',

// These are shared as the app is using the engine as a dependency for now.
CACHE_PATH = 'CACHE_PATH',
EXECUTION_MODE = 'EXECUTION_MODE',
Expand All @@ -101,20 +101,22 @@ export enum SharedSystemProp {
PIECES_SOURCE = 'PIECES_SOURCE',
ENGINE_EXECUTABLE_PATH = 'ENGINE_EXECUTABLE_PATH',
ENRICH_ERROR_CONTEXT = 'ENRICH_ERROR_CONTEXT',
PIECES_CONFIG = 'PIECES_CONFIG',

// Cloud Only & Enterprise Only
SENTRY_DSN = 'SENTRY_DSN',
LOKI_PASSWORD = 'LOKI_PASSWORD',
LOKI_URL = 'LOKI_URL',
LOKI_USERNAME = 'LOKI_USERNAME',


}

export enum WorkerSystemProps {
FLOW_WORKER_CONCURRENCY = 'FLOW_WORKER_CONCURRENCY',
SCHEDULED_WORKER_CONCURRENCY = 'SCHEDULED_WORKER_CONCURRENCY',
SCHEDULED_POLLING_COUNT = 'SCHEDULED_POLLING_COUNT',

// TODO: This is currently undocumented and used for testing purposes. Please document or remove as necessary.
POLLING_POOL_SIZE = 'POLLING_POOL_SIZE',
WORKER_TOKEN = 'WORKER_TOKEN',
Expand Down
1 change: 1 addition & 0 deletions packages/server/shared/src/lib/system/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const systemPropDefaultValues: Partial<Record<SystemProp, string>> = {
[AppSystemProp.MAX_CONCURRENT_JOBS_PER_PROJECT]: '100',
[AppSystemProp.PROJECT_RATE_LIMITER_ENABLED]: 'false',
[AppSystemProp.DEV_PIECES]: '',
[SharedSystemProp.PIECES_CONFIG]: '{}',

}

Expand Down

0 comments on commit 0cbb53a

Please sign in to comment.