@krak-stack/registry 0.1.51 → 0.1.53

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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @krak-stack/registry
2
2
 
3
+ ## 0.1.53
4
+
5
+ ### Patch Changes
6
+
7
+ - Use Effect Crypto for secret-salted SHA-256 visitor IDs and generated UUIDv7 event and visit IDs. Applications must provide a platform Crypto layer alongside Otlp. The versioned visitor derivation changes IDs from the previous HMAC algorithm.
8
+
9
+ Replace the Events layer factories with default `Events.layer` / `Events.baseLayer` values and partial `Events.layerWith(options)` / `Events.baseLayerWith(options)` overrides. Missing secret and origin options read server-only `APP_SECRET` and the origin of `VITE_SITE_URL`; explicit values skip their environment lookup. Geolocation remains opt-in. Migrate existing `Events.layer(options)` and `Events.baseLayer(options)` calls to their With counterparts.
10
+
11
+ ## 0.1.52
12
+
13
+ ### Patch Changes
14
+
15
+ - Replace AuditLogTable's profile resolver callbacks with an application-supplied `actors` list and export `AuditActor`. Match responsible actors by type and ID and resolve user impersonators from the same list. Use neutral labels for unavailable profiles so loading or partial member lists do not misidentify users as former members.
16
+ - Add `Events.listAudit` using the shared Query schema for organization-scoped pagination, filtering, and sorting. Return unchanged OTLP EventLogRecord values in the standard paginated response. Export a bilingual AuditLogTable from `events/client` with application-owned live member profiles, standard query state, and the shared KrakStack locale.
17
+
18
+ Include audit queries and the table in the Events registry item and documentation. Include the opt-in Browser Web Vitals layer and its documentation in the OpenTelemetry registry item, without changing package subpath imports.
19
+
20
+ Present audit history in five columns: Time, Action, Target, Actor, and Method. Separate the responsible user or organization from request authentication. Resolve current profiles in the application, while retaining key identities, historical roles, and target types in unchanged log records. Include localized labels and safe identity fallbacks.
21
+
22
+ Define principal attribution as `app.actor.type/id`, authentication as `app.auth.method` and API-key identity as `app.auth.credential.id`. Method displays User session, API Key, or Unknown from verified authentication only, without interpreting agent, channel, or user-agent metadata. Protect auth annotations from browser claims. Document the application vocabulary and its relationship to OTel and OCSF.
23
+
24
+ Retain the verified impersonator ID as `app.auth.impersonator.id` while keeping the effective user as Actor. Show localized impersonation attribution in the Actor cell, resolving profiles from the application-provided actors list and falling back to the retained ID when a profile is unavailable. Never infer membership status from a missing profile or change Method during impersonation.
25
+
26
+ - Add a `reference` table column and reusable `DataTableReferenceCell` for an image beside stacked primary/secondary text, such as a user's name and email. Include configurable circle/square images, initials/image-error fallbacks, and readable search, sorting, and exports without exposing image URLs.
27
+ - Require a typed `target: { id, name, type }` on audit events and generate an event UUID when `eventId` is omitted. Persist historical `user.roles`, but exclude user display names/photos from recorded events so applications can resolve current profiles by actor ID. Browser claims cannot override auth-owned attribution. Existing audit callers must supply a target; explicit IDs retain retry deduplication.
28
+
3
29
  ## 0.1.51
4
30
 
5
31
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { type ReactNode } from "react";
1
+ import { type ReactElement, type ReactNode } from "react";
2
2
  import { type PaginationMessages } from "./pagination.js";
3
3
  import type { QueryType } from "../../lib/query.js";
4
4
  type RowData = object;
@@ -19,6 +19,22 @@ export interface DataTableListItem {
19
19
  label: string;
20
20
  value?: string;
21
21
  }
22
+ export interface DataTableReferenceItem {
23
+ label: string;
24
+ /** Secondary text, such as a user's email or a record identifier. */
25
+ description?: string | null;
26
+ imageSrc?: string | null;
27
+ }
28
+ export interface DataTableReferenceOptions<TData> {
29
+ getItem: (row: TData) => DataTableReferenceItem | null | undefined;
30
+ emptyLabel?: ReactNode;
31
+ imageVariant?: "circle" | "square";
32
+ }
33
+ export declare const DataTableReferenceCell: ({ item, emptyLabel, imageVariant, }: {
34
+ item: DataTableReferenceItem | null | undefined;
35
+ emptyLabel?: ReactNode;
36
+ imageVariant?: "circle" | "square";
37
+ }) => string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null;
22
38
  export interface DataTableListOption extends DataTableListItem {
23
39
  value: string;
24
40
  }
