Skip to content

Commit

Permalink
Merge branch 'main' into reenable-flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic authored Aug 30, 2023
2 parents 45c0da7 + b343654 commit 3d7e973
Show file tree
Hide file tree
Showing 21 changed files with 881 additions and 595 deletions.
14 changes: 8 additions & 6 deletions src/plugins/usage_collection/server/collector/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type {
/**
* Helper to find out whether to keep recursively looking or if we are on an end value
*/
export type RecursiveMakeSchemaFrom<U> = U extends object
export type RecursiveMakeSchemaFrom<U, RequireMeta> = U extends object
? Record<string, unknown> extends U
?
| {
Expand All @@ -31,19 +31,21 @@ export type RecursiveMakeSchemaFrom<U> = U extends object
description: string; // Intentionally enforcing the descriptions here
} & SchemaMetaOptional<U>;
}
| MakeSchemaFrom<U> // But still allow being explicit in the definition if they want to.
: MakeSchemaFrom<U>
| MakeSchemaFrom<U, RequireMeta> // But still allow being explicit in the definition if they want to.
: MakeSchemaFrom<U, RequireMeta>
: RequireMeta extends true
? { type: PossibleSchemaTypes<U>; _meta: { description: string } }
: { type: PossibleSchemaTypes<U>; _meta?: { description: string } };

/**
* The `schema` property in {@link CollectorOptions} must match the output of
* the `fetch` method. This type helps ensure that is correct
*/
export type MakeSchemaFrom<Base> = {
export type MakeSchemaFrom<Base, RequireMeta = false> = {
// Using Required to enforce all optional keys in the object
[Key in keyof Required<Base>]: Required<Base>[Key] extends Array<infer U>
? { type: 'array'; items: RecursiveMakeSchemaFrom<U> }
: RecursiveMakeSchemaFrom<Required<Base>[Key]>;
? { type: 'array'; items: RecursiveMakeSchemaFrom<U, RequireMeta> }
: RecursiveMakeSchemaFrom<Required<Base>[Key], RequireMeta>;
};

/**
Expand Down
215 changes: 169 additions & 46 deletions x-pack/plugins/apm/common/__snapshots__/apm_telemetry.test.ts.snap

Large diffs are not rendered by default.

Loading

0 comments on commit 3d7e973

Please sign in to comment.