@krak-stack/registry 0.1.56 → 0.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/components/ui/data-table.d.ts +85 -2
- package/dist/components/ui/data-table.js +1385 -608
- package/dist/lib/query.d.ts +216 -0
- package/dist/lib/query.js +50 -2
- package/dist/services/events/browser.js +46 -1
- package/dist/services/events/client/audit-log-table.js +1399 -626
- package/dist/services/events/index.d.ts +48 -0
- package/dist/services/events/index.js +54 -9
- package/dist/services/events/schema.d.ts +189 -0
- package/dist/services/events/schema.js +46 -1
- package/package.json +1 -1
|
@@ -79,6 +79,30 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
79
79
|
readonly id: string;
|
|
80
80
|
readonly direction: "asc" | "desc";
|
|
81
81
|
}[] | undefined;
|
|
82
|
+
readonly filters?: readonly ({
|
|
83
|
+
readonly id: string;
|
|
84
|
+
readonly kind: "number";
|
|
85
|
+
readonly min?: number | undefined;
|
|
86
|
+
readonly max?: number | undefined;
|
|
87
|
+
} | {
|
|
88
|
+
readonly id: string;
|
|
89
|
+
readonly kind: "date";
|
|
90
|
+
readonly from?: string | undefined;
|
|
91
|
+
readonly to?: string | undefined;
|
|
92
|
+
} | {
|
|
93
|
+
readonly id: string;
|
|
94
|
+
readonly kind: "text";
|
|
95
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
96
|
+
readonly value: string;
|
|
97
|
+
} | {
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly kind: "boolean";
|
|
100
|
+
readonly value: boolean;
|
|
101
|
+
} | {
|
|
102
|
+
readonly id: string;
|
|
103
|
+
readonly kind: "values";
|
|
104
|
+
readonly values: readonly [string, ...string[]];
|
|
105
|
+
})[] | undefined;
|
|
82
106
|
readonly eventName?: string | undefined;
|
|
83
107
|
readonly organizationId: string;
|
|
84
108
|
readonly category: "analytics" | "audit";
|
|
@@ -169,6 +193,30 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
169
193
|
readonly id: string;
|
|
170
194
|
readonly direction: "asc" | "desc";
|
|
171
195
|
}[] | undefined;
|
|
196
|
+
readonly filters?: readonly ({
|
|
197
|
+
readonly id: string;
|
|
198
|
+
readonly kind: "number";
|
|
199
|
+
readonly min?: number | undefined;
|
|
200
|
+
readonly max?: number | undefined;
|
|
201
|
+
} | {
|
|
202
|
+
readonly id: string;
|
|
203
|
+
readonly kind: "date";
|
|
204
|
+
readonly from?: string | undefined;
|
|
205
|
+
readonly to?: string | undefined;
|
|
206
|
+
} | {
|
|
207
|
+
readonly id: string;
|
|
208
|
+
readonly kind: "text";
|
|
209
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
210
|
+
readonly value: string;
|
|
211
|
+
} | {
|
|
212
|
+
readonly id: string;
|
|
213
|
+
readonly kind: "boolean";
|
|
214
|
+
readonly value: boolean;
|
|
215
|
+
} | {
|
|
216
|
+
readonly id: string;
|
|
217
|
+
readonly kind: "values";
|
|
218
|
+
readonly values: readonly [string, ...string[]];
|
|
219
|
+
})[] | undefined;
|
|
172
220
|
readonly eventName?: string | undefined;
|
|
173
221
|
readonly organizationId: string;
|
|
174
222
|
readonly category: "analytics" | "audit";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Config as Config2,
|
|
4
4
|
Context as Context4,
|
|
5
|
-
DateTime as
|
|
5
|
+
DateTime as DateTime3,
|
|
6
6
|
Effect as Effect8,
|
|
7
7
|
Layer as Layer3,
|
|
8
8
|
Option as Option6,
|
|
@@ -219,6 +219,7 @@ import { Effect as Effect5, Option as Option3, Schema as Schema6 } from "effect"
|
|
|
219
219
|
|
|
220
220
|
// ../../src/lib/query.ts
|
|
221
221
|
import {
|
|
222
|
+
DateTime as DateTime2,
|
|
222
223
|
Effect as Effect4,
|
|
223
224
|
Option as Option2,
|
|
224
225
|
Schema as Schema5,
|
|
@@ -299,6 +300,49 @@ var SortParams = Schema5.declare(Schema5.is(SortParamsArray), {
|
|
|
299
300
|
toCodec: () => Schema5.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
300
301
|
toCodecStringTree: () => Schema5.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
301
302
|
});
|
|
303
|
+
var TextFilterOperator = Schema5.Literals([
|
|
304
|
+
"contains",
|
|
305
|
+
"equals",
|
|
306
|
+
"startsWith",
|
|
307
|
+
"endsWith"
|
|
308
|
+
]).annotate({ identifier: "TextFilterOperator" });
|
|
309
|
+
var FilterCalendarDate = Schema5.String.check(Schema5.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema5.makeFilter((value) => Option2.exists(DateTime2.make(value), (date) => DateTime2.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
|
|
310
|
+
var ColumnFilter = Schema5.Union([
|
|
311
|
+
Schema5.Struct({
|
|
312
|
+
id: Schema5.NonEmptyString,
|
|
313
|
+
kind: Schema5.Literal("text"),
|
|
314
|
+
operator: TextFilterOperator,
|
|
315
|
+
value: Schema5.NonEmptyString
|
|
316
|
+
}),
|
|
317
|
+
Schema5.Struct({
|
|
318
|
+
id: Schema5.NonEmptyString,
|
|
319
|
+
kind: Schema5.Literal("number"),
|
|
320
|
+
min: Schema5.optional(Schema5.Finite),
|
|
321
|
+
max: Schema5.optional(Schema5.Finite)
|
|
322
|
+
}).check(Schema5.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
323
|
+
Schema5.Struct({
|
|
324
|
+
id: Schema5.NonEmptyString,
|
|
325
|
+
kind: Schema5.Literal("date"),
|
|
326
|
+
from: Schema5.optional(FilterCalendarDate),
|
|
327
|
+
to: Schema5.optional(FilterCalendarDate)
|
|
328
|
+
}).check(Schema5.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
329
|
+
Schema5.Struct({
|
|
330
|
+
id: Schema5.NonEmptyString,
|
|
331
|
+
kind: Schema5.Literal("boolean"),
|
|
332
|
+
value: Schema5.Boolean
|
|
333
|
+
}),
|
|
334
|
+
Schema5.Struct({
|
|
335
|
+
id: Schema5.NonEmptyString,
|
|
336
|
+
kind: Schema5.Literal("values"),
|
|
337
|
+
values: Schema5.NonEmptyArray(Schema5.String)
|
|
338
|
+
})
|
|
339
|
+
]).annotate({ identifier: "ColumnFilter" });
|
|
340
|
+
var ColumnFiltersArray = Schema5.Array(ColumnFilter);
|
|
341
|
+
var ColumnFilters = Schema5.declare(Schema5.is(ColumnFiltersArray), {
|
|
342
|
+
identifier: "ColumnFilters",
|
|
343
|
+
toCodec: () => Schema5.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
344
|
+
toCodecStringTree: () => Schema5.link()(Schema5.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
345
|
+
});
|
|
302
346
|
var Query = Schema5.Struct({
|
|
303
347
|
page: Schema5.optional(Schema5.Union([Schema5.Number, Schema5.NumberFromString]).check(Schema5.isInt(), Schema5.isGreaterThanOrEqualTo(0))).pipe(Schema5.decodeTo(Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(0)), {
|
|
304
348
|
decode: SchemaGetter.withDefault(Effect4.succeed(0)),
|
|
@@ -309,7 +353,8 @@ var Query = Schema5.Struct({
|
|
|
309
353
|
encode: SchemaGetter.transformOptional(Option2.filter((pageSize) => pageSize !== 20))
|
|
310
354
|
})),
|
|
311
355
|
globalFilter: Schema5.optional(Schema5.String),
|
|
312
|
-
sort: Schema5.optional(SortParams)
|
|
356
|
+
sort: Schema5.optional(SortParams),
|
|
357
|
+
filters: Schema5.optional(ColumnFilters)
|
|
313
358
|
}).annotate({
|
|
314
359
|
identifier: "Query",
|
|
315
360
|
title: "Query",
|
|
@@ -776,13 +821,13 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
776
821
|
secret: options.secret,
|
|
777
822
|
ip: location2.ip,
|
|
778
823
|
userAgent,
|
|
779
|
-
day:
|
|
824
|
+
day: DateTime3.formatIsoDate(now)
|
|
780
825
|
}) : undefined;
|
|
781
826
|
let sessionId;
|
|
782
827
|
if (visitorId && storage) {
|
|
783
828
|
yield* storage.lockVisitor(visitorId);
|
|
784
829
|
const latest = yield* storage.latestSession({ visitorId });
|
|
785
|
-
sessionId = Option6.isSome(latest) && latest.value.received_at >
|
|
830
|
+
sessionId = Option6.isSome(latest) && latest.value.received_at > DateTime3.toEpochMillis(now) - SESSION_TIMEOUT_MS ? latest.value.session_id : yield* random.uuidV7();
|
|
786
831
|
}
|
|
787
832
|
const identity = {};
|
|
788
833
|
if (visitorId)
|
|
@@ -800,8 +845,8 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
800
845
|
const event = yield* Schema9.decodeUnknownEffect(TrackEvent)(input);
|
|
801
846
|
const eventId = event.eventId ?? (yield* random.uuidV7());
|
|
802
847
|
const category = event.category ?? "analytics";
|
|
803
|
-
const receivedAt = yield*
|
|
804
|
-
const now =
|
|
848
|
+
const receivedAt = yield* DateTime3.now;
|
|
849
|
+
const now = DateTime3.toEpochMillis(receivedAt);
|
|
805
850
|
const request = yield* Effect8.serviceOption(HttpServerRequest.HttpServerRequest);
|
|
806
851
|
const annotations = yield* References2.CurrentLogAnnotations;
|
|
807
852
|
if (category === "analytics" && options.requireConsent && (Option6.isNone(request) || !hasAnalyticsConsent(request.value.headers.cookie ?? "", request.value.headers))) {
|
|
@@ -841,7 +886,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
841
886
|
const location2 = Option6.isSome(request) && (!options.requireConsent || hasAnalyticsConsent(request.value.headers.cookie ?? "", request.value.headers)) ? yield* resolveGeolocation(request.value).pipe(Effect8.mapError(() => new EventsPersistenceError({ operation: "geolocation" }))) : null;
|
|
842
887
|
const entry = {
|
|
843
888
|
eventName: event.name,
|
|
844
|
-
timeUnixNano: (BigInt(event.timestamp ?
|
|
889
|
+
timeUnixNano: (BigInt(event.timestamp ? DateTime3.toEpochMillis(event.timestamp) : now) * 1000000n).toString(),
|
|
845
890
|
observedTimeUnixNano: (BigInt(now) * 1000000n).toString()
|
|
846
891
|
};
|
|
847
892
|
return yield* Effect8.gen(function* () {
|
|
@@ -990,8 +1035,8 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
990
1035
|
}
|
|
991
1036
|
const rawRecords = analyticsScopes.flatMap((scope) => scope.logRecords);
|
|
992
1037
|
const records = yield* Schema9.decodeUnknownEffect(Schema9.Array(EventLogRecord).check(Schema9.isMinLength(1), Schema9.isMaxLength(100)))(rawRecords).pipe(Effect8.mapError(() => new OtlpProcessingError({ status: 400 })));
|
|
993
|
-
const now = yield*
|
|
994
|
-
const nowMillis =
|
|
1038
|
+
const now = yield* DateTime3.now;
|
|
1039
|
+
const nowMillis = DateTime3.toEpochMillis(now);
|
|
995
1040
|
for (const record of records) {
|
|
996
1041
|
const timestamp = BigInt(record.timeUnixNano) / 1000000n;
|
|
997
1042
|
if (timestamp < BigInt(nowMillis - 60 * 60 * 1000) || timestamp > BigInt(nowMillis + 60000) || textAttribute(record, "app.event.schema.version") !== "1" || Option6.isNone(Schema9.decodeUnknownOption(EventUuid)(textAttribute(record, "analytics.page_view.id"))) || Option6.isNone(Schema9.decodeUnknownOption(EventId)(textAttribute(record, "log.record.uid"))) || Option6.isNone(Schema9.decodeUnknownOption(BrowserEventPath)(textAttribute(record, "url.path")))) {
|
|
@@ -83,6 +83,53 @@ export declare const EventQuery: Schema.Struct<{
|
|
|
83
83
|
readonly id: string;
|
|
84
84
|
readonly direction: "asc" | "desc";
|
|
85
85
|
}[]>>;
|
|
86
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly kind: "number";
|
|
89
|
+
readonly min?: number | undefined;
|
|
90
|
+
readonly max?: number | undefined;
|
|
91
|
+
} | {
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly kind: "date";
|
|
94
|
+
readonly from?: string | undefined;
|
|
95
|
+
readonly to?: string | undefined;
|
|
96
|
+
} | {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly kind: "text";
|
|
99
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
100
|
+
readonly value: string;
|
|
101
|
+
} | {
|
|
102
|
+
readonly id: string;
|
|
103
|
+
readonly kind: "boolean";
|
|
104
|
+
readonly value: boolean;
|
|
105
|
+
} | {
|
|
106
|
+
readonly id: string;
|
|
107
|
+
readonly kind: "values";
|
|
108
|
+
readonly values: readonly [string, ...string[]];
|
|
109
|
+
})[], readonly ({
|
|
110
|
+
readonly id: string;
|
|
111
|
+
readonly kind: "number";
|
|
112
|
+
readonly min?: number | undefined;
|
|
113
|
+
readonly max?: number | undefined;
|
|
114
|
+
} | {
|
|
115
|
+
readonly id: string;
|
|
116
|
+
readonly kind: "date";
|
|
117
|
+
readonly from?: string | undefined;
|
|
118
|
+
readonly to?: string | undefined;
|
|
119
|
+
} | {
|
|
120
|
+
readonly id: string;
|
|
121
|
+
readonly kind: "text";
|
|
122
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
123
|
+
readonly value: string;
|
|
124
|
+
} | {
|
|
125
|
+
readonly id: string;
|
|
126
|
+
readonly kind: "boolean";
|
|
127
|
+
readonly value: boolean;
|
|
128
|
+
} | {
|
|
129
|
+
readonly id: string;
|
|
130
|
+
readonly kind: "values";
|
|
131
|
+
readonly values: readonly [string, ...string[]];
|
|
132
|
+
})[]>>;
|
|
86
133
|
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
87
134
|
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
88
135
|
}>;
|
|
@@ -95,6 +142,30 @@ export declare const EventQueryStandard: import("effect/StandardSchema").Standar
|
|
|
95
142
|
readonly id: string;
|
|
96
143
|
readonly direction: "asc" | "desc";
|
|
97
144
|
}[] | undefined;
|
|
145
|
+
readonly filters?: readonly ({
|
|
146
|
+
readonly id: string;
|
|
147
|
+
readonly kind: "number";
|
|
148
|
+
readonly min?: number | undefined;
|
|
149
|
+
readonly max?: number | undefined;
|
|
150
|
+
} | {
|
|
151
|
+
readonly id: string;
|
|
152
|
+
readonly kind: "date";
|
|
153
|
+
readonly from?: string | undefined;
|
|
154
|
+
readonly to?: string | undefined;
|
|
155
|
+
} | {
|
|
156
|
+
readonly id: string;
|
|
157
|
+
readonly kind: "text";
|
|
158
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
159
|
+
readonly value: string;
|
|
160
|
+
} | {
|
|
161
|
+
readonly id: string;
|
|
162
|
+
readonly kind: "boolean";
|
|
163
|
+
readonly value: boolean;
|
|
164
|
+
} | {
|
|
165
|
+
readonly id: string;
|
|
166
|
+
readonly kind: "values";
|
|
167
|
+
readonly values: readonly [string, ...string[]];
|
|
168
|
+
})[] | undefined;
|
|
98
169
|
readonly eventName?: string | undefined;
|
|
99
170
|
}, {
|
|
100
171
|
readonly page: number;
|
|
@@ -104,6 +175,30 @@ export declare const EventQueryStandard: import("effect/StandardSchema").Standar
|
|
|
104
175
|
readonly id: string;
|
|
105
176
|
readonly direction: "asc" | "desc";
|
|
106
177
|
}[] | undefined;
|
|
178
|
+
readonly filters?: readonly ({
|
|
179
|
+
readonly id: string;
|
|
180
|
+
readonly kind: "number";
|
|
181
|
+
readonly min?: number | undefined;
|
|
182
|
+
readonly max?: number | undefined;
|
|
183
|
+
} | {
|
|
184
|
+
readonly id: string;
|
|
185
|
+
readonly kind: "date";
|
|
186
|
+
readonly from?: string | undefined;
|
|
187
|
+
readonly to?: string | undefined;
|
|
188
|
+
} | {
|
|
189
|
+
readonly id: string;
|
|
190
|
+
readonly kind: "text";
|
|
191
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
192
|
+
readonly value: string;
|
|
193
|
+
} | {
|
|
194
|
+
readonly id: string;
|
|
195
|
+
readonly kind: "boolean";
|
|
196
|
+
readonly value: boolean;
|
|
197
|
+
} | {
|
|
198
|
+
readonly id: string;
|
|
199
|
+
readonly kind: "values";
|
|
200
|
+
readonly values: readonly [string, ...string[]];
|
|
201
|
+
})[] | undefined;
|
|
107
202
|
readonly eventName?: string | undefined;
|
|
108
203
|
}> & Schema.Struct<{
|
|
109
204
|
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
@@ -116,6 +211,53 @@ export declare const EventQueryStandard: import("effect/StandardSchema").Standar
|
|
|
116
211
|
readonly id: string;
|
|
117
212
|
readonly direction: "asc" | "desc";
|
|
118
213
|
}[]>>;
|
|
214
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
215
|
+
readonly id: string;
|
|
216
|
+
readonly kind: "number";
|
|
217
|
+
readonly min?: number | undefined;
|
|
218
|
+
readonly max?: number | undefined;
|
|
219
|
+
} | {
|
|
220
|
+
readonly id: string;
|
|
221
|
+
readonly kind: "date";
|
|
222
|
+
readonly from?: string | undefined;
|
|
223
|
+
readonly to?: string | undefined;
|
|
224
|
+
} | {
|
|
225
|
+
readonly id: string;
|
|
226
|
+
readonly kind: "text";
|
|
227
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
228
|
+
readonly value: string;
|
|
229
|
+
} | {
|
|
230
|
+
readonly id: string;
|
|
231
|
+
readonly kind: "boolean";
|
|
232
|
+
readonly value: boolean;
|
|
233
|
+
} | {
|
|
234
|
+
readonly id: string;
|
|
235
|
+
readonly kind: "values";
|
|
236
|
+
readonly values: readonly [string, ...string[]];
|
|
237
|
+
})[], readonly ({
|
|
238
|
+
readonly id: string;
|
|
239
|
+
readonly kind: "number";
|
|
240
|
+
readonly min?: number | undefined;
|
|
241
|
+
readonly max?: number | undefined;
|
|
242
|
+
} | {
|
|
243
|
+
readonly id: string;
|
|
244
|
+
readonly kind: "date";
|
|
245
|
+
readonly from?: string | undefined;
|
|
246
|
+
readonly to?: string | undefined;
|
|
247
|
+
} | {
|
|
248
|
+
readonly id: string;
|
|
249
|
+
readonly kind: "text";
|
|
250
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
251
|
+
readonly value: string;
|
|
252
|
+
} | {
|
|
253
|
+
readonly id: string;
|
|
254
|
+
readonly kind: "boolean";
|
|
255
|
+
readonly value: boolean;
|
|
256
|
+
} | {
|
|
257
|
+
readonly id: string;
|
|
258
|
+
readonly kind: "values";
|
|
259
|
+
readonly values: readonly [string, ...string[]];
|
|
260
|
+
})[]>>;
|
|
119
261
|
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
120
262
|
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
121
263
|
}>;
|
|
@@ -130,6 +272,53 @@ export declare const ListEvents: Schema.Struct<{
|
|
|
130
272
|
readonly id: string;
|
|
131
273
|
readonly direction: "asc" | "desc";
|
|
132
274
|
}[]>>;
|
|
275
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
276
|
+
readonly id: string;
|
|
277
|
+
readonly kind: "number";
|
|
278
|
+
readonly min?: number | undefined;
|
|
279
|
+
readonly max?: number | undefined;
|
|
280
|
+
} | {
|
|
281
|
+
readonly id: string;
|
|
282
|
+
readonly kind: "date";
|
|
283
|
+
readonly from?: string | undefined;
|
|
284
|
+
readonly to?: string | undefined;
|
|
285
|
+
} | {
|
|
286
|
+
readonly id: string;
|
|
287
|
+
readonly kind: "text";
|
|
288
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
289
|
+
readonly value: string;
|
|
290
|
+
} | {
|
|
291
|
+
readonly id: string;
|
|
292
|
+
readonly kind: "boolean";
|
|
293
|
+
readonly value: boolean;
|
|
294
|
+
} | {
|
|
295
|
+
readonly id: string;
|
|
296
|
+
readonly kind: "values";
|
|
297
|
+
readonly values: readonly [string, ...string[]];
|
|
298
|
+
})[], readonly ({
|
|
299
|
+
readonly id: string;
|
|
300
|
+
readonly kind: "number";
|
|
301
|
+
readonly min?: number | undefined;
|
|
302
|
+
readonly max?: number | undefined;
|
|
303
|
+
} | {
|
|
304
|
+
readonly id: string;
|
|
305
|
+
readonly kind: "date";
|
|
306
|
+
readonly from?: string | undefined;
|
|
307
|
+
readonly to?: string | undefined;
|
|
308
|
+
} | {
|
|
309
|
+
readonly id: string;
|
|
310
|
+
readonly kind: "text";
|
|
311
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
312
|
+
readonly value: string;
|
|
313
|
+
} | {
|
|
314
|
+
readonly id: string;
|
|
315
|
+
readonly kind: "boolean";
|
|
316
|
+
readonly value: boolean;
|
|
317
|
+
} | {
|
|
318
|
+
readonly id: string;
|
|
319
|
+
readonly kind: "values";
|
|
320
|
+
readonly values: readonly [string, ...string[]];
|
|
321
|
+
})[]>>;
|
|
133
322
|
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
134
323
|
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
135
324
|
readonly organizationId: Schema.NonEmptyString;
|
|
@@ -53,6 +53,7 @@ var TelemetryEvent = Schema.Struct({
|
|
|
53
53
|
|
|
54
54
|
// ../../src/lib/query.ts
|
|
55
55
|
import {
|
|
56
|
+
DateTime,
|
|
56
57
|
Effect,
|
|
57
58
|
Option,
|
|
58
59
|
Schema as Schema2,
|
|
@@ -133,6 +134,49 @@ var SortParams = Schema2.declare(Schema2.is(SortParamsArray), {
|
|
|
133
134
|
toCodec: () => Schema2.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
134
135
|
toCodecStringTree: () => Schema2.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
135
136
|
});
|
|
137
|
+
var TextFilterOperator = Schema2.Literals([
|
|
138
|
+
"contains",
|
|
139
|
+
"equals",
|
|
140
|
+
"startsWith",
|
|
141
|
+
"endsWith"
|
|
142
|
+
]).annotate({ identifier: "TextFilterOperator" });
|
|
143
|
+
var FilterCalendarDate = Schema2.String.check(Schema2.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema2.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
|
|
144
|
+
var ColumnFilter = Schema2.Union([
|
|
145
|
+
Schema2.Struct({
|
|
146
|
+
id: Schema2.NonEmptyString,
|
|
147
|
+
kind: Schema2.Literal("text"),
|
|
148
|
+
operator: TextFilterOperator,
|
|
149
|
+
value: Schema2.NonEmptyString
|
|
150
|
+
}),
|
|
151
|
+
Schema2.Struct({
|
|
152
|
+
id: Schema2.NonEmptyString,
|
|
153
|
+
kind: Schema2.Literal("number"),
|
|
154
|
+
min: Schema2.optional(Schema2.Finite),
|
|
155
|
+
max: Schema2.optional(Schema2.Finite)
|
|
156
|
+
}).check(Schema2.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
157
|
+
Schema2.Struct({
|
|
158
|
+
id: Schema2.NonEmptyString,
|
|
159
|
+
kind: Schema2.Literal("date"),
|
|
160
|
+
from: Schema2.optional(FilterCalendarDate),
|
|
161
|
+
to: Schema2.optional(FilterCalendarDate)
|
|
162
|
+
}).check(Schema2.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
163
|
+
Schema2.Struct({
|
|
164
|
+
id: Schema2.NonEmptyString,
|
|
165
|
+
kind: Schema2.Literal("boolean"),
|
|
166
|
+
value: Schema2.Boolean
|
|
167
|
+
}),
|
|
168
|
+
Schema2.Struct({
|
|
169
|
+
id: Schema2.NonEmptyString,
|
|
170
|
+
kind: Schema2.Literal("values"),
|
|
171
|
+
values: Schema2.NonEmptyArray(Schema2.String)
|
|
172
|
+
})
|
|
173
|
+
]).annotate({ identifier: "ColumnFilter" });
|
|
174
|
+
var ColumnFiltersArray = Schema2.Array(ColumnFilter);
|
|
175
|
+
var ColumnFilters = Schema2.declare(Schema2.is(ColumnFiltersArray), {
|
|
176
|
+
identifier: "ColumnFilters",
|
|
177
|
+
toCodec: () => Schema2.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
178
|
+
toCodecStringTree: () => Schema2.link()(Schema2.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
179
|
+
});
|
|
136
180
|
var Query = Schema2.Struct({
|
|
137
181
|
page: Schema2.optional(Schema2.Union([Schema2.Number, Schema2.NumberFromString]).check(Schema2.isInt(), Schema2.isGreaterThanOrEqualTo(0))).pipe(Schema2.decodeTo(Schema2.Int.check(Schema2.isGreaterThanOrEqualTo(0)), {
|
|
138
182
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
@@ -143,7 +187,8 @@ var Query = Schema2.Struct({
|
|
|
143
187
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
|
|
144
188
|
})),
|
|
145
189
|
globalFilter: Schema2.optional(Schema2.String),
|
|
146
|
-
sort: Schema2.optional(SortParams)
|
|
190
|
+
sort: Schema2.optional(SortParams),
|
|
191
|
+
filters: Schema2.optional(ColumnFilters)
|
|
147
192
|
}).annotate({
|
|
148
193
|
identifier: "Query",
|
|
149
194
|
title: "Query",
|