@krak-stack/registry 0.1.55 → 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.
@@ -148,6 +148,7 @@ function DialogDescription({
148
148
  }
149
149
 
150
150
  // ../../src/services/opentelemetry/consent.ts
151
+ import { SecureRandom } from "effect/crypto";
151
152
  import { Effect, Option, Schema as Schema2 } from "effect";
152
153
 
153
154
  // ../../src/services/opentelemetry/schema.ts
@@ -247,7 +248,7 @@ var saveAnalyticsPreference = (choice) => {
247
248
  const issuedAt = Date.now();
248
249
  const value = Schema2.encodeSync(codec)({
249
250
  choice,
250
- revision: crypto.randomUUID(),
251
+ revision: Effect.runSync(SecureRandom.SecureRandom.use((random) => random.uuidV7()).pipe(Effect.provide(SecureRandom.layerWebCrypto))),
251
252
  version: ANALYTICS_NOTICE_VERSION,
252
253
  issuedAt,
253
254
  expiresAt: issuedAt + lifetime
@@ -1,4 +1,4 @@
1
- import { Config, Context, Crypto, DateTime, Effect, Layer, Redacted, Schema } from "effect";
1
+ import { Config, Context, DateTime, Effect, Layer, Redacted, Schema } from "effect";
2
2
  import { HttpServerRequest } from "effect/http";
3
3
  import { OtlpLogsProcessor, OtlpProcessingError } from "../opentelemetry/processor.js";
4
4
  import { Otlp } from "../opentelemetry/index.js";
@@ -32,7 +32,7 @@ export declare const dailyVisitorId: (input: {
32
32
  readonly userAgent: string;
33
33
  readonly day: string;
34
34
  readonly secret: Redacted.Redacted<string>;
35
- }) => Effect.Effect<string, import("effect/PlatformError").PlatformError, Crypto.Crypto>;
35
+ }) => Effect.Effect<string, never, never>;
36
36
  declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events", {
37
37
  process: (body: Uint8Array<ArrayBufferLike>) => Effect.Effect<{
38
38
  body: Uint8Array<ArrayBufferLike>;
@@ -70,7 +70,7 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
70
70
  }) => Effect.Effect<{
71
71
  eventId: string;
72
72
  inserted: boolean;
73
- }, EventConflictError | EventsPersistenceError | import("effect/PlatformError").PlatformError | Schema.SchemaError, never>;
73
+ }, EventConflictError | EventsPersistenceError | Schema.SchemaError, never>;
74
74
  list: (input: {
75
75
  readonly page?: string | number | undefined;
76
76
  readonly pageSize?: string | number | undefined;
@@ -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";
@@ -160,7 +184,7 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
160
184
  }) => Effect.Effect<{
161
185
  eventId: string;
162
186
  inserted: boolean;
163
- }, EventConflictError | EventsPersistenceError | import("effect/PlatformError").PlatformError | Schema.SchemaError, never>;
187
+ }, EventConflictError | EventsPersistenceError | Schema.SchemaError, never>;
164
188
  list: (input: {
165
189
  readonly page?: string | number | undefined;
166
190
  readonly pageSize?: string | number | undefined;
@@ -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";
@@ -212,14 +260,14 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
212
260
  pageCount: number;
213
261
  };
214
262
  }, EventsPersistenceError | import("effect/Cause").NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
215
- }, EventsConfigurationError, Crypto.Crypto | Otlp | OtlpEvents>;
263
+ }, EventsConfigurationError, Otlp | OtlpEvents>;
216
264
  };
217
265
  export declare class Events extends Events_base {
218
266
  /** Missing options resolve from APP_SECRET, VITE_SITE_URL and Otlp. */
219
- static readonly baseLayerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError, Crypto.Crypto | Otlp | OtlpEvents>;
220
- static readonly baseLayer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError, Crypto.Crypto | Otlp | OtlpEvents>;
267
+ static readonly baseLayerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError, Otlp | OtlpEvents>;
268
+ static readonly baseLayer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError, Otlp | OtlpEvents>;
221
269
  /** An injected PostgreSQL/SQLite SqlClient enables persistence and the initial migration. */
222
- static readonly layerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Crypto.Crypto | Otlp | OtlpEvents>;
223
- static readonly layer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Crypto.Crypto | Otlp | OtlpEvents>;
270
+ static readonly layerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Otlp | OtlpEvents>;
271
+ static readonly layer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Otlp | OtlpEvents>;
224
272
  static readonly ingestionLayer: Layer.Layer<OtlpLogsProcessor, never, Events>;
225
273
  }
