Skip to content

[EPM] Consume TS types from EPR. Update EPM app code.#54955

Closed
jfsiii wants to merge 2 commits intoelastic:feature-ingestfrom
jfsiii:updated-registry-types
Closed

[EPM] Consume TS types from EPR. Update EPM app code.#54955
jfsiii wants to merge 2 commits intoelastic:feature-ingestfrom
jfsiii:updated-registry-types

Conversation

@jfsiii
Copy link
Contributor

@jfsiii jfsiii commented Jan 15, 2020

Summary

Use the TS types from elastic/package-registry#196

The app code is largely unchanged but there were a few types which marked properties as optional which were previously typed as required. I'll add notes inline.

@jfsiii jfsiii added the Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project label Jan 15, 2020
@jfsiii jfsiii requested a review from a team January 15, 2020 19:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest (Feature:EPM)

"private": true,
"license": "Elastic-License",
"dependencies": {
"@elastic/package-registry": "ssh://git@github.com:jfsiii/package-registry.git#ts-types",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consuming from my PR/fork right now. This can become github.com:elastic/package-registry in the short term, then @elastic/package-registry eventually.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be https:// instead of ssh:// ? I guess no user permissions are needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you're right. Updated in 80a5a26.

Will update to elastic/package-registry before merging this.

className?: string;
version: RequirementVersion;
}) {
export function Version({ className, version }: { className?: string; version?: string }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EPR type & golang code have versions as optional

style={{ width: '22.5rem', maxWidth: '100%' }}
/>
{image.src && (
<EuiImage
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EPR type and golang code have src as optional

export function createInput(vars: VarsEntry[], inputTemplate: string): string {
const view: Record<VarsEntry['name'], VarsEntry['default']> = {};
export function createInput(vars: Dataset['vars'] = [{}], inputTemplate: string): string {
const view: Record<string, string> = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is different from the others.

The existing EPM VarsEntry defines a type with name & default properties. However, the EPR type and golang code only say that it's an object. Essentially a Record<string, any>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruflin mind giving a 👍 or 👎 on this ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there was a reason I made it interface instead of string, meaning for some cases we need it. Suggestion:

  • Lets keep it in sync with the registry
  • If we change it to string, lets do a follow up to both repos to make it string, then we also see th effects.

Copy link
Contributor Author

@jfsiii jfsiii Jan 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are in sync now. That's the change.

EPM had a VarsEntry type which was object with keys of default and name. Both values were strings.

However, EPR has vars as an array of interfaces. Essentially an array of plain objects in JS.

I don't see anything in EPR guaranteeing there will be both default and name in the response or that they must be strings.

EPM probably adds these keys/values somewhere but that makes them an EPM type, not an EPR one.

I could add those in EPM, but I wondered if they were really needed since the type seemed so open. i.e. there could be any string value as a key and anything for the value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets go forward with this change. 👍

@jfsiii jfsiii changed the title Consume TS types from EPR. Update EPM app code. [EPM] Consume TS types from EPR. Update EPM app code. Jan 15, 2020
Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool how types are generated with struct2ts

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

export function createInput(vars: VarsEntry[], inputTemplate: string): string {
const view: Record<VarsEntry['name'], VarsEntry['default']> = {};
export function createInput(vars: Dataset['vars'] = [{}], inputTemplate: string): string {
const view: Record<string, string> = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there was a reason I made it interface instead of string, meaning for some cases we need it. Suggestion:

  • Lets keep it in sync with the registry
  • If we change it to string, lets do a follow up to both repos to make it string, then we also see th effects.

@jen-huang jen-huang added the Team:Fleet Team label for Observability Data Collection Fleet team label Mar 26, 2020
@ph
Copy link
Contributor

ph commented May 25, 2020

@jfsiii @ruflin Should we close this or more forward?

@ruflin
Copy link
Contributor

ruflin commented May 26, 2020

I think this would still be nice to have but is not a top priority. I suggest we close it for now but open an issue to track this idea for later.

@jfsiii
Copy link
Contributor Author

jfsiii commented Jun 1, 2020

I agree with @ruflin. I created elastic/package-registry#487 to track one idea I had.

@jfsiii jfsiii closed this Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project Team:Fleet Team label for Observability Data Collection Fleet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants