-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add IntegrationExecutionContext.stepMetadata
and propagate custom config type data
#795
base: main
Are you sure you want to change the base?
Conversation
|
IntegrationStep
, IntegrationInvocationConfig
typesIntegrationExecutionContext.stepMetadata
and propagate custom config type data
- Improved type definitions to allow for expressing the type of the | ||
`IntegrationExecutionConfig` that is returned from `loadExecutionConfig` and | ||
passed to `executionHandler` functions. | ||
- Added `IntegrationStepExecutionContext.stepMetadata` to allow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What use cases do you imagine needing the stepMetadata?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The integration I'm working on for generating load on persister/core is going to use step metadata in the executionHandler
bound to the step to generate data. After getting some sleep, I realized I can easily reference the step metadata object because it is a module constant in the file where the executionHandler
function is defined. It seems natural that the IntegrationStepExecutionContext
would have the metadata on it, so I carried on with making it work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the major improvements here!
Do you believe this will be a non-breaking version?
Can we help with the testing in handful of integrations?
I believe it should be non-breaking.
That will be helpful to coordinate, yes! I made some other changes last week that worked fine for a I'll be sure to link a local build of these into the |
210d267
to
f3f68d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve done the following:
- Rebased on main and cleaned up the commits a bit
- Linked into the integration I’m working on for load testing to be sure it works as desired for executing the integration in the CLI
- Linked into
jupiter-managed-integration
to be sure all of its tests are passing and no code changes were necessary
export type StepExecutionHandlerFunction< | ||
TConfig extends IntegrationInstanceConfig = IntegrationInstanceConfig, | ||
> = ExecutionHandlerFunction<IntegrationStepExecutionContext<TConfig>>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no references to this type: https://cs.github.com/?scope=org%3AJupiterOne&scopeName=JupiterOne&q=StepExecutionHandlerFunction
f3f68d1
to
d30bac8
Compare
…ig type on executionHandler
Fix stepMetadata field placement and propagate Clearly there needs to be a better test for this... Add a test to ensure stepMetadata reaches execution handler
d30bac8
to
9700fda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all of the improvements! I manually linked and tested this with graph-aws
and graph-google-cloud
, which is how I found a few of the issues.
Are there any documentation improvements that we should consider making?
Step<IntegrationStepExecutionContext<TConfig>>, | ||
export interface StepSpec< | ||
TInstanceConfig extends IntegrationInstanceConfig, | ||
TExecutionConfig extends IntegrationExecutionConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change unless we fall back to IntegrationExecutionConfig
as the default. The AWS integration is using StepSpec
heavily e.g. https://github.com/JupiterOne/graph-aws/blob/d402343227e24395b57725924dc60ac5a403fe5c/docs/spec/src/accessanalyzer/index.ts#L4
> { | ||
instanceConfig: TConfig; | ||
instanceConfig: TInstanceConfig; | ||
executionConfig: TExecutionConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a breaking change. Should this be optional? Many integrations are using the createMockExecutionContext
test function and will complain about the executionConfig
property being omitted. https://github.com/search?q=org%3AJupiterOne+%22createMockExecutionContext%22&type=code
TExecutionConfig extends IntegrationExecutionConfig = IntegrationExecutionConfig, | ||
> = CreateMockExecutionContextOptions<TInstanceConfig, TExecutionConfig> & | ||
CreateMockJobStateOptions & { | ||
stepMetadata: StepMetadata; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a breaking change too. stepMetadata
is now enforced. createMockStepExecutionContext
is used in many integrations: https://github.com/search?q=org%3AJupiterOne+%22createMockStepExecutionContext%22&type=code
I think we will want something like this:
export type CreateMockStepExecutionContextOptions<
TInstanceConfig extends IntegrationInstanceConfig = IntegrationInstanceConfig,
TExecutionConfig extends IntegrationExecutionConfig = IntegrationExecutionConfig,
> = CreateMockExecutionContextOptions<TInstanceConfig, TExecutionConfig> &
CreateMockJobStateOptions & {
stepMetadata?: StepMetadata;
};
// ...
// ...
export function createMockStepExecutionContext<
TInstanceConfig extends IntegrationInstanceConfig = IntegrationInstanceConfig,
TExecutionConfig extends IntegrationExecutionConfig = IntegrationExecutionConfig,
>(
options: CreateMockStepExecutionContextOptions<
TInstanceConfig,
TExecutionConfig
> = {
instanceConfigFields:
{} as IntegrationInstanceConfigFieldMap<TInstanceConfig>,
},
): MockIntegrationStepExecutionContext<TInstanceConfig, TExecutionConfig> {
return {
...createMockExecutionContext<TInstanceConfig, TExecutionConfig>(options),
stepMetadata: options.stepMetadata || ({} as StepMetadata),
jobState: createMockJobState(options),
};
}
Improved the
IntegrationStep
andIntegrationInvocationConfig
type definitions to allow for expressing the type of theIntegrationExecutionConfig
that is returned fromloadExecutionConfig
and passed toexecutionHandler
functions.This can be a patch release. The type parameters are optional.