@krak-stack/registry 0.1.51 → 0.1.52
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 +18 -0
- package/dist/components/ui/data-table.d.ts +20 -1
- package/dist/components/ui/data-table.js +52 -1
- package/dist/services/events/browser.js +269 -113
- package/dist/services/events/client/audit-log-table.d.ts +53 -0
- package/dist/services/events/client/audit-log-table.js +3655 -0
- package/dist/services/events/index.d.ts +137 -4
- package/dist/services/events/index.js +410 -162
- package/dist/services/events/record.d.ts +3 -0
- package/dist/services/events/record.js +14 -0
- package/dist/services/events/schema.d.ts +47 -6
- package/dist/services/events/schema.js +361 -0
- package/package.json +13 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// ../../src/services/events/record.ts
|
|
2
|
+
import { Option, Schema } from "effect";
|
|
3
|
+
var TextValue = Schema.Struct({ stringValue: Schema.String }).annotate({
|
|
4
|
+
identifier: "EventTextValue"
|
|
5
|
+
});
|
|
6
|
+
var TextArrayValue = Schema.Struct({
|
|
7
|
+
arrayValue: Schema.Struct({ values: Schema.Array(TextValue) })
|
|
8
|
+
}).annotate({ identifier: "EventTextArrayValue" });
|
|
9
|
+
var eventTextAttribute = (record, key) => Schema.decodeUnknownOption(TextValue)(record.attributes.find((attribute) => attribute.key === key)?.value).pipe(Option.map((value) => value.stringValue), Option.getOrNull);
|
|
10
|
+
var eventStringArrayAttribute = (record, key) => Schema.decodeUnknownOption(TextArrayValue)(record.attributes.find((attribute) => attribute.key === key)?.value).pipe(Option.map((value) => value.arrayValue.values.map((item) => item.stringValue)), Option.getOrElse(() => []));
|
|
11
|
+
export {
|
|
12
|
+
eventStringArrayAttribute,
|
|
13
|
+
eventTextAttribute
|
|
14
|
+
};
|
|
@@ -39,8 +39,14 @@ export declare const BrowserPage: Schema.Struct<{
|
|
|
39
39
|
}>;
|
|
40
40
|
export type BrowserEventOptions = typeof BrowserEventOptions.Type;
|
|
41
41
|
export type BrowserPageOptions = typeof BrowserPage.Type;
|
|
42
|
-
export declare const
|
|
43
|
-
readonly
|
|
42
|
+
export declare const AuditTarget: Schema.Struct<{
|
|
43
|
+
readonly id: Schema.NonEmptyString;
|
|
44
|
+
readonly name: Schema.NonEmptyString;
|
|
45
|
+
readonly type: Schema.NonEmptyString;
|
|
46
|
+
}>;
|
|
47
|
+
export type AuditTarget = typeof AuditTarget.Type;
|
|
48
|
+
export declare const TrackEvent: Schema.Union<readonly [Schema.Struct<{
|
|
49
|
+
readonly eventId: Schema.optional<Schema.NonEmptyString>;
|
|
44
50
|
readonly name: Schema.NonEmptyString;
|
|
45
51
|
readonly properties: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>, Schema.$Array<Schema.Finite>, Schema.$Array<Schema.Boolean>]>>>;
|
|
46
52
|
readonly identity: Schema.optional<Schema.Struct<{
|
|
@@ -48,9 +54,41 @@ export declare const TrackEvent: Schema.Struct<{
|
|
|
48
54
|
readonly organizationId: Schema.optional<Schema.NonEmptyString>;
|
|
49
55
|
}>>;
|
|
50
56
|
readonly timestamp: Schema.optional<Schema.DateTimeUtc>;
|
|
51
|
-
readonly category: Schema.optional<Schema.
|
|
52
|
-
}
|
|
57
|
+
readonly category: Schema.optional<Schema.Literal<"analytics">>;
|
|
58
|
+
}>, Schema.Struct<{
|
|
59
|
+
readonly eventId: Schema.optional<Schema.NonEmptyString>;
|
|
60
|
+
readonly name: Schema.NonEmptyString;
|
|
61
|
+
readonly properties: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>, Schema.$Array<Schema.Finite>, Schema.$Array<Schema.Boolean>]>>>;
|
|
62
|
+
readonly identity: Schema.optional<Schema.Struct<{
|
|
63
|
+
readonly userId: Schema.optional<Schema.NonEmptyString>;
|
|
64
|
+
readonly organizationId: Schema.optional<Schema.NonEmptyString>;
|
|
65
|
+
}>>;
|
|
66
|
+
readonly timestamp: Schema.optional<Schema.DateTimeUtc>;
|
|
67
|
+
readonly category: Schema.Literal<"audit">;
|
|
68
|
+
readonly target: Schema.Struct<{
|
|
69
|
+
readonly id: Schema.NonEmptyString;
|
|
70
|
+
readonly name: Schema.NonEmptyString;
|
|
71
|
+
readonly type: Schema.NonEmptyString;
|
|
72
|
+
}>;
|
|
73
|
+
}>]>;
|
|
53
74
|
export type TrackEvent = typeof TrackEvent.Type;
|
|
75
|
+
export declare const ListAudit: Schema.Struct<{
|
|
76
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
77
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
78
|
+
readonly globalFilter: Schema.optional<Schema.String>;
|
|
79
|
+
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
80
|
+
readonly id: string;
|
|
81
|
+
readonly direction: "asc" | "desc";
|
|
82
|
+
}[], readonly {
|
|
83
|
+
readonly id: string;
|
|
84
|
+
readonly direction: "asc" | "desc";
|
|
85
|
+
}[]>>;
|
|
86
|
+
readonly organizationId: Schema.NonEmptyString;
|
|
87
|
+
}>;
|
|
88
|
+
export declare const AuditSortId: Schema.Literals<readonly ["time", "eventName", "recordType", "record", "actorType", "actorId"]>;
|
|
89
|
+
export declare const AuditCount: Schema.Struct<{
|
|
90
|
+
readonly total: Schema.Int;
|
|
91
|
+
}>;
|
|
54
92
|
/** Minimal attribution contract; actor types and resolution belong to auth. */
|
|
55
93
|
export declare const AuditAttribution: Schema.Struct<{
|
|
56
94
|
readonly "app.actor.type": Schema.NonEmptyString;
|
|
@@ -60,8 +98,11 @@ export declare const AuditAttribution: Schema.Struct<{
|
|
|
60
98
|
export declare const RequestActorAttribution: Schema.Struct<{
|
|
61
99
|
readonly "app.actor.type": Schema.NonEmptyString;
|
|
62
100
|
readonly "app.actor.id": Schema.NonEmptyString;
|
|
63
|
-
readonly "app.
|
|
64
|
-
readonly "app.
|
|
101
|
+
readonly "app.auth.method": Schema.optional<Schema.NonEmptyString>;
|
|
102
|
+
readonly "app.auth.credential.id": Schema.optional<Schema.NonEmptyString>;
|
|
103
|
+
/** Initiating admin from a verified session; actor and user IDs remain the effective user. */
|
|
104
|
+
readonly "app.auth.impersonator.id": Schema.optional<Schema.NonEmptyString>;
|
|
105
|
+
readonly "user.roles": Schema.optional<Schema.$Array<Schema.String>>;
|
|
65
106
|
}>;
|
|
66
107
|
declare const EventsPersistenceError_base: Schema.Class<EventsPersistenceError, Schema.TaggedStruct<"EventsPersistenceError", {
|
|
67
108
|
readonly operation: Schema.String;
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
// ../../src/services/events/schema.ts
|
|
2
|
+
import { Effect as Effect2, Option as Option2, Schema as Schema3 } from "effect";
|
|
3
|
+
|
|
4
|
+
// ../../src/services/opentelemetry/schema.ts
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
var BrowserWebVital = Schema.Struct({
|
|
7
|
+
name: Schema.Literals(["LCP", "INP", "CLS", "FCP", "TTFB"]),
|
|
8
|
+
id: Schema.NonEmptyString.check(Schema.isMaxLength(64)),
|
|
9
|
+
value: Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
10
|
+
delta: Schema.Finite,
|
|
11
|
+
rating: Schema.Literals(["good", "needs-improvement", "poor"]),
|
|
12
|
+
navigationType: Schema.Literals([
|
|
13
|
+
"navigate",
|
|
14
|
+
"reload",
|
|
15
|
+
"back-forward",
|
|
16
|
+
"back-forward-cache",
|
|
17
|
+
"prerender",
|
|
18
|
+
"restore"
|
|
19
|
+
])
|
|
20
|
+
}).annotate({ identifier: "BrowserWebVital" });
|
|
21
|
+
var EventAttributeValue = Schema.Union([
|
|
22
|
+
Schema.String,
|
|
23
|
+
Schema.Finite,
|
|
24
|
+
Schema.Boolean,
|
|
25
|
+
Schema.Array(Schema.String),
|
|
26
|
+
Schema.Array(Schema.Finite),
|
|
27
|
+
Schema.Array(Schema.Boolean)
|
|
28
|
+
]);
|
|
29
|
+
var EventAttributesSchema = Schema.Record(Schema.String, EventAttributeValue).annotate({ identifier: "EventAttributes" });
|
|
30
|
+
var EventOptionsSchema = Schema.Struct({
|
|
31
|
+
userId: Schema.optional(Schema.NonEmptyString),
|
|
32
|
+
anonymousId: Schema.optional(Schema.NonEmptyString),
|
|
33
|
+
sessionId: Schema.optional(Schema.NonEmptyString),
|
|
34
|
+
messageId: Schema.optional(Schema.NonEmptyString),
|
|
35
|
+
timestamp: Schema.optional(Schema.DateTimeUtc),
|
|
36
|
+
context: Schema.optional(EventAttributesSchema)
|
|
37
|
+
}).annotate({ identifier: "EventOptions" });
|
|
38
|
+
var TelemetryEvent = Schema.Struct({
|
|
39
|
+
name: Schema.NonEmptyString,
|
|
40
|
+
properties: Schema.optional(EventAttributesSchema),
|
|
41
|
+
options: Schema.optional(EventOptionsSchema)
|
|
42
|
+
}).annotate({ identifier: "TelemetryEvent" });
|
|
43
|
+
|
|
44
|
+
// ../../src/lib/query.ts
|
|
45
|
+
import {
|
|
46
|
+
Effect,
|
|
47
|
+
Option,
|
|
48
|
+
Schema as Schema2,
|
|
49
|
+
SchemaGetter,
|
|
50
|
+
SchemaIssue,
|
|
51
|
+
SchemaTransformation
|
|
52
|
+
} from "effect";
|
|
53
|
+
var parseSortParam = (sort) => {
|
|
54
|
+
const id = sort.startsWith("-") ? sort.slice(1) : sort;
|
|
55
|
+
if (!id || id.includes(",") || id.includes(":")) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
|
|
59
|
+
};
|
|
60
|
+
var SortDirection = Schema2.Union([
|
|
61
|
+
Schema2.Literal("asc"),
|
|
62
|
+
Schema2.Literal("desc")
|
|
63
|
+
]).pipe(Schema2.annotate({
|
|
64
|
+
identifier: "SortDirection",
|
|
65
|
+
title: "Sort Direction",
|
|
66
|
+
description: "Sort direction for list query results.",
|
|
67
|
+
examples: ["asc", "desc"]
|
|
68
|
+
}));
|
|
69
|
+
var SortParam = Schema2.Struct({
|
|
70
|
+
id: Schema2.NonEmptyString,
|
|
71
|
+
direction: SortDirection
|
|
72
|
+
}).pipe(Schema2.annotate({
|
|
73
|
+
identifier: "SortParam",
|
|
74
|
+
title: "Sort Parameter",
|
|
75
|
+
description: "Decoded sort parameter with a field id and direction.",
|
|
76
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
77
|
+
}));
|
|
78
|
+
var SortParamFromString = Schema2.String.pipe(Schema2.decodeTo(SortParam, SchemaTransformation.transformEffect({
|
|
79
|
+
decode: (sort) => {
|
|
80
|
+
const sortParam = parseSortParam(sort);
|
|
81
|
+
if (!sortParam) {
|
|
82
|
+
return Effect.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field" or "-field"' }, sort));
|
|
83
|
+
}
|
|
84
|
+
return Effect.succeed(sortParam);
|
|
85
|
+
},
|
|
86
|
+
encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
87
|
+
})), Schema2.annotate({
|
|
88
|
+
identifier: "SortParamFromString",
|
|
89
|
+
title: "Sort Parameter From String",
|
|
90
|
+
description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
|
|
91
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
92
|
+
}));
|
|
93
|
+
var SortParamsFromString = Schema2.String.pipe(Schema2.decodeTo(Schema2.Array(SortParam), SchemaTransformation.transformEffect({
|
|
94
|
+
decode: (sort) => {
|
|
95
|
+
if (sort === "")
|
|
96
|
+
return Effect.succeed([]);
|
|
97
|
+
const parts = sort.split(",");
|
|
98
|
+
const sortParams = [];
|
|
99
|
+
for (const part of parts) {
|
|
100
|
+
const sortParam = parseSortParam(part);
|
|
101
|
+
if (!sortParam) {
|
|
102
|
+
return Effect.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field,-otherField"' }, sort));
|
|
103
|
+
}
|
|
104
|
+
sortParams.push(sortParam);
|
|
105
|
+
}
|
|
106
|
+
return Effect.succeed(sortParams);
|
|
107
|
+
},
|
|
108
|
+
encode: (sort) => Effect.succeed(sort.map((part) => Schema2.encodeSync(SortParamFromString)(part)).join(","))
|
|
109
|
+
})), Schema2.annotate({
|
|
110
|
+
identifier: "SortParamsFromString",
|
|
111
|
+
title: "Sort Parameters From String",
|
|
112
|
+
description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
|
|
113
|
+
examples: [
|
|
114
|
+
[
|
|
115
|
+
{ id: "name", direction: "desc" },
|
|
116
|
+
{ id: "age", direction: "asc" }
|
|
117
|
+
]
|
|
118
|
+
]
|
|
119
|
+
}));
|
|
120
|
+
var SortParamsArray = Schema2.Array(SortParam);
|
|
121
|
+
var SortParams = Schema2.declare(Schema2.is(SortParamsArray), {
|
|
122
|
+
identifier: "SortParams",
|
|
123
|
+
toCodec: () => Schema2.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
124
|
+
toCodecStringTree: () => Schema2.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
125
|
+
});
|
|
126
|
+
var Query = Schema2.Struct({
|
|
127
|
+
page: Schema2.optional(Schema2.Union([Schema2.Number, Schema2.NumberFromString]).check(Schema2.isInt(), Schema2.isGreaterThanOrEqualTo(0))).pipe(Schema2.decodeTo(Schema2.Int.check(Schema2.isGreaterThanOrEqualTo(0)), {
|
|
128
|
+
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
129
|
+
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
130
|
+
})),
|
|
131
|
+
pageSize: Schema2.optional(Schema2.Union([Schema2.Number, Schema2.NumberFromString]).check(Schema2.isInt(), Schema2.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema2.decodeTo(Schema2.Int.check(Schema2.isBetween({ minimum: 1, maximum: 100 })), {
|
|
132
|
+
decode: SchemaGetter.withDefault(Effect.succeed(20)),
|
|
133
|
+
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
|
|
134
|
+
})),
|
|
135
|
+
globalFilter: Schema2.optional(Schema2.String),
|
|
136
|
+
sort: Schema2.optional(SortParams)
|
|
137
|
+
}).annotate({
|
|
138
|
+
identifier: "Query",
|
|
139
|
+
title: "Query",
|
|
140
|
+
description: "Zero-based page request parameters with optional filtering and sorting for list endpoints.",
|
|
141
|
+
examples: [
|
|
142
|
+
{
|
|
143
|
+
page: 0,
|
|
144
|
+
pageSize: 20,
|
|
145
|
+
globalFilter: "housing",
|
|
146
|
+
sort: [
|
|
147
|
+
{ id: "publicName", direction: "desc" },
|
|
148
|
+
{ id: "createdAt", direction: "asc" }
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
});
|
|
153
|
+
var QueryStandard = Schema2.toStandardSchemaV1(Query);
|
|
154
|
+
var PaginationMeta = Schema2.Struct({
|
|
155
|
+
page: Schema2.Int,
|
|
156
|
+
pageSize: Schema2.Int,
|
|
157
|
+
total: Schema2.Int,
|
|
158
|
+
pageCount: Schema2.Int
|
|
159
|
+
}).pipe(Schema2.annotate({
|
|
160
|
+
identifier: "PaginationMeta",
|
|
161
|
+
title: "Pagination Metadata",
|
|
162
|
+
description: "Pagination metadata returned with a paginated list response.",
|
|
163
|
+
examples: [{ page: 0, pageSize: 20, total: 125, pageCount: 7 }]
|
|
164
|
+
}));
|
|
165
|
+
|
|
166
|
+
// ../../src/services/events/schema.ts
|
|
167
|
+
var EventUuid = Schema3.String.check(Schema3.isUUID());
|
|
168
|
+
var EventId = Schema3.NonEmptyString.check(Schema3.isMaxLength(100));
|
|
169
|
+
var BrowserEventPath = Schema3.String.check(Schema3.isMaxLength(2048), Schema3.isPattern(/^\/(?!\/)[^?#]*$/));
|
|
170
|
+
var EventIdentity = Schema3.Struct({
|
|
171
|
+
userId: Schema3.optional(Schema3.NonEmptyString),
|
|
172
|
+
organizationId: Schema3.optional(Schema3.NonEmptyString)
|
|
173
|
+
}).annotate({ identifier: "EventIdentity" });
|
|
174
|
+
var EventIpAddress = Schema3.String.check(Schema3.makeFilter((value) => Option2.isSome(Schema3.decodeUnknownOption(Schema3.IpAddressFromString)(value)) || "Invalid IP address")).annotate({ identifier: "EventIpAddress" });
|
|
175
|
+
var EventCountry = Schema3.String.check(Schema3.isPattern(/^[A-Z]{2}$/), Schema3.makeFilter((value) => !["XX", "T1"].includes(value) || "Unknown country")).annotate({ identifier: "EventCountry" });
|
|
176
|
+
var EventRegion = Schema3.String.check(Schema3.isPattern(/^[A-Z0-9]{1,3}$/)).annotate({ identifier: "EventRegion" });
|
|
177
|
+
var EventCity = Schema3.NonEmptyString.check(Schema3.isMaxLength(128)).annotate({ identifier: "EventCity" });
|
|
178
|
+
var EventGeolocation = Schema3.Struct({
|
|
179
|
+
ip: Schema3.optional(EventIpAddress),
|
|
180
|
+
country: Schema3.optional(EventCountry),
|
|
181
|
+
region: Schema3.optional(EventRegion),
|
|
182
|
+
city: Schema3.optional(EventCity)
|
|
183
|
+
}).annotate({ identifier: "EventGeolocation" });
|
|
184
|
+
|
|
185
|
+
class EventGeolocationError extends Schema3.TaggedError()("EventGeolocationError", {}) {
|
|
186
|
+
}
|
|
187
|
+
var BrowserEventOptions = Schema3.Struct({
|
|
188
|
+
messageId: Schema3.optional(EventId),
|
|
189
|
+
timestamp: Schema3.optional(Schema3.DateTimeUtc),
|
|
190
|
+
context: Schema3.optional(EventAttributesSchema)
|
|
191
|
+
}).annotate({ identifier: "BrowserEventOptions" });
|
|
192
|
+
var BrowserPage = Schema3.Struct({
|
|
193
|
+
name: Schema3.optional(Schema3.NonEmptyString),
|
|
194
|
+
category: Schema3.optional(Schema3.NonEmptyString),
|
|
195
|
+
path: Schema3.optional(Schema3.NonEmptyString),
|
|
196
|
+
properties: Schema3.optional(EventAttributesSchema),
|
|
197
|
+
options: Schema3.optional(BrowserEventOptions)
|
|
198
|
+
}).annotate({ identifier: "BrowserPage" });
|
|
199
|
+
var AuditTarget = Schema3.Struct({
|
|
200
|
+
id: Schema3.NonEmptyString.check(Schema3.isMaxLength(256)),
|
|
201
|
+
name: Schema3.NonEmptyString.check(Schema3.isMaxLength(2048)),
|
|
202
|
+
type: Schema3.NonEmptyString.check(Schema3.isMaxLength(128))
|
|
203
|
+
}).annotate({ identifier: "AuditTarget" });
|
|
204
|
+
var trackEventFields = {
|
|
205
|
+
eventId: Schema3.optional(EventId),
|
|
206
|
+
name: Schema3.NonEmptyString.check(Schema3.isMaxLength(128)),
|
|
207
|
+
properties: Schema3.optional(EventAttributesSchema),
|
|
208
|
+
identity: Schema3.optional(EventIdentity),
|
|
209
|
+
timestamp: Schema3.optional(Schema3.DateTimeUtc)
|
|
210
|
+
};
|
|
211
|
+
var TrackEvent = Schema3.Union([
|
|
212
|
+
Schema3.Struct({
|
|
213
|
+
...trackEventFields,
|
|
214
|
+
category: Schema3.optional(Schema3.Literal("analytics"))
|
|
215
|
+
}),
|
|
216
|
+
Schema3.Struct({
|
|
217
|
+
...trackEventFields,
|
|
218
|
+
category: Schema3.Literal("audit"),
|
|
219
|
+
target: AuditTarget
|
|
220
|
+
})
|
|
221
|
+
]).annotate({ identifier: "TrackEvent" });
|
|
222
|
+
var ListAudit = Schema3.Struct({
|
|
223
|
+
organizationId: Schema3.NonEmptyString,
|
|
224
|
+
...Query.fields
|
|
225
|
+
}).annotate({ identifier: "ListAudit" });
|
|
226
|
+
var AuditSortId = Schema3.Literals([
|
|
227
|
+
"time",
|
|
228
|
+
"eventName",
|
|
229
|
+
"recordType",
|
|
230
|
+
"record",
|
|
231
|
+
"actorType",
|
|
232
|
+
"actorId"
|
|
233
|
+
]).annotate({ identifier: "AuditSortId" });
|
|
234
|
+
var AuditCount = Schema3.Struct({ total: Schema3.Int }).annotate({
|
|
235
|
+
identifier: "AuditCount"
|
|
236
|
+
});
|
|
237
|
+
var AuditAttribution = Schema3.Struct({
|
|
238
|
+
"app.actor.type": Schema3.NonEmptyString,
|
|
239
|
+
"app.actor.id": Schema3.NonEmptyString
|
|
240
|
+
}).annotate({ identifier: "AuditAttribution" });
|
|
241
|
+
var RequestActorAttribution = Schema3.Struct({
|
|
242
|
+
...AuditAttribution.fields,
|
|
243
|
+
"app.auth.method": Schema3.optional(Schema3.NonEmptyString),
|
|
244
|
+
"app.auth.credential.id": Schema3.optional(Schema3.NonEmptyString),
|
|
245
|
+
"app.auth.impersonator.id": Schema3.optional(Schema3.NonEmptyString),
|
|
246
|
+
"user.roles": Schema3.optional(Schema3.Array(Schema3.String))
|
|
247
|
+
}).annotate({ identifier: "RequestActorAttribution" });
|
|
248
|
+
|
|
249
|
+
class EventsPersistenceError extends Schema3.TaggedError()("EventsPersistenceError", { operation: Schema3.String }) {
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
class EventConflictError extends Schema3.TaggedError()("EventConflictError", { eventId: EventId }) {
|
|
253
|
+
}
|
|
254
|
+
var EventSource = Schema3.Literals(["browser", "server"]).annotate({
|
|
255
|
+
identifier: "EventSource"
|
|
256
|
+
});
|
|
257
|
+
var ExistingEventRequest = Schema3.Struct({
|
|
258
|
+
eventId: EventId,
|
|
259
|
+
source: EventSource
|
|
260
|
+
}).annotate({ identifier: "ExistingEventRequest" });
|
|
261
|
+
var StoredEventRequest = Schema3.Struct({
|
|
262
|
+
source: EventSource,
|
|
263
|
+
event_id: EventId,
|
|
264
|
+
event_name: Schema3.NonEmptyString,
|
|
265
|
+
event_type: Schema3.Literals(["page", "track"]),
|
|
266
|
+
occurred_at: Schema3.Finite,
|
|
267
|
+
received_at: Schema3.Finite,
|
|
268
|
+
organization_id: Schema3.NullOr(Schema3.NonEmptyString),
|
|
269
|
+
user_id: Schema3.NullOr(Schema3.NonEmptyString),
|
|
270
|
+
session_id: Schema3.NullOr(Schema3.NonEmptyString),
|
|
271
|
+
anonymous_id: Schema3.NullOr(Schema3.NonEmptyString),
|
|
272
|
+
payload_json: Schema3.String
|
|
273
|
+
}).annotate({ identifier: "StoredEventRequest" });
|
|
274
|
+
var StoredEventId = Schema3.Struct({
|
|
275
|
+
event_id: EventId
|
|
276
|
+
}).annotate({ identifier: "StoredEventId" });
|
|
277
|
+
var PrimitiveValue = Schema3.Union([
|
|
278
|
+
Schema3.Struct({ stringValue: Schema3.String.check(Schema3.isMaxLength(2048)) }),
|
|
279
|
+
Schema3.Struct({
|
|
280
|
+
intValue: Schema3.Union([
|
|
281
|
+
Schema3.String.check(Schema3.isPattern(/^-?\d{1,20}$/)),
|
|
282
|
+
Schema3.Int
|
|
283
|
+
])
|
|
284
|
+
}),
|
|
285
|
+
Schema3.Struct({ doubleValue: Schema3.Finite }),
|
|
286
|
+
Schema3.Struct({ boolValue: Schema3.Boolean })
|
|
287
|
+
]);
|
|
288
|
+
var AttributeValue = Schema3.Union([
|
|
289
|
+
PrimitiveValue,
|
|
290
|
+
Schema3.Struct({
|
|
291
|
+
arrayValue: Schema3.Struct({
|
|
292
|
+
values: Schema3.Array(PrimitiveValue).check(Schema3.isMaxLength(32))
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
]);
|
|
296
|
+
var EventAttribute = Schema3.Struct({
|
|
297
|
+
key: Schema3.NonEmptyString.check(Schema3.isMaxLength(128)),
|
|
298
|
+
value: AttributeValue
|
|
299
|
+
}).annotate({ identifier: "EventAttribute" });
|
|
300
|
+
var EventLogRecord = Schema3.Struct({
|
|
301
|
+
eventName: Schema3.NonEmptyString.check(Schema3.isMaxLength(128), Schema3.isPattern(/^[^\r\n]+$/)),
|
|
302
|
+
timeUnixNano: Schema3.String.check(Schema3.isPattern(/^\d{1,20}$/)),
|
|
303
|
+
observedTimeUnixNano: Schema3.optional(Schema3.String.check(Schema3.isPattern(/^\d{1,20}$/))),
|
|
304
|
+
severityNumber: Schema3.optional(Schema3.Int),
|
|
305
|
+
traceId: Schema3.optional(Schema3.String.check(Schema3.isPattern(/^[a-f0-9]{32}$/))),
|
|
306
|
+
spanId: Schema3.optional(Schema3.String.check(Schema3.isPattern(/^[a-f0-9]{16}$/))),
|
|
307
|
+
attributes: Schema3.Array(EventAttribute).check(Schema3.isMaxLength(64), Schema3.makeFilter((values) => new Set(values.map(({ key }) => key)).size === values.length || "Duplicate attribute keys"))
|
|
308
|
+
}).annotate({ identifier: "EventLogRecord" });
|
|
309
|
+
var extensions = Schema3.Record(Schema3.String, Schema3.Unknown);
|
|
310
|
+
var OtlpLogs = Schema3.StructWithRest(Schema3.Struct({
|
|
311
|
+
resourceLogs: Schema3.Array(Schema3.StructWithRest(Schema3.Struct({
|
|
312
|
+
scopeLogs: Schema3.Array(Schema3.StructWithRest(Schema3.Struct({
|
|
313
|
+
scope: Schema3.optional(Schema3.StructWithRest(Schema3.Struct({ name: Schema3.optional(Schema3.String) }), [extensions])),
|
|
314
|
+
logRecords: Schema3.Array(Schema3.Unknown).pipe(Schema3.withDecodingDefaultKey(Effect2.succeed([])))
|
|
315
|
+
}), [extensions])).pipe(Schema3.withDecodingDefaultKey(Effect2.succeed([])))
|
|
316
|
+
}), [extensions])).pipe(Schema3.withDecodingDefaultKey(Effect2.succeed([])))
|
|
317
|
+
}), [extensions]).annotate({ identifier: "EventsOtlpLogs" });
|
|
318
|
+
var StoredEventPayload = Schema3.Struct({
|
|
319
|
+
payload_json: Schema3.Union([OtlpLogs, Schema3.fromJsonString(OtlpLogs)])
|
|
320
|
+
}).annotate({ identifier: "StoredEventPayload" });
|
|
321
|
+
var VisitorEventsRequest = Schema3.Struct({
|
|
322
|
+
visitorId: Schema3.NonEmptyString
|
|
323
|
+
}).annotate({ identifier: "VisitorEventsRequest" });
|
|
324
|
+
var VisitorEventSession = Schema3.Struct({
|
|
325
|
+
event_id: EventId,
|
|
326
|
+
session_id: Schema3.NullOr(Schema3.NonEmptyString),
|
|
327
|
+
received_at: Schema3.Finite
|
|
328
|
+
}).annotate({ identifier: "VisitorEventSession" });
|
|
329
|
+
export {
|
|
330
|
+
AuditAttribution,
|
|
331
|
+
AuditCount,
|
|
332
|
+
AuditSortId,
|
|
333
|
+
AuditTarget,
|
|
334
|
+
BrowserEventOptions,
|
|
335
|
+
BrowserEventPath,
|
|
336
|
+
BrowserPage,
|
|
337
|
+
EventAttribute,
|
|
338
|
+
EventCity,
|
|
339
|
+
EventConflictError,
|
|
340
|
+
EventCountry,
|
|
341
|
+
EventGeolocation,
|
|
342
|
+
EventGeolocationError,
|
|
343
|
+
EventId,
|
|
344
|
+
EventIdentity,
|
|
345
|
+
EventIpAddress,
|
|
346
|
+
EventLogRecord,
|
|
347
|
+
EventRegion,
|
|
348
|
+
EventSource,
|
|
349
|
+
EventUuid,
|
|
350
|
+
EventsPersistenceError,
|
|
351
|
+
ExistingEventRequest,
|
|
352
|
+
ListAudit,
|
|
353
|
+
OtlpLogs,
|
|
354
|
+
RequestActorAttribution,
|
|
355
|
+
StoredEventId,
|
|
356
|
+
StoredEventPayload,
|
|
357
|
+
StoredEventRequest,
|
|
358
|
+
TrackEvent,
|
|
359
|
+
VisitorEventSession,
|
|
360
|
+
VisitorEventsRequest
|
|
361
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,18 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
+
"./events/client": {
|
|
21
|
+
"types": "./dist/services/events/client/audit-log-table.d.ts",
|
|
22
|
+
"import": "./dist/services/events/client/audit-log-table.js"
|
|
23
|
+
},
|
|
24
|
+
"./events/schema": {
|
|
25
|
+
"types": "./dist/services/events/schema.d.ts",
|
|
26
|
+
"import": "./dist/services/events/schema.js"
|
|
27
|
+
},
|
|
28
|
+
"./events/record": {
|
|
29
|
+
"types": "./dist/services/events/record.d.ts",
|
|
30
|
+
"import": "./dist/services/events/record.js"
|
|
31
|
+
},
|
|
20
32
|
"./events": {
|
|
21
33
|
"types": "./dist/services/events/index.d.ts",
|
|
22
34
|
"import": "./dist/services/events/index.js"
|