Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow async getStepStartStates in InvocationConfig #254

Closed
austinkelleher opened this issue Jul 27, 2020 · 2 comments
Closed

Allow async getStepStartStates in InvocationConfig #254

austinkelleher opened this issue Jul 27, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@austinkelleher
Copy link
Contributor

Problem

Sometimes permissions for a given config are not known at the beginning of an integration execution. These permissions may ultimately decide which steps are able to be executed. For example, in the Google Cloud integration, we do not know strictly from the config passed to the integration whether specific APIs have been enabled in the Google Cloud account or whether the integration has the correct scopes for steps to be invoked. As past of the getStepStartStates function in the Google Cloud integration, we would make a request to fetch this information and properly decide which steps can be invoked ahead of time.

The current value of the return type of getStepStartStates can be found here: https://github.com/JupiterOne/sdk/blob/master/packages/integration-sdk-core/src/types/config.ts#L16

export interface InvocationConfig<
  TExecutionContext extends ExecutionContext,
  TStepExecutionContext extends StepExecutionContext
> {
  getStepStartStates?: GetStepStartStatesFunction<TExecutionContext>;
 ...
}

Proposal

Change implementation of getStepStartStates in InvocationConfig to support sync and async methods:

export interface InvocationConfig<
  TExecutionContext extends ExecutionContext,
  TStepExecutionContext extends StepExecutionContext
> {
  validateInvocation?: InvocationValidationFunction<TExecutionContext>;
  getStepStartStates?: GetStepStartStatesFunction<TExecutionContext> | Promise<GetStepStartStatesFunction<TExecutionContext>>;
  integrationSteps: Step<TStepExecutionContext>[];
}
@austinkelleher austinkelleher added the enhancement New feature or request label Jul 27, 2020
@austinkelleher austinkelleher self-assigned this Jul 27, 2020
@aiwilliams
Copy link
Contributor

Oh, yeah, this should definitely be capable of async behavior.

Wouldn't the change be in the function type declaration?

export type GetStepStartStatesFunction<T extends ExecutionContext> = (
  context: T,
) => StepStartStates | Promise<StepStartStates>;

@austinkelleher
Copy link
Contributor Author

Yup I didn't look closely at the code yet. Just wanted to get the proposal out there. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants