Skip to content

Commit 62de97e

Browse files
authored
Merge branch '8.19' into backport/8.19/pr-226887
2 parents d7f943d + 2bc37e6 commit 62de97e

13 files changed

Lines changed: 644 additions & 15 deletions

File tree

src/platform/packages/shared/deeplinks/observability/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export const APM_APP_ID = 'apm';
2222

2323
export const SYNTHETICS_APP_ID = 'synthetics';
2424

25+
export const UPTIME_APP_ID = 'uptime';
26+
2527
export const OBSERVABILITY_ONBOARDING_APP_ID = 'observabilityOnboarding';
2628

2729
export const SLO_APP_ID = 'slo';

src/platform/packages/shared/deeplinks/observability/deep_links.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
OBSERVABILITY_ONBOARDING_APP_ID,
1717
OBSERVABILITY_OVERVIEW_APP_ID,
1818
SYNTHETICS_APP_ID,
19+
UPTIME_APP_ID,
1920
SLO_APP_ID,
2021
AI_ASSISTANT_APP_ID,
2122
OBLT_UX_APP_ID,
@@ -31,6 +32,7 @@ type ObservabilityOverviewApp = typeof OBSERVABILITY_OVERVIEW_APP_ID;
3132
type MetricsApp = typeof METRICS_APP_ID;
3233
type ApmApp = typeof APM_APP_ID;
3334
type SyntheticsApp = typeof SYNTHETICS_APP_ID;
35+
type UptimeApp = typeof UPTIME_APP_ID;
3436
type ObservabilityOnboardingApp = typeof OBSERVABILITY_ONBOARDING_APP_ID;
3537
type SloApp = typeof SLO_APP_ID;
3638
type AiAssistantApp = typeof AI_ASSISTANT_APP_ID;
@@ -48,6 +50,7 @@ export type AppId =
4850
| ApmApp
4951
| MetricsApp
5052
| SyntheticsApp
53+
| UptimeApp
5154
| SloApp
5255
| AiAssistantApp
5356
| ObltUxApp
@@ -84,6 +87,8 @@ export type ApmLinkId =
8487

8588
export type SyntheticsLinkId = 'certificates' | 'overview';
8689

90+
export type UptimeLinkId = 'Certificates';
91+
8792
export type ProfilingLinkId = 'stacktraces' | 'flamegraphs' | 'functions';
8893

8994
export type StreamsLinkId = 'overview';
@@ -94,6 +99,7 @@ export type LinkId =
9499
| MetricsLinkId
95100
| ApmLinkId
96101
| SyntheticsLinkId
102+
| UptimeLinkId
97103
| ProfilingLinkId
98104
| StreamsLinkId;
99105

@@ -104,6 +110,7 @@ export type DeepLinkId =
104110
| `${MetricsApp}:${MetricsLinkId}`
105111
| `${ApmApp}:${ApmLinkId}`
106112
| `${SyntheticsApp}:${SyntheticsLinkId}`
113+
| `${UptimeApp}:${UptimeLinkId}`
107114
| `${ObltProfilingApp}:${ProfilingLinkId}`
108115
| `${InventoryApp}:${InventoryLinkId}`
109116
| `${StreamsApp}:${StreamsLinkId}`;