@@ -2,8 +2,7 @@
2
2
  import {
3
3
  Config as Config2,
4
4
  Context as Context4,
5
- Crypto,
6
- DateTime as DateTime2,
5
+ DateTime as DateTime3,
7
6
  Effect as Effect8,
8
7
  Layer as Layer3,
9
8
  Option as Option6,
@@ -12,6 +11,7 @@ import {
12
11
  References as References2,
13
12
  Schema as Schema9
14
13
  } from "effect";
14
+ import { Digest, SecureRandom as SecureRandom2 } from "effect/crypto";
15
15
  import { HttpServerRequest } from "effect/http";
16
16
  import { SqlClient as SqlClient2, SqlSchema } from "effect/sql";
17
17
  import { Hex } from "effect/encoding";
@@ -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",
@@ -576,6 +621,7 @@ var migrateEvents = Migrator.make({})({
576
621
  });
577
622
 
578
623
  // ../../src/services/opentelemetry/consent.ts
624
+ import { SecureRandom } from "effect/crypto";
579
625
  import { Effect as Effect7, Option as Option5, Schema as Schema8 } from "effect";
580
626
  var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
581
627
  var ANALYTICS_NOTICE_VERSION = "1";
@@ -656,15 +702,15 @@ var eventContent = (record, source, compareTimestamp = source === "browser") =>
656
702
  ].includes(key) || key === "user.id" || key === "organization.id").sort((a, b) => a.key.localeCompare(b.key))
657
703
  });
