Index pattern serialize and de-serialize#68844
Conversation
ppisljar
left a comment
There was a problem hiding this comment.
minor comments but really excited to see this !
src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
Outdated
Show resolved
Hide resolved
|
|
||
| export interface IndexPatternSpec { | ||
| _id: string; | ||
| _type: string; |
There was a problem hiding this comment.
whats a type ? are this saved object properties ?
There was a problem hiding this comment.
yes, its a saved object property.
| _id: string; | ||
| _type: string; | ||
| _source: { | ||
| title: string; |
There was a problem hiding this comment.
why are this under _source ?
There was a problem hiding this comment.
feels like we might just want whats under _source ? could we restore index pattern withoiut the other stuff ?
There was a problem hiding this comment.
@ppisljar I agree that we could do that and it would likely be sufficient for your needs. However, that would be a different IndexPattern - one that couldn't be saved. I'd prefer to have just one kind of index pattern. We could consider having different types after some of the planned refactoring.
There was a problem hiding this comment.
what do you mean it couldn't be saved ? if
export interface IndexPatternSpec {
id: string;
title: string;
timeFieldName?: string;
fields: FieldSpec[];
version: string;
}
and then specToIndexPattern takes this in and gives you back indexPattern instance that can be saved.
lets try to make this IndexPatternSpec a bit easier to handle and more futureproof if possible. the information on how saved object looks like does not need to be exposed to the consumer (IndexPatternSpec can have a different shape as long as it contains sufficient information to reconstruct index pattern out of it)
There was a problem hiding this comment.
version can also be removed as that's a saved object thing
There was a problem hiding this comment.
I guess I didn't understand what you were asking for, happy to implement IndexPatternSpec as explained above.
That said, I think we need to keep version as its used when updating an index pattern saved object.
There was a problem hiding this comment.
we should always assume the latest version when creating index pattern from spec.
There was a problem hiding this comment.
version is used to ensure there aren't write collisions.
|
Pinging @elastic/kibana-app-arch (Team:AppArch) |
|
@elasticmachine merge upstream |
Here's an example version value - Why does this pertain to IndexPatterns? It has logic for reattempting saving when there are conflicting save attempts. perhaps I should change the value in IndexPatterns to be |
FieldFormats uses |
Yeah I know @ppisljar and I have discussed this before too. Since technically we are returning serializable state but not serialized state. I've seen usage of This is something I don't feel strongly about either, just falls into the same category for me of "stuff we should try to make consistent" Perhaps |
I literally can't use that with the |
I'm going to see if I can tighten up the types on |
|
i don't have preference about naming the functions, but i agree it would be nice if we would be consistent about it. Actually toSpec might be the best suggestion so far, i don't like serialize as it doesn't serialize, toJSON is nice as Luke mentions but can't be used everywhere. |
|
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
History
To update your PR or re-run it, just comment with: |
lukeelmers
left a comment
There was a problem hiding this comment.
Changes LGTM! Using toSpec and fromSpec works for me - we can look into changing those in aggs & visualize for consistency.
kertal
left a comment
There was a problem hiding this comment.
KibanaApp Code LGTM, didn't test the test, I trust good ol' jenkins to do so
* master: (90 commits) [Encrypted Saved Objects] Adds support for migrations in ESO (elastic#69513) [SIEM] Replace WithSource with useWithSource hook (elastic#68722) [Endpoint]EMT-451: add ability to filter endpoint metadata based on presence of unenrolled events (elastic#69708) rename old siem kibana config to securitySolution (elastic#69874) Remove unused Resolver code (elastic#69914) [Observability] Fixing dynamic return type based on the appName (elastic#69894) [SECURITY SOLUTION][INGEST] Task/endpoint list tests (elastic#69419) Fixes special clicks and 3rd party icon sizes in nav (elastic#69767) [APM] Catch annotations index permission error and log warning (elastic#69881) [Endpoint][Ingest Manager] minor code cleanup (elastic#69844) [Logs UI] Logs ui context menu (elastic#69915) Index pattern serialize and de-serialize (elastic#68844) [QA] Unskip functional tests (elastic#69760) [SIEM][Detection Engine] - Update DE to work with new exceptions schema (elastic#69715) Fixes elastic#69639: Ignore url.url fields above 2048 characters (elastic#69863) PR: Provide limit warnings to user when API limits are reached. (elastic#69590) [Maps] Remove broken button (elastic#69853) Makes usage collection methods available on start (elastic#69836) [SIEM][CASE] Improve Jira's labelling (elastic#69892) [Logs UI] Access ML via the programmatic plugin API (elastic#68905) ...
* serialize and deserialize index patterns # Conflicts: # src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts # src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts # src/plugins/data/common/index_patterns/types.ts # src/plugins/data/public/index.ts
* master: [Encrypted Saved Objects] Adds support for migrations in ESO (elastic#69513) [SIEM] Replace WithSource with useWithSource hook (elastic#68722) [Endpoint]EMT-451: add ability to filter endpoint metadata based on presence of unenrolled events (elastic#69708) rename old siem kibana config to securitySolution (elastic#69874) Remove unused Resolver code (elastic#69914) [Observability] Fixing dynamic return type based on the appName (elastic#69894) [SECURITY SOLUTION][INGEST] Task/endpoint list tests (elastic#69419) Fixes special clicks and 3rd party icon sizes in nav (elastic#69767) [APM] Catch annotations index permission error and log warning (elastic#69881) [Endpoint][Ingest Manager] minor code cleanup (elastic#69844) [Logs UI] Logs ui context menu (elastic#69915) Index pattern serialize and de-serialize (elastic#68844)
Summary
IndexPattern.toSpec() and IndexPatternService.specToIndexPattern(indexPatternSpec)
part of #68003
Checklist
For maintainers