@@ -147,6 +163,9 @@ type DataTableColumnType<TData> = {
147
163
  } | {
148
164
  type: "boolean";
149
165
  typeOptions?: DataTableBooleanOptions<TData>;
166
+ } | {
167
+ type: "reference";
168
+ typeOptions: DataTableReferenceOptions<TData>;
150
169
  } | {
151
170
  type: "list";
152
171
  typeOptions: DataTableListColumn<TData>;
@@ -983,6 +983,47 @@ var DataTablePersistedUiStateSchema = Schema.Struct({
983
983
  view: Schema.Literals(["table", "gallery"])
984
984
  }).annotate({ identifier: "DataTablePersistedUiState" });
985
985
  var dataTableStorageRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
986
+ var DataTableReferenceCell = ({
987
+ item,
988
+ emptyLabel = "—",
989
+ imageVariant = "circle"
990
+ }) => {
991
+ const [failedImage, setFailedImage] = useState();
992
+ if (!item)
993
+ return emptyLabel;
994
+ const initials = item.label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
995
+ return /* @__PURE__ */ jsxs8("div", {
996
+ className: "flex min-w-0 items-center gap-2",
997
+ children: [
998
+ /* @__PURE__ */ jsx14("div", {
999
+ className: cn("bg-muted flex size-8 shrink-0 items-center justify-center overflow-hidden text-xs font-medium", imageVariant === "circle" ? "rounded-full" : "rounded-md"),
1000
+ children: item.imageSrc && item.imageSrc !== failedImage ? /* @__PURE__ */ jsx14("img", {
1001
+ src: item.imageSrc,
1002
+ alt: item.label,
1003
+ className: "size-full object-cover",
1004
+ onError: () => setFailedImage(item.imageSrc ?? undefined)
1005
+ }) : /* @__PURE__ */ jsx14("span", {
1006
+ "aria-hidden": "true",
1007
+ children: initials
1008
+ })
1009
+ }),
1010
+ /* @__PURE__ */ jsxs8("div", {
1011
+ className: "flex min-w-0 flex-col leading-tight",
1012
+ children: [
1013
+ /* @__PURE__ */ jsx14("span", {
1014
+ className: "truncate font-medium",
1015
+ children: item.label
1016
+ }),
1017
+ item.description ? /* @__PURE__ */ jsx14("span", {
1018
+ className: "text-muted-foreground truncate text-xs",
1019
+ children: item.description
1020
+ }) : null
1021
+ ]
1022
+ })
1023
+ ]
1024
+ });
1025
+ };
1026
+ var referenceText = (item) => item ? [item.label, item.description].filter(Boolean).join(" — ") : "";
986
1027
  var messages2 = {
987
1028
  en: {
988
1029
  ...paginationMessages("en"),
@@ -1112,7 +1153,7 @@ var buildDataTableRows = (rowData, columns, getRowId) => {
1112
1153
  index,
1113
1154
  values: new Map(columns.map((column) => {
1114
1155
  const { colDef } = column;
1115
- const value = colDef.valueGetter ? colDef.valueGetter({ data, rowId: id, rowIndex: index, colDef }) : colDef.type === "list" ? colDef.typeOptions.getItems(data).map((item) => item.label).join(", ") : colDef.field ? data[colDef.field] : undefined;
1156
+ const value = colDef.valueGetter ? colDef.valueGetter({ data, rowId: id, rowIndex: index, colDef }) : colDef.type === "list" ? colDef.typeOptions.getItems(data).map((item) => item.label).join(", ") : colDef.type === "reference" ? referenceText(colDef.typeOptions.getItem(data)) : colDef.field ? data[colDef.field] : undefined;
1116
1157
  return [column.id, value];
1117
1158
  }))
1118
1159
  };
@@ -1443,6 +1484,15 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
1443
1484
  ...params
1444
1485
  });
1445
1486
  const colDef = column.colDef;
1487
+ if (colDef.type === "reference") {
1488
+ if (colDef.valueFormatter)
1489
+ return colDef.valueFormatter(params);
1490
+ return /* @__PURE__ */ jsx14(DataTableReferenceCell, {
1491
+ item: colDef.typeOptions.getItem(row.data),
1492
+ emptyLabel: colDef.typeOptions.emptyLabel,
1493
+ imageVariant: colDef.typeOptions.imageVariant
1494
+ });
1495
+ }
1446
1496
  if (colDef.type === "number") {
1447
1497
  if (colDef.valueFormatter)
1448
1498
  return colDef.valueFormatter(params);
@@ -3437,6 +3487,7 @@ export {
3437
3487
  DataTable,
3438
3488
  DataTableListCell,
3439
3489
  DataTableListSummary,
3490
+ DataTableReferenceCell,
3440
3491
  DataTableRowActions,
3441
3492
  buildDataTableRows,
3442
3493
  dataTableMessages,
@@ -129,139 +129,295 @@ var event = Effect.fnUntraced(function* (name, properties, options) {
129
129
  });
130
130
 
131
131
  // ../../src/services/events/browser.ts
132
- import { Context as Context2, Effect as Effect3, FiberSet, Layer as Layer2, Option as Option3, Schema as Schema4 } from "effect";
132
+ import { Context as Context2, Effect as Effect4, FiberSet, Layer as Layer2, Option as Option4, Schema as Schema5 } from "effect";
133
133
 
134
134
  // ../../src/services/events/schema.ts
135
- import { Effect as Effect2, Option as Option2, Schema as Schema3 } from "effect";
136
- var EventUuid = Schema3.String.check(Schema3.isUUID());
137
- var EventId = Schema3.NonEmptyString.check(Schema3.isMaxLength(100));
138
- var BrowserEventPath = Schema3.String.check(Schema3.isMaxLength(2048), Schema3.isPattern(/^\/(?!\/)[^?#]*$/));
139
- var EventIdentity = Schema3.Struct({
140
- userId: Schema3.optional(Schema3.NonEmptyString),
141
- organizationId: Schema3.optional(Schema3.NonEmptyString)
135
+ import { Effect as Effect3, Option as Option3, Schema as Schema4 } from "effect";
136
+
137
+ // ../../src/lib/query.ts
138
+ import {
139
+ Effect as Effect2,
140
+ Option as Option2,
141
+ Schema as Schema3,
142
+ SchemaGetter,
143
+ SchemaIssue,
144
+ SchemaTransformation
145
+ } from "effect";
146
+ var parseSortParam = (sort) => {
147
+ const id = sort.startsWith("-") ? sort.slice(1) : sort;
148
+ if (!id || id.includes(",") || id.includes(":")) {
149
+ return null;
150
+ }
151
+ return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
152
+ };
153
+ var SortDirection = Schema3.Union([
154
+ Schema3.Literal("asc"),
155
+ Schema3.Literal("desc")
156
+ ]).pipe(Schema3.annotate({
157
+ identifier: "SortDirection",
158
+ title: "Sort Direction",
159
+ description: "Sort direction for list query results.",
160
+ examples: ["asc", "desc"]
161
+ }));
162
+ var SortParam = Schema3.Struct({
163
+ id: Schema3.NonEmptyString,
164
+ direction: SortDirection
165
+ }).pipe(Schema3.annotate({
166
+ identifier: "SortParam",
167
+ title: "Sort Parameter",
168
+ description: "Decoded sort parameter with a field id and direction.",
169
+ examples: [{ id: "publicName", direction: "asc" }]
170
+ }));
171
+ var SortParamFromString = Schema3.String.pipe(Schema3.decodeTo(SortParam, SchemaTransformation.transformEffect({
172
+ decode: (sort) => {
173
+ const sortParam = parseSortParam(sort);
174
+ if (!sortParam) {
175
+ return Effect2.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field" or "-field"' }, sort));
176
+ }
177
+ return Effect2.succeed(sortParam);
178
+ },
179
+ encode: (sort) => Effect2.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
180
+ })), Schema3.annotate({
181
+ identifier: "SortParamFromString",
182
+ title: "Sort Parameter From String",
183
+ description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
184
+ examples: [{ id: "publicName", direction: "asc" }]
185
+ }));
186
+ var SortParamsFromString = Schema3.String.pipe(Schema3.decodeTo(Schema3.Array(SortParam), SchemaTransformation.transformEffect({
187
+ decode: (sort) => {
188
+ if (sort === "")
189
+ return Effect2.succeed([]);
190
+ const parts = sort.split(",");
191
+ const sortParams = [];
192
+ for (const part of parts) {
193
+ const sortParam = parseSortParam(part);
194
+ if (!sortParam) {
195
+ return Effect2.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field,-otherField"' }, sort));
196
+ }
197
+ sortParams.push(sortParam);
198
+ }
199
+ return Effect2.succeed(sortParams);
200
+ },
201
+ encode: (sort) => Effect2.succeed(sort.map((part) => Schema3.encodeSync(SortParamFromString)(part)).join(","))
202
+ })), Schema3.annotate({
203
+ identifier: "SortParamsFromString",
204
+ title: "Sort Parameters From String",
205
+ description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
206
+ examples: [
207
+ [
208
+ { id: "name", direction: "desc" },
209
+ { id: "age", direction: "asc" }
210
+ ]
211
+ ]
212
+ }));
213
+ var SortParamsArray = Schema3.Array(SortParam);
214
+ var SortParams = Schema3.declare(Schema3.is(SortParamsArray), {
215
+ identifier: "SortParams",
216
+ toCodec: () => Schema3.link()(SortParamsArray, SchemaTransformation.passthrough()),
217
+ toCodecStringTree: () => Schema3.link()(SortParamsFromString, SchemaTransformation.passthrough())
218
+ });
219
+ var Query = Schema3.Struct({
220
+ page: Schema3.optional(Schema3.Union([Schema3.Number, Schema3.NumberFromString]).check(Schema3.isInt(), Schema3.isGreaterThanOrEqualTo(0))).pipe(Schema3.decodeTo(Schema3.Int.check(Schema3.isGreaterThanOrEqualTo(0)), {
221
+ decode: SchemaGetter.withDefault(Effect2.succeed(0)),
222
+ encode: SchemaGetter.transformOptional(Option2.filter((page) => page !== 0))
223
+ })),
224
+ pageSize: Schema3.optional(Schema3.Union([Schema3.Number, Schema3.NumberFromString]).check(Schema3.isInt(), Schema3.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema3.decodeTo(Schema3.Int.check(Schema3.isBetween({ minimum: 1, maximum: 100 })), {
225
+ decode: SchemaGetter.withDefault(Effect2.succeed(20)),
226
+ encode: SchemaGetter.transformOptional(Option2.filter((pageSize) => pageSize !== 20))
227
+ })),
228
+ globalFilter: Schema3.optional(Schema3.String),
229
+ sort: Schema3.optional(SortParams)
230
+ }).annotate({
231
+ identifier: "Query",
232
+ title: "Query",
233
+ description: "Zero-based page request parameters with optional filtering and sorting for list endpoints.",
234
+ examples: [
235
+ {
236
+ page: 0,
237
+ pageSize: 20,
238
+ globalFilter: "housing",
239
+ sort: [
240
+ { id: "publicName", direction: "desc" },
241
+ { id: "createdAt", direction: "asc" }
242
+ ]
243
+ }
244
+ ]
245
+ });
246
+ var QueryStandard = Schema3.toStandardSchemaV1(Query);
247
+ var PaginationMeta = Schema3.Struct({
248
+ page: Schema3.Int,
249
+ pageSize: Schema3.Int,
250
+ total: Schema3.Int,
251
+ pageCount: Schema3.Int
252
+ }).pipe(Schema3.annotate({
253
+ identifier: "PaginationMeta",
254
+ title: "Pagination Metadata",
255
+ description: "Pagination metadata returned with a paginated list response.",
256
+ examples: [{ page: 0, pageSize: 20, total: 125, pageCount: 7 }]
257
+ }));
258
+
259
+ // ../../src/services/events/schema.ts
260
+ var EventUuid = Schema4.String.check(Schema4.isUUID());
261
+ var EventId = Schema4.NonEmptyString.check(Schema4.isMaxLength(100));
262
+ var BrowserEventPath = Schema4.String.check(Schema4.isMaxLength(2048), Schema4.isPattern(/^\/(?!\/)[^?#]*$/));
263
+ var EventIdentity = Schema4.Struct({
264
+ userId: Schema4.optional(Schema4.NonEmptyString),
265
+ organizationId: Schema4.optional(Schema4.NonEmptyString)
142
266
  }).annotate({ identifier: "EventIdentity" });
143
- var EventIpAddress = Schema3.String.check(Schema3.makeFilter((value) => Option2.isSome(Schema3.decodeUnknownOption(Schema3.IpAddressFromString)(value)) || "Invalid IP address")).annotate({ identifier: "EventIpAddress" });
144
- var EventCountry = Schema3.String.check(Schema3.isPattern(/^[A-Z]{2}$/), Schema3.makeFilter((value) => !["XX", "T1"].includes(value) || "Unknown country")).annotate({ identifier: "EventCountry" });
145
- var EventRegion = Schema3.String.check(Schema3.isPattern(/^[A-Z0-9]{1,3}$/)).annotate({ identifier: "EventRegion" });
146
- var EventCity = Schema3.NonEmptyString.check(Schema3.isMaxLength(128)).annotate({ identifier: "EventCity" });
147
- var EventGeolocation = Schema3.Struct({
148
- ip: Schema3.optional(EventIpAddress),
149
- country: Schema3.optional(EventCountry),
150
- region: Schema3.optional(EventRegion),
151
- city: Schema3.optional(EventCity)
267
+ var EventIpAddress = Schema4.String.check(Schema4.makeFilter((value) => Option3.isSome(Schema4.decodeUnknownOption(Schema4.IpAddressFromString)(value)) || "Invalid IP address")).annotate({ identifier: "EventIpAddress" });
268
+ var EventCountry = Schema4.String.check(Schema4.isPattern(/^[A-Z]{2}$/), Schema4.makeFilter((value) => !["XX", "T1"].includes(value) || "Unknown country")).annotate({ identifier: "EventCountry" });
269
+ var EventRegion = Schema4.String.check(Schema4.isPattern(/^[A-Z0-9]{1,3}$/)).annotate({ identifier: "EventRegion" });
270
+ var EventCity = Schema4.NonEmptyString.check(Schema4.isMaxLength(128)).annotate({ identifier: "EventCity" });
271
+ var EventGeolocation = Schema4.Struct({
272
+ ip: Schema4.optional(EventIpAddress),
273
+ country: Schema4.optional(EventCountry),
274
+ region: Schema4.optional(EventRegion),
275
+ city: Schema4.optional(EventCity)
152
276
  }).annotate({ identifier: "EventGeolocation" });
153
277
 
154
- class EventGeolocationError extends Schema3.TaggedError()("EventGeolocationError", {}) {
278
+ class EventGeolocationError extends Schema4.TaggedError()("EventGeolocationError", {}) {
155
279
  }
156
- var BrowserEventOptions = Schema3.Struct({
157
- messageId: Schema3.optional(EventId),
158
- timestamp: Schema3.optional(Schema3.DateTimeUtc),
159
- context: Schema3.optional(EventAttributesSchema)
280
+ var BrowserEventOptions = Schema4.Struct({
281
+ messageId: Schema4.optional(EventId),
282
+ timestamp: Schema4.optional(Schema4.DateTimeUtc),
283
+ context: Schema4.optional(EventAttributesSchema)
160
284
  }).annotate({ identifier: "BrowserEventOptions" });
161
- var BrowserPage = Schema3.Struct({
162
- name: Schema3.optional(Schema3.NonEmptyString),
163
- category: Schema3.optional(Schema3.NonEmptyString),
164
- path: Schema3.optional(Schema3.NonEmptyString),
165
- properties: Schema3.optional(EventAttributesSchema),
166
- options: Schema3.optional(BrowserEventOptions)
285
+ var BrowserPage = Schema4.Struct({
286
+ name: Schema4.optional(Schema4.NonEmptyString),
287
+ category: Schema4.optional(Schema4.NonEmptyString),
288
+ path: Schema4.optional(Schema4.NonEmptyString),
289
+ properties: Schema4.optional(EventAttributesSchema),
290
+ options: Schema4.optional(BrowserEventOptions)
167
291
  }).annotate({ identifier: "BrowserPage" });
168
- var TrackEvent = Schema3.Struct({
169
- eventId: EventId,
170
- name: Schema3.NonEmptyString.check(Schema3.isMaxLength(128)),
171
- properties: Schema3.optional(EventAttributesSchema),
172
- identity: Schema3.optional(EventIdentity),
173
- timestamp: Schema3.optional(Schema3.DateTimeUtc),
174
- category: Schema3.optional(Schema3.Literals(["analytics", "audit"]))
175
- }).annotate({ identifier: "TrackEvent" });
176
- var AuditAttribution = Schema3.Struct({
177
- "app.actor.type": Schema3.NonEmptyString,
178
- "app.actor.id": Schema3.NonEmptyString
292
+ var AuditTarget = Schema4.Struct({
293
+ id: Schema4.NonEmptyString.check(Schema4.isMaxLength(256)),
294
+ name: Schema4.NonEmptyString.check(Schema4.isMaxLength(2048)),
295
+ type: Schema4.NonEmptyString.check(Schema4.isMaxLength(128))
296
+ }).annotate({ identifier: "AuditTarget" });
297
+ var trackEventFields = {
298
+ eventId: Schema4.optional(EventId),
299
+ name: Schema4.NonEmptyString.check(Schema4.isMaxLength(128)),
300
+ properties: Schema4.optional(EventAttributesSchema),
301
+ identity: Schema4.optional(EventIdentity),
302
+ timestamp: Schema4.optional(Schema4.DateTimeUtc)
303
+ };
304
+ var TrackEvent = Schema4.Union([
305
+ Schema4.Struct({
306
+ ...trackEventFields,
307
+ category: Schema4.optional(Schema4.Literal("analytics"))
308
+ }),
309
+ Schema4.Struct({
310
+ ...trackEventFields,
311
+ category: Schema4.Literal("audit"),
312
+ target: AuditTarget
313
+ })
314
+ ]).annotate({ identifier: "TrackEvent" });
315
+ var ListAudit = Schema4.Struct({
316
+ organizationId: Schema4.NonEmptyString,
317
+ ...Query.fields
318
+ }).annotate({ identifier: "ListAudit" });
319
+ var AuditSortId = Schema4.Literals([
320
+ "time",
321
+ "eventName",
322
+ "recordType",
323
+ "record",
324
+ "actorType",
325
+ "actorId"
326
+ ]).annotate({ identifier: "AuditSortId" });
327
+ var AuditCount = Schema4.Struct({ total: Schema4.Int }).annotate({
328
+ identifier: "AuditCount"
329
+ });
330
+ var AuditAttribution = Schema4.Struct({
331
+ "app.actor.type": Schema4.NonEmptyString,
332
+ "app.actor.id": Schema4.NonEmptyString
179
333
  }).annotate({ identifier: "AuditAttribution" });
180
- var RequestActorAttribution = Schema3.Struct({
334
+ var RequestActorAttribution = Schema4.Struct({
181
335
  ...AuditAttribution.fields,
182
- "app.actor.owner.type": Schema3.optional(Schema3.NonEmptyString),
183
- "app.actor.owner.id": Schema3.optional(Schema3.NonEmptyString)
336
+ "app.auth.method": Schema4.optional(Schema4.NonEmptyString),
337
+ "app.auth.credential.id": Schema4.optional(Schema4.NonEmptyString),
338
+ "app.auth.impersonator.id": Schema4.optional(Schema4.NonEmptyString),
339
+ "user.roles": Schema4.optional(Schema4.Array(Schema4.String))
184
340
  }).annotate({ identifier: "RequestActorAttribution" });
185
341
 
186
- class EventsPersistenceError extends Schema3.TaggedError()("EventsPersistenceError", { operation: Schema3.String }) {
342
+ class EventsPersistenceError extends Schema4.TaggedError()("EventsPersistenceError", { operation: Schema4.String }) {
187
343
  }
188
344
 
189
- class EventConflictError extends Schema3.TaggedError()("EventConflictError", { eventId: EventId }) {
345
+ class EventConflictError extends Schema4.TaggedError()("EventConflictError", { eventId: EventId }) {
190
346
  }
191
- var EventSource = Schema3.Literals(["browser", "server"]).annotate({
347
+ var EventSource = Schema4.Literals(["browser", "server"]).annotate({
192
348
  identifier: "EventSource"
193
349
  });
194
- var ExistingEventRequest = Schema3.Struct({
350
+ var ExistingEventRequest = Schema4.Struct({
195
351
  eventId: EventId,
196
352
  source: EventSource
197
353
  }).annotate({ identifier: "ExistingEventRequest" });
198
- var StoredEventRequest = Schema3.Struct({
354
+ var StoredEventRequest = Schema4.Struct({
199
355
  source: EventSource,
200
356
  event_id: EventId,
201
- event_name: Schema3.NonEmptyString,
202
- event_type: Schema3.Literals(["page", "track"]),
203
- occurred_at: Schema3.Finite,
204
- received_at: Schema3.Finite,
205
- organization_id: Schema3.NullOr(Schema3.NonEmptyString),
206
- user_id: Schema3.NullOr(Schema3.NonEmptyString),
207
- session_id: Schema3.NullOr(Schema3.NonEmptyString),
208
- anonymous_id: Schema3.NullOr(Schema3.NonEmptyString),
209
- payload_json: Schema3.String
357
+ event_name: Schema4.NonEmptyString,
358
+ event_type: Schema4.Literals(["page", "track"]),
359
+ occurred_at: Schema4.Finite,
360
+ received_at: Schema4.Finite,
361
+ organization_id: Schema4.NullOr(Schema4.NonEmptyString),
362
+ user_id: Schema4.NullOr(Schema4.NonEmptyString),
363
+ session_id: Schema4.NullOr(Schema4.NonEmptyString),
364
+ anonymous_id: Schema4.NullOr(Schema4.NonEmptyString),
365
+ payload_json: Schema4.String
210
366
  }).annotate({ identifier: "StoredEventRequest" });
211
- var StoredEventId = Schema3.Struct({
367
+ var StoredEventId = Schema4.Struct({
212
368
  event_id: EventId
213
369
  }).annotate({ identifier: "StoredEventId" });
214
- var PrimitiveValue = Schema3.Union([
215
- Schema3.Struct({ stringValue: Schema3.String.check(Schema3.isMaxLength(2048)) }),
216
- Schema3.Struct({
217
- intValue: Schema3.Union([
218
- Schema3.String.check(Schema3.isPattern(/^-?\d{1,20}$/)),
219
- Schema3.Int
370
+ var PrimitiveValue = Schema4.Union([
371
+ Schema4.Struct({ stringValue: Schema4.String.check(Schema4.isMaxLength(2048)) }),
372
+ Schema4.Struct({
373
+ intValue: Schema4.Union([
374
+ Schema4.String.check(Schema4.isPattern(/^-?\d{1,20}$/)),
375
+ Schema4.Int
220
376
  ])
221
377
  }),
222
- Schema3.Struct({ doubleValue: Schema3.Finite }),
223
- Schema3.Struct({ boolValue: Schema3.Boolean })
378
+ Schema4.Struct({ doubleValue: Schema4.Finite }),
379
+ Schema4.Struct({ boolValue: Schema4.Boolean })
224
380
  ]);
225
- var AttributeValue = Schema3.Union([
381
+ var AttributeValue = Schema4.Union([
226
382
  PrimitiveValue,
227
- Schema3.Struct({
228
- arrayValue: Schema3.Struct({
229
- values: Schema3.Array(PrimitiveValue).check(Schema3.isMaxLength(32))
383
+ Schema4.Struct({
384
+ arrayValue: Schema4.Struct({
385
+ values: Schema4.Array(PrimitiveValue).check(Schema4.isMaxLength(32))
230
386
  })
231
387
  })
232
388
  ]);
233
- var EventAttribute = Schema3.Struct({
234
- key: Schema3.NonEmptyString.check(Schema3.isMaxLength(128)),
389
+ var EventAttribute = Schema4.Struct({
390
+ key: Schema4.NonEmptyString.check(Schema4.isMaxLength(128)),
235
391
  value: AttributeValue
236
392
  }).annotate({ identifier: "EventAttribute" });
237
- var EventLogRecord = Schema3.Struct({
238
- eventName: Schema3.NonEmptyString.check(Schema3.isMaxLength(128), Schema3.isPattern(/^[^\r\n]+$/)),
239
- timeUnixNano: Schema3.String.check(Schema3.isPattern(/^\d{1,20}$/)),
240
- observedTimeUnixNano: Schema3.optional(Schema3.String.check(Schema3.isPattern(/^\d{1,20}$/))),
241
- severityNumber: Schema3.optional(Schema3.Int),
242
- traceId: Schema3.optional(Schema3.String.check(Schema3.isPattern(/^[a-f0-9]{32}$/))),
243
- spanId: Schema3.optional(Schema3.String.check(Schema3.isPattern(/^[a-f0-9]{16}$/))),
244
- attributes: Schema3.Array(EventAttribute).check(Schema3.isMaxLength(64), Schema3.makeFilter((values) => new Set(values.map(({ key }) => key)).size === values.length || "Duplicate attribute keys"))
393
+ var EventLogRecord = Schema4.Struct({
394
+ eventName: Schema4.NonEmptyString.check(Schema4.isMaxLength(128), Schema4.isPattern(/^[^\r\n]+$/)),
395
+ timeUnixNano: Schema4.String.check(Schema4.isPattern(/^\d{1,20}$/)),
396
+ observedTimeUnixNano: Schema4.optional(Schema4.String.check(Schema4.isPattern(/^\d{1,20}$/))),
397
+ severityNumber: Schema4.optional(Schema4.Int),
398
+ traceId: Schema4.optional(Schema4.String.check(Schema4.isPattern(/^[a-f0-9]{32}$/))),
399
+ spanId: Schema4.optional(Schema4.String.check(Schema4.isPattern(/^[a-f0-9]{16}$/))),
400
+ attributes: Schema4.Array(EventAttribute).check(Schema4.isMaxLength(64), Schema4.makeFilter((values) => new Set(values.map(({ key }) => key)).size === values.length || "Duplicate attribute keys"))
245
401
  }).annotate({ identifier: "EventLogRecord" });
246
- var extensions = Schema3.Record(Schema3.String, Schema3.Unknown);
247
- var OtlpLogs = Schema3.StructWithRest(Schema3.Struct({
248
- resourceLogs: Schema3.Array(Schema3.StructWithRest(Schema3.Struct({
249
- scopeLogs: Schema3.Array(Schema3.StructWithRest(Schema3.Struct({
250
- scope: Schema3.optional(Schema3.StructWithRest(Schema3.Struct({ name: Schema3.optional(Schema3.String) }), [extensions])),
251
- logRecords: Schema3.Array(Schema3.Unknown).pipe(Schema3.withDecodingDefaultKey(Effect2.succeed([])))
252
- }), [extensions])).pipe(Schema3.withDecodingDefaultKey(Effect2.succeed([])))
253
- }), [extensions])).pipe(Schema3.withDecodingDefaultKey(Effect2.succeed([])))
402
+ var extensions = Schema4.Record(Schema4.String, Schema4.Unknown);
403
+ var OtlpLogs = Schema4.StructWithRest(Schema4.Struct({
404
+ resourceLogs: Schema4.Array(Schema4.StructWithRest(Schema4.Struct({
405
+ scopeLogs: Schema4.Array(Schema4.StructWithRest(Schema4.Struct({
406
+ scope: Schema4.optional(Schema4.StructWithRest(Schema4.Struct({ name: Schema4.optional(Schema4.String) }), [extensions])),
407
+ logRecords: Schema4.Array(Schema4.Unknown).pipe(Schema4.withDecodingDefaultKey(Effect3.succeed([])))
408
+ }), [extensions])).pipe(Schema4.withDecodingDefaultKey(Effect3.succeed([])))
409
+ }), [extensions])).pipe(Schema4.withDecodingDefaultKey(Effect3.succeed([])))
254
410
  }), [extensions]).annotate({ identifier: "EventsOtlpLogs" });
255
- var StoredEventPayload = Schema3.Struct({
256
- payload_json: Schema3.Union([OtlpLogs, Schema3.fromJsonString(OtlpLogs)])
411
+ var StoredEventPayload = Schema4.Struct({
412
+ payload_json: Schema4.Union([OtlpLogs, Schema4.fromJsonString(OtlpLogs)])
257
413
  }).annotate({ identifier: "StoredEventPayload" });
258
- var VisitorEventsRequest = Schema3.Struct({
259
- visitorId: Schema3.NonEmptyString
414
+ var VisitorEventsRequest = Schema4.Struct({
415
+ visitorId: Schema4.NonEmptyString
260
416
  }).annotate({ identifier: "VisitorEventsRequest" });
261
- var VisitorEventSession = Schema3.Struct({
417
+ var VisitorEventSession = Schema4.Struct({
262
418
  event_id: EventId,
263
- session_id: Schema3.NullOr(Schema3.NonEmptyString),
264
- received_at: Schema3.Finite
419
+ session_id: Schema4.NullOr(Schema4.NonEmptyString),
420
+ received_at: Schema4.Finite
265
421
  }).annotate({ identifier: "VisitorEventSession" });
266
422
 
267
423
  // ../../src/services/events/browser.ts
@@ -272,13 +428,13 @@ var eventProperties = (properties) => Object.fromEntries(Object.entries(properti
272
428
 
273
429
  class BrowserEventsClient extends Context2.Service()("krakstack/events/BrowserEventsClient") {
274
430
  }
275
- var emit = Effect3.fnUntraced(function* (name, properties, options) {
431
+ var emit = Effect4.fnUntraced(function* (name, properties, options) {
276
432
  const client = yield* BrowserEventsClient;
277
- const decoded = yield* Schema4.decodeUnknownEffect(BrowserEventOptions)(options ?? {});
278
- yield* event(name, { ...properties, ...client.context(name, properties) }, decoded).pipe(Effect3.provideService(OtlpEvents, client.events));
433
+ const decoded = yield* Schema5.decodeUnknownEffect(BrowserEventOptions)(options ?? {});
434
+ yield* event(name, { ...properties, ...client.context(name, properties) }, decoded).pipe(Effect4.provideService(OtlpEvents, client.events));
279
435
  });
280
- var page = Effect3.fnUntraced(function* (input = {}) {
281
- const decoded = yield* Schema4.decodeUnknownEffect(BrowserPage)(input);
436
+ var page = Effect4.fnUntraced(function* (input = {}) {
437
+ const decoded = yield* Schema5.decodeUnknownEffect(BrowserPage)(input);
282
438
  const properties = eventProperties(decoded.properties);
283
439
  if (decoded.name)
284
440
  properties["analytics.page.name"] = decoded.name;
@@ -288,16 +444,16 @@ var page = Effect3.fnUntraced(function* (input = {}) {
288
444
  yield* emit("browser.page_view", properties, decoded.options);
289
445
  });
290
446
  var clients = [];
291
- var runBrowser = (program) => Effect3.suspend(() => {
447
+ var runBrowser = (program) => Effect4.suspend(() => {
292
448
  const client = clients.at(-1);
293
- return client ? program.pipe(Effect3.provideService(BrowserEventsClient, client)) : Effect3.void;
449
+ return client ? program.pipe(Effect4.provideService(BrowserEventsClient, client)) : Effect4.void;
294
450
  });
295
- var BrowserClientLive = Layer2.effectDiscard(Effect3.gen(function* () {
451
+ var BrowserClientLive = Layer2.effectDiscard(Effect4.gen(function* () {
296
452
  const client = yield* BrowserEventsClient;
297
- yield* Effect3.acquireRelease(Effect3.sync(() => {
453
+ yield* Effect4.acquireRelease(Effect4.sync(() => {
298
454
  clients.push(client);
299
455
  return client;
300
- }), (client) => Effect3.sync(() => {
456
+ }), (client) => Effect4.sync(() => {
301
457
  const index = clients.indexOf(client);
302
458
  if (index !== -1)
303
459
  clients.splice(index, 1);
@@ -341,18 +497,18 @@ var subscribePageViews = (listener) => {
341
497
  }
342
498
  };
343
499
  };
344
- var BrowserPageViewsLive = Layer2.effectDiscard(Effect3.gen(function* () {
500
+ var BrowserPageViewsLive = Layer2.effectDiscard(Effect4.gen(function* () {
345
501
  const fibers = yield* FiberSet.make();
346
502
  const run = yield* FiberSet.runtime(fibers)();
347
503
  let previousPath = location.pathname;
348
- yield* Effect3.acquireRelease(Effect3.sync(() => subscribePageViews(() => {
504
+ yield* Effect4.acquireRelease(Effect4.sync(() => subscribePageViews(() => {
349
505
  const path = location.pathname;
350
506
  if (path === previousPath)
351
507
  return;
352
508
  previousPath = path;
353
- run(page({ path }).pipe(Effect3.ignore));
354
- })), (unsubscribe) => Effect3.sync(unsubscribe));
355
- yield* page({ path: previousPath }).pipe(Effect3.ignore);
509
+ run(page({ path }).pipe(Effect4.ignore));
510
+ })), (unsubscribe) => Effect4.sync(unsubscribe));
511
+ yield* page({ path: previousPath }).pipe(Effect4.ignore);
356
512
  }));
357
513
 
358
514
  class BrowserEvents {
@@ -365,13 +521,13 @@ class BrowserEvents {
365
521
  locale,
366
522
  sanitizePath
367
523
  } = {}) => {
368
- const privacy = Schema4.decodeUnknownSync(Schema4.Struct({ globalPrivacyControl: Schema4.optional(Schema4.Boolean) }))(navigator);
524
+ const privacy = Schema5.decodeUnknownSync(Schema5.Struct({ globalPrivacyControl: Schema5.optional(Schema5.Boolean) }))(navigator);
369
525
  const disabled = !enabled || respectDoNotTrack && (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || privacy.globalPrivacyControl === true);
370
526
  let previousPath;
371
527
  let pageViewId = crypto.randomUUID();
372
528
  const context = (name, properties) => {
373
- const explicitPath = Schema4.decodeUnknownOption(Schema4.String)(properties?.["url.path"]);
374
- const path = Option3.getOrElse(explicitPath, () => location.pathname);
529
+ const explicitPath = Schema5.decodeUnknownOption(Schema5.String)(properties?.["url.path"]);
530
+ const path = Option4.getOrElse(explicitPath, () => location.pathname);
375
531
  if (location.pathname !== previousPath || name === "browser.page_view") {
376
532
  previousPath = location.pathname;
377
533
  pageViewId = crypto.randomUUID();
@@ -399,7 +555,7 @@ class BrowserEvents {
399
555
  }
400
556
  return { ...attributes, ...optional };
401
557
  };
402
- const client = Layer2.effect(BrowserEventsClient, Effect3.gen(function* () {
558
+ const client = Layer2.effect(BrowserEventsClient, Effect4.gen(function* () {
403
559
  const exporter = yield* OtlpEvents;
404
560
  return {
405
561
  events: {