658
704
  var dailyVisitorId = Effect8.fnUntraced(function* (input) {
659
- const crypto2 = yield* Crypto.Crypto;
705
+ const digestService = yield* Digest.Digest.pipe(Effect8.provide(Digest.layerWebCrypto));
660
706
  const encoder = new TextEncoder;
661
- const salt = yield* crypto2.digest("SHA-256", encoder.encode(JSON.stringify([
707
+ const salt = yield* digestService.digest(Digest.sha256, encoder.encode(JSON.stringify([
662
708
  "analytics.visitor.salt.v2",
663
709
  Redacted.value(input.secret),
664
710
  input.serviceName,
665
711
  input.day
666
712
  ])));
667
- const digest = yield* crypto2.digest("SHA-256", encoder.encode(JSON.stringify([
713
+ const digest = yield* digestService.digest(Digest.sha256, encoder.encode(JSON.stringify([
668
714
  "analytics.visitor.v2",
669
715
  input.serviceName,
670
716
  input.day,
@@ -677,7 +723,7 @@ var dailyVisitorId = Effect8.fnUntraced(function* (input) {
677
723
 
678
724
  class Events extends Context4.Service()("krakstack/events/Events", {
679
725
  make: (options) => Effect8.gen(function* () {
680
- const crypto2 = yield* Crypto.Crypto;
726
+ const random = yield* SecureRandom2.SecureRandom.pipe(Effect8.provide(SecureRandom2.layerWebCrypto));
681
727
  const telemetry = yield* Otlp;
682
728
  const exporter = yield* OtlpEvents;
683
729
  const resource = options.serviceName ? yield* OtlpResource3.fromConfig({ serviceName: options.serviceName }) : yield* telemetry.resource;
@@ -775,13 +821,13 @@ class Events extends Context4.Service()("krakstack/events/Events", {
775
821
  secret: options.secret,
776
822
  ip: location2.ip,
777
823
  userAgent,
778
- day: DateTime2.formatIsoDate(now)
779
- }).pipe(Effect8.provideService(Crypto.Crypto, crypto2)) : undefined;
824
+ day: DateTime3.formatIsoDate(now)
825
+ }) : undefined;
780
826
  let sessionId;
781
827
  if (visitorId && storage) {
782
828
  yield* storage.lockVisitor(visitorId);
783
829
  const latest = yield* storage.latestSession({ visitorId });
784
- sessionId = Option6.isSome(latest) && latest.value.received_at > DateTime2.toEpochMillis(now) - SESSION_TIMEOUT_MS ? latest.value.session_id : yield* crypto2.randomUUIDv7;
830
+ sessionId = Option6.isSome(latest) && latest.value.received_at > DateTime3.toEpochMillis(now) - SESSION_TIMEOUT_MS ? latest.value.session_id : yield* random.uuidV7();
785
831
  }
786
832
  const identity = {};
787
833
  if (visitorId)
@@ -797,10 +843,10 @@ class Events extends Context4.Service()("krakstack/events/Events", {
797
843
  });
798
844
  const track = Effect8.fn("Events.track")(function* (input) {
799
845
  const event = yield* Schema9.decodeUnknownEffect(TrackEvent)(input);
800
- const eventId = event.eventId ?? (yield* crypto2.randomUUIDv7);
846
+ const eventId = event.eventId ?? (yield* random.uuidV7());
801
847
  const category = event.category ?? "analytics";
802
- const receivedAt = yield* DateTime2.now;
803
- const now = DateTime2.toEpochMillis(receivedAt);
848
+ const receivedAt = yield* DateTime3.now;
849
+ const now = DateTime3.toEpochMillis(receivedAt);
804
850
  const request = yield* Effect8.serviceOption(HttpServerRequest.HttpServerRequest);
805
851
  const annotations = yield* References2.CurrentLogAnnotations;
806
852
  if (category === "analytics" && options.requireConsent && (Option6.isNone(request) || !hasAnalyticsConsent(request.value.headers.cookie ?? "", request.value.headers))) {
@@ -840,7 +886,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
840
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;
841
887
  const entry = {
842
888
  eventName: event.name,
843
- timeUnixNano: (BigInt(event.timestamp ? DateTime2.toEpochMillis(event.timestamp) : now) * 1000000n).toString(),
889
+ timeUnixNano: (BigInt(event.timestamp ? DateTime3.toEpochMillis(event.timestamp) : now) * 1000000n).toString(),
844
890
  observedTimeUnixNano: (BigInt(now) * 1000000n).toString()
845
891
  };
846
892
  return yield* Effect8.gen(function* () {
@@ -989,8 +1035,8 @@ class Events extends Context4.Service()("krakstack/events/Events", {
989
1035
  }
990
1036
  const rawRecords = analyticsScopes.flatMap((scope) => scope.logRecords);
991
1037
  const records = yield* Schema9.decodeUnknownEffect(Schema9.Array(EventLogRecord).check(Schema9.isMinLength(1), Schema9.isMaxLength(100)))(rawRecords).pipe(Effect8.mapError(() => new OtlpProcessingError({ status: 400 })));
992
- const now = yield* DateTime2.now;
993
- const nowMillis = DateTime2.toEpochMillis(now);
1038
+ const now = yield* DateTime3.now;
1039
+ const nowMillis = DateTime3.toEpochMillis(now);
994
1040
  for (const record of records) {
995
1041
  const timestamp = BigInt(record.timeUnixNano) / 1000000n;
996
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",
@@ -145,6 +145,7 @@ var event = Effect.fnUntraced(function* (name, properties, options) {
145
145
  });
146
146
 
147
147
  // ../../src/services/opentelemetry/consent.ts
148
+ import { SecureRandom } from "effect/crypto";
148
149
  import { Effect as Effect2, Option as Option2, Schema as Schema3 } from "effect";
149
150
  var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
150
151
  var ANALYTICS_NOTICE_VERSION = "1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/registry",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "Tree-shakable KrakStack components and Effect services.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -271,8 +271,8 @@
271
271
  "peerDependencies": {
272
272
  "@aws-sdk/client-sesv2": "^3.1068.0",
273
273
  "@base-ui/react": "^1.5.0",
274
- "@effect/atom-react": "^4.0.0",
275
- "@effect/platform-browser": "^4.0.0",
274
+ "@effect/atom-react": "^4.1.0",
275
+ "@effect/platform-browser": "^4.1.0",
276
276
  "@iconify/react": "^6.0.2",
277
277
  "@inlang/paraglide-js": "^2.19.0",
278
278
  "@lucas-barake/effect-form": "1.1.0",
@@ -286,7 +286,7 @@
286
286
  "cmdk": "^1.1.1",
287
287
  "cn": "^0.3.0",
288
288
  "drizzle-orm": "^1.0.0-rc.4-5d5b77c",
289
- "effect": "^4.0.0",
289
+ "effect": "^4.1.0",
290
290
  "lucide-react": "^1.18.0",
291
291
  "react": "^19.2.0",
292
292
  "react-dom": "^19.2.0"