x-pack/platform/packages/shared/kbn-streamlang/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@
1313
"exclude": [
1414
"target/**/*"
1515
],
16-
"kbn_references": []
16+
"kbn_references": [
17+
"@kbn/zod",
18+
"@kbn/zod-helpers",
19+
"@kbn/streams-schema",
20+
]
1721
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { z } from '@kbn/zod';
9+
import { NonEmptyString } from '@kbn/zod-helpers';
10+
import { createIsNarrowSchema } from '@kbn/streams-schema';
11+
12+
const stringOrNumberOrBoolean = z.union([z.string(), z.number(), z.boolean()]);
13+
14+
export interface ShorthandBinaryFilterCondition {
15+
field: string;
16+
eq?: string | number | boolean;
17+
neq?: string | number | boolean;
18+
lt?: string | number | boolean;
19+
lte?: string | number | boolean;
20+
gt?: string | number | boolean;
21+
gte?: string | number | boolean;
22+
contains?: string | number | boolean;
23+
startsWith?: string | number | boolean;
24+
endsWith?: string | number | boolean;
25+
}
26+
27+
// Shorthand binary: field + one of the operator keys
28+
export const shorthandBinaryFilterConditionSchema = z
29+
.object({
30+
field: NonEmptyString,
31+
eq: stringOrNumberOrBoolean.optional(),
32+
neq: stringOrNumberOrBoolean.optional(),
33+
lt: stringOrNumberOrBoolean.optional(),
34+
lte: stringOrNumberOrBoolean.optional(),
35+
gt: stringOrNumberOrBoolean.optional(),
36+
gte: stringOrNumberOrBoolean.optional(),
37+
contains: stringOrNumberOrBoolean.optional(),
38+
startsWith: stringOrNumberOrBoolean.optional(),
39+
endsWith: stringOrNumberOrBoolean.optional(),
40+
})
41+
.refine(
42+
(obj) =>
43+
// At least one operator must be present
44+
Object.keys(obj).some((key) =>
45+
['eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'contains', 'startsWith', 'endsWith'].includes(key)
46+
),
47+
{ message: 'At least one operator must be specified' }
48+
);
49+
50+
export interface ShorthandUnaryFilterCondition {
51+
field: string;
52+
exists?: true;
53+
notExists?: true;
54+
}
55+
56+
// Shorthand unary: field + exists or notExists
57+
export const shorthandUnaryFilterConditionSchema = z
58+
.object({
59+
field: NonEmptyString,
60+
exists: z.literal(true).optional(),
61+
notExists: z.literal(true).optional(),
62+
})
63+
.refine((obj) => obj.exists === true || obj.notExists === true, {
64+
message: 'Must specify exists: true or notExists: true',
65+
});
66+
67+
export type FilterCondition = ShorthandBinaryFilterCondition | ShorthandUnaryFilterCondition;
68+
69+
export const filterConditionSchema = z.union([
70+
shorthandBinaryFilterConditionSchema,
71+
shorthandUnaryFilterConditionSchema,
72+
]);
73+
74+
export interface AndCondition {
75+
and: Condition[];
76+
}
77+
78+
export interface OrCondition {
79+
or: Condition[];
80+
}
81+
82+
export interface AlwaysCondition {
83+
always: {};
84+
}
85+
86+
export interface NeverCondition {
87+
never: {};
88+
}
89+
90+
export type Condition =
91+
| FilterCondition
92+
| AndCondition
93+
| OrCondition
94+
| NeverCondition
95+
| AlwaysCondition;
96+
97+
export const conditionSchema: z.Schema<Condition> = z.lazy(() =>
98+
z.union([
99+
filterConditionSchema,
100+
andConditionSchema,
101+
orConditionSchema,
102+
neverConditionSchema,
103+
alwaysConditionSchema,
104+
])
105+
);
106+
107+
export const andConditionSchema = z.object({ and: z.array(conditionSchema) });
108+
export const orConditionSchema = z.object({ or: z.array(conditionSchema) });
109+
export const neverConditionSchema = z.object({ never: z.strictObject({}) });
110+
export const alwaysConditionSchema = z.object({ always: z.strictObject({}) });
111+
112+
export const isBinaryFilterCondition = createIsNarrowSchema(
113+
conditionSchema,
114+
shorthandBinaryFilterConditionSchema
115+
);
116+
export const isUnaryFilterCondition = createIsNarrowSchema(
117+
conditionSchema,
118+
shorthandUnaryFilterConditionSchema
119+
);
120+
export const isFilterCondition = createIsNarrowSchema(conditionSchema, filterConditionSchema);
121+
122+
export const isAndCondition = createIsNarrowSchema(conditionSchema, andConditionSchema);
123+
export const isOrCondition = createIsNarrowSchema(conditionSchema, orConditionSchema);
124+
export const isNeverCondition = createIsNarrowSchema(conditionSchema, neverConditionSchema);
125+
export const isAlwaysCondition = createIsNarrowSchema(conditionSchema, alwaysConditionSchema);
126+
127+
export const isCondition = createIsNarrowSchema(z.unknown(), conditionSchema);

0 commit comments

Comments
 (0)