@krak-stack/registry 0.1.54 → 0.1.56
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 +31 -0
- package/dist/components/ui/error-component.js +10 -6
- package/dist/components/ui/form.d.ts +5 -5
- package/dist/lib/docs.js +2 -1
- package/dist/services/agent/client/index.js +3 -1
- package/dist/services/agent/index.d.ts +2 -2
- package/dist/services/agent/index.js +3 -1
- package/dist/services/events/browser.js +18 -7
- package/dist/services/events/client/audit-log-table.d.ts +17 -12
- package/dist/services/events/client/audit-log-table.js +71 -17
- package/dist/services/events/client/tracking-notice.js +2 -1
- package/dist/services/events/index.d.ts +16 -12
- package/dist/services/events/index.js +28 -30
- package/dist/services/events/schema.d.ts +51 -1
- package/dist/services/events/schema.js +12 -4
- package/dist/services/opentelemetry/web-vitals.js +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Merge the error component's homepage link classes with `cn` so its outline border is visible instead of being overridden by the base transparent border.
|
|
8
|
+
|
|
9
|
+
## 0.1.56
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Upgrade to Effect 4.1.0 and use Effect crypto services for UUIDv7 entity IDs, hashing, and secure capability generation. Preserve existing deterministic fingerprints and random upload capability tokens.
|
|
14
|
+
- d3000ed: Use exact matching for documentation sidebar links so Introduction is only highlighted on its own page.
|
|
15
|
+
|
|
16
|
+
## 0.1.55
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 9ec74fb: Default the activity history dateTime column to America/New_York, expose a timeZone override, and use Activity history titles in English and French.
|
|
21
|
+
|
|
22
|
+
Display event-time OpenTelemetry user.full_name, user.name, user.email and user.id attributes in activity history without resolving or linking Auth profiles. Preserve those trusted server annotations for audit events, while omitting them from analytics. Remove the separate actors prop.
|
|
23
|
+
|
|
24
|
+
Replace Events.listAudit / ListAudit with Events.list / ListEvents and require an explicit audit or analytics category. Preserve server pagination and service/tenant isolation; audit results remain restricted to server events.
|
|
25
|
+
|
|
26
|
+
Support an optional exact eventName filter, combined with category and search before counting and pagination.
|
|
27
|
+
|
|
28
|
+
Add an Action dropdown with a filter icon as the first toolbar menu in controlled AuditLogTable instances. Accept an application-owned events catalog of { value, label } options, use the labels in both the dropdown and Action column, and include All actions to clear the selection. Reset pagination when the event changes and preserve it across table query updates. Export EventQuery and EventQueryStandard for shared table and route state.
|
|
29
|
+
|
|
30
|
+
Display recorded target names with type and ID as secondary text. For older events whose target name is missing or duplicates the ID, show the target type above the ID instead. Target names remain event-time snapshots, not current entity lookups.
|
|
31
|
+
|
|
32
|
+
Migration required: replace Events.listAudit with Events.list({ ...query, organizationId, category: "audit" }), replace ListAudit with ListEvents, remove AuditActor/actors wiring, and use EventQuery / EventQueryStandard through API, client, and route query state to preserve eventName. Populate events with the full application event catalog and localized labels. Existing events are not backfilled.
|
|
33
|
+
|
|
3
34
|
## 0.1.54
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
|
@@ -289,10 +289,13 @@ var ErrorComponent = ({
|
|
|
289
289
|
...messages?.[locale.split("-")[0] ?? locale],
|
|
290
290
|
...messages?.[locale]
|
|
291
291
|
}), [locale, messages]);
|
|
292
|
-
const
|
|
292
|
+
const standardError = error instanceof Error ? error : undefined;
|
|
293
|
+
const errorName = standardError?.name ?? labels.errorLabel;
|
|
294
|
+
const errorMessage = standardError?.message.trim() || labels.description;
|
|
295
|
+
const reference = diagnostics?.reference ?? (standardError ? getErrorTraceId(standardError) : undefined);
|
|
293
296
|
const report = useMemo(() => [
|
|
294
|
-
`${labels.errorLabel}: ${
|
|
295
|
-
`${labels.messageLabel}: ${
|
|
297
|
+
`${labels.errorLabel}: ${errorName}`,
|
|
298
|
+
`${labels.messageLabel}: ${errorMessage}`,
|
|
296
299
|
"",
|
|
297
300
|
`${labels.pageLabel}: ${pathname}`,
|
|
298
301
|
`${labels.timeLabel}: ${new Date().toISOString()}`,
|
|
@@ -302,7 +305,8 @@ var ErrorComponent = ({
|
|
|
302
305
|
...reference ? [`${labels.referenceLabel}: ${reference}`] : []
|
|
303
306
|
].join(`
|
|
304
307
|
`), [
|
|
305
|
-
|
|
308
|
+
errorName,
|
|
309
|
+
errorMessage,
|
|
306
310
|
pathname,
|
|
307
311
|
locale,
|
|
308
312
|
labels,
|
|
@@ -328,7 +332,7 @@ var ErrorComponent = ({
|
|
|
328
332
|
})
|
|
329
333
|
}),
|
|
330
334
|
/* @__PURE__ */ jsx5(EmptyDescription, {
|
|
331
|
-
children:
|
|
335
|
+
children: errorMessage
|
|
332
336
|
})
|
|
333
337
|
]
|
|
334
338
|
}),
|
|
@@ -348,7 +352,7 @@ var ErrorComponent = ({
|
|
|
348
352
|
}),
|
|
349
353
|
/* @__PURE__ */ jsx5(Link, {
|
|
350
354
|
to: "/",
|
|
351
|
-
className: buttonVariants({ variant: "outline" }),
|
|
355
|
+
className: cn(buttonVariants({ variant: "outline" })),
|
|
352
356
|
children: labels.home
|
|
353
357
|
})
|
|
354
358
|
]
|
|
@@ -103,7 +103,7 @@ export declare const FieldWrapper: ({ children, legend, localized, description,
|
|
|
103
103
|
value: string;
|
|
104
104
|
}[];
|
|
105
105
|
}) => JSX.Element;
|
|
106
|
-
declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/
|
|
106
|
+
declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TSubmitMeta>(props: import("@tanstack/form-core").FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
107
107
|
readonly TextField: ({ children, ...props }: React.ComponentProps<"input"> & DefaultOptions) => JSX.Element;
|
|
108
108
|
readonly TextAreaField: ({ children, ...props }: React.ComponentProps<"textarea"> & DefaultOptions) => JSX.Element;
|
|
109
109
|
readonly SelectField: ({ description, label, multiple, options, placeholder, }: SelectFieldProps) => JSX.Element;
|
|
@@ -160,7 +160,7 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
160
160
|
locale?: string;
|
|
161
161
|
messages?: FormMessageTranslations;
|
|
162
162
|
}) => JSX.Element;
|
|
163
|
-
}>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/
|
|
163
|
+
}>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TSubmitMeta, TRenderProps extends object = {}>({ render, props, }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
164
164
|
readonly TextField: ({ children, ...props }: React.ComponentProps<"input"> & DefaultOptions) => JSX.Element;
|
|
165
165
|
readonly TextAreaField: ({ children, ...props }: React.ComponentProps<"textarea"> & DefaultOptions) => JSX.Element;
|
|
166
166
|
readonly SelectField: ({ description, label, multiple, options, placeholder, }: SelectFieldProps) => JSX.Element;
|
|
@@ -218,7 +218,7 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
218
218
|
messages?: FormMessageTranslations;
|
|
219
219
|
}) => JSX.Element;
|
|
220
220
|
}, TRenderProps>) => import("react").FunctionComponent<import("react").PropsWithChildren<NoInfer<[unknown] extends [TRenderProps] ? any : TRenderProps> & {
|
|
221
|
-
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/
|
|
221
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
|
|
222
222
|
readonly TextField: ({ children, ...props }: React.ComponentProps<"input"> & DefaultOptions) => JSX.Element;
|
|
223
223
|
readonly TextAreaField: ({ children, ...props }: React.ComponentProps<"textarea"> & DefaultOptions) => JSX.Element;
|
|
224
224
|
readonly SelectField: ({ description, label, multiple, options, placeholder, }: SelectFieldProps) => JSX.Element;
|
|
@@ -333,8 +333,8 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
333
333
|
locale?: string;
|
|
334
334
|
messages?: FormMessageTranslations;
|
|
335
335
|
}) => JSX.Element;
|
|
336
|
-
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/
|
|
337
|
-
form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/
|
|
336
|
+
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/form-core").DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import("@tanstack/form-core").FieldsMap<TFormData, TFieldGroupData>, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TFormSubmitMeta>(params: import("react").PropsWithChildren<NoInfer<TRenderProps> & {
|
|
337
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/form-core").FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
338
338
|
readonly TextField: ({ children, ...props }: React.ComponentProps<"input"> & DefaultOptions) => JSX.Element;
|
|
339
339
|
readonly TextAreaField: ({ children, ...props }: React.ComponentProps<"textarea"> & DefaultOptions) => JSX.Element;
|
|
340
340
|
readonly SelectField: ({ description, label, multiple, options, placeholder, }: SelectFieldProps) => JSX.Element;
|
package/dist/lib/docs.js
CHANGED
|
@@ -2184,7 +2184,8 @@ var DocsLayout = ({
|
|
|
2184
2184
|
items: section.pages.map((item) => {
|
|
2185
2185
|
const navItem = {
|
|
2186
2186
|
label: () => item.title,
|
|
2187
|
-
href: item.path
|
|
2187
|
+
href: item.path,
|
|
2188
|
+
exact: true
|
|
2188
2189
|
};
|
|
2189
2190
|
const ItemIcon = iconFor(docs.icons, item.icon);
|
|
2190
2191
|
if (ItemIcon)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// ../../src/services/agent/client/atom.ts
|
|
2
|
+
import { SecureRandom } from "effect/crypto";
|
|
2
3
|
import { Effect, Layer, Option, Schema, Stream } from "effect";
|
|
3
4
|
import { Atom } from "effect/reactivity";
|
|
5
|
+
var random = Effect.runSync(SecureRandom.SecureRandom.pipe(Effect.provide(SecureRandom.layerWebCrypto)));
|
|
4
6
|
var initialAgentState = {
|
|
5
7
|
context: undefined,
|
|
6
8
|
contextLocked: false,
|
|
@@ -103,7 +105,7 @@ var makeAgentAtoms = ({
|
|
|
103
105
|
const messages = submitAction.type === "message" ? [
|
|
104
106
|
...current.messages,
|
|
105
107
|
{
|
|
106
|
-
id:
|
|
108
|
+
id: Effect.runSync(random.uuidV7()),
|
|
107
109
|
role: "user",
|
|
108
110
|
text: submitAction.text,
|
|
109
111
|
tools: []
|
|
@@ -66,7 +66,7 @@ declare const AgentService_base: Context.ServiceClass<AgentService, "AgentServic
|
|
|
66
66
|
code: "stream-failed";
|
|
67
67
|
} | {
|
|
68
68
|
type: "finish";
|
|
69
|
-
}, never, Exclude<Tool.
|
|
69
|
+
}, never, Exclude<Tool.Requirements<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.ResultDecodingServices<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.SchemaServices<Tools[keyof Tools]>, LanguageModel.LanguageModel>>, AgentHistoryError | Schema.SchemaError, LanguageModel.LanguageModel>;
|
|
70
70
|
}> & {
|
|
71
71
|
readonly make: Effect.Effect<{
|
|
72
72
|
stream: <Tools extends Record<string, Tool.Any>>(args_0: AgentStreamOptions<Tools>) => Effect.Effect<Stream.Stream<{
|
|
@@ -122,7 +122,7 @@ declare const AgentService_base: Context.ServiceClass<AgentService, "AgentServic
|
|
|
122
122
|
code: "stream-failed";
|
|
123
123
|
} | {
|
|
124
124
|
type: "finish";
|
|
125
|
-
}, never, Exclude<Tool.
|
|
125
|
+
}, never, Exclude<Tool.Requirements<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.ResultDecodingServices<Tools[keyof Tools]>, LanguageModel.LanguageModel> | Exclude<Tool.SchemaServices<Tools[keyof Tools]>, LanguageModel.LanguageModel>>, AgentHistoryError | Schema.SchemaError, LanguageModel.LanguageModel>;
|
|
126
126
|
}, never, never>;
|
|
127
127
|
};
|
|
128
128
|
export declare class AgentService extends AgentService_base {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// ../../src/services/agent/index.ts
|
|
2
|
+
import { SecureRandom } from "effect/crypto";
|
|
2
3
|
import {
|
|
3
4
|
Context,
|
|
4
5
|
Data,
|
|
@@ -98,6 +99,7 @@ var decodeAgentStreamErrorDetails = Schema.decodeUnknownOption(AgentStreamErrorD
|
|
|
98
99
|
|
|
99
100
|
class AgentService extends Context.Service()("AgentService", {
|
|
100
101
|
make: Effect.gen(function* () {
|
|
102
|
+
const random = yield* SecureRandom.SecureRandom.pipe(Effect.provide(SecureRandom.layerWebCrypto));
|
|
101
103
|
const streamErrorDetails = (error) => {
|
|
102
104
|
const details = Option.getOrUndefined(decodeAgentStreamErrorDetails(error));
|
|
103
105
|
if (!details)
|
|
@@ -238,7 +240,7 @@ class AgentService extends Context.Service()("AgentService", {
|
|
|
238
240
|
});
|
|
239
241
|
const stream = Effect.fn("AgentService.stream")(function* ({ action, history, systemPrompt, toolkit }) {
|
|
240
242
|
const model = yield* LanguageModel.LanguageModel;
|
|
241
|
-
const messageId =
|
|
243
|
+
const messageId = yield* random.uuidV7();
|
|
242
244
|
const conversation = history ? yield* Chat.fromJson(history) : yield* Chat.fromPrompt([{ role: "system", content: systemPrompt }]);
|
|
243
245
|
yield* Ref.update(conversation.history, Prompt.setSystem(systemPrompt));
|
|
244
246
|
if (action.type === "approval") {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// ../../src/services/events/browser.ts
|
|
2
|
+
import { SecureRandom as SecureRandom2 } from "effect/crypto";
|
|
3
|
+
|
|
1
4
|
// ../../src/services/opentelemetry/events.ts
|
|
2
5
|
import {
|
|
3
6
|
Clock,
|
|
@@ -144,6 +147,7 @@ var event = Effect.fnUntraced(function* (name, properties, options) {
|
|
|
144
147
|
import { Context as Context2, Effect as Effect5, FiberSet, Layer as Layer2, Option as Option5, Schema as Schema6 } from "effect";
|
|
145
148
|
|
|
146
149
|
// ../../src/services/opentelemetry/consent.ts
|
|
150
|
+
import { SecureRandom } from "effect/crypto";
|
|
147
151
|
import { Effect as Effect2, Option as Option2, Schema as Schema3 } from "effect";
|
|
148
152
|
var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
|
|
149
153
|
var ANALYTICS_NOTICE_VERSION = "1";
|
|
@@ -197,7 +201,7 @@ var saveAnalyticsPreference = (choice) => {
|
|
|
197
201
|
const issuedAt = Date.now();
|
|
198
202
|
const value = Schema3.encodeSync(codec)({
|
|
199
203
|
choice,
|
|
200
|
-
revision:
|
|
204
|
+
revision: Effect2.runSync(SecureRandom.SecureRandom.use((random) => random.uuidV7()).pipe(Effect2.provide(SecureRandom.layerWebCrypto))),
|
|
201
205
|
version: ANALYTICS_NOTICE_VERSION,
|
|
202
206
|
issuedAt,
|
|
203
207
|
expiresAt: issuedAt + lifetime
|
|
@@ -407,10 +411,16 @@ var TrackEvent = Schema5.Union([
|
|
|
407
411
|
target: AuditTarget
|
|
408
412
|
})
|
|
409
413
|
]).annotate({ identifier: "TrackEvent" });
|
|
410
|
-
var
|
|
414
|
+
var EventQuery = Schema5.Struct({
|
|
415
|
+
...Query.fields,
|
|
416
|
+
eventName: Schema5.optional(trackEventFields.name)
|
|
417
|
+
}).annotate({ identifier: "EventQuery" });
|
|
418
|
+
var EventQueryStandard = Schema5.toStandardSchemaV1(EventQuery);
|
|
419
|
+
var ListEvents = Schema5.Struct({
|
|
411
420
|
organizationId: Schema5.NonEmptyString,
|
|
412
|
-
|
|
413
|
-
|
|
421
|
+
category: Schema5.Literals(["audit", "analytics"]),
|
|
422
|
+
...EventQuery.fields
|
|
423
|
+
}).annotate({ identifier: "ListEvents" });
|
|
414
424
|
var AuditSortId = Schema5.Literals([
|
|
415
425
|
"time",
|
|
416
426
|
"eventName",
|
|
@@ -631,20 +641,21 @@ class BrowserEvents {
|
|
|
631
641
|
locale,
|
|
632
642
|
sanitizePath
|
|
633
643
|
} = {}) => {
|
|
644
|
+
const random = Effect5.runSync(SecureRandom2.SecureRandom.pipe(Effect5.provide(SecureRandom2.layerWebCrypto)));
|
|
634
645
|
const allowed = () => enabled && (!respectDoNotTrack || !browserPrivacyEnabled()) && (!requireConsent || analyticsAllowed());
|
|
635
646
|
let previousPath;
|
|
636
|
-
let pageViewId =
|
|
647
|
+
let pageViewId = Effect5.runSync(random.uuidV7());
|
|
637
648
|
const context = (name, properties) => {
|
|
638
649
|
const explicitPath = Schema6.decodeUnknownOption(Schema6.String)(properties?.["url.path"]);
|
|
639
650
|
const path = Option5.getOrElse(explicitPath, () => location.pathname);
|
|
640
651
|
if (location.pathname !== previousPath || name === "browser.page_view") {
|
|
641
652
|
previousPath = location.pathname;
|
|
642
|
-
pageViewId =
|
|
653
|
+
pageViewId = Effect5.runSync(random.uuidV7());
|
|
643
654
|
}
|
|
644
655
|
const attributes = {
|
|
645
656
|
"app.event.schema.version": "1",
|
|
646
657
|
"analytics.page_view.id": pageViewId,
|
|
647
|
-
"log.record.uid":
|
|
658
|
+
"log.record.uid": Effect5.runSync(random.uuidV7()),
|
|
648
659
|
"url.path": sanitizePath?.(path) ?? path,
|
|
649
660
|
"browser.language": navigator.language.slice(0, 256)
|
|
650
661
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import { type
|
|
3
|
-
import type { EventLogRecord } from "../schema.js";
|
|
2
|
+
import { type DataTableStatus } from "../../../components/ui/data-table.js";
|
|
3
|
+
import type { EventLogRecord, EventQuery } from "../schema.js";
|
|
4
4
|
declare const translations: {
|
|
5
5
|
en: {
|
|
6
6
|
title: string;
|
|
7
|
+
event: string;
|
|
8
|
+
allEvents: string;
|
|
7
9
|
time: string;
|
|
8
10
|
action: string;
|
|
9
11
|
target: string;
|
|
@@ -18,6 +20,8 @@ declare const translations: {
|
|
|
18
20
|
};
|
|
19
21
|
fr: {
|
|
20
22
|
title: string;
|
|
23
|
+
event: string;
|
|
24
|
+
allEvents: string;
|
|
21
25
|
time: string;
|
|
22
26
|
action: string;
|
|
23
27
|
target: string;
|
|
@@ -32,22 +36,23 @@ declare const translations: {
|
|
|
32
36
|
};
|
|
33
37
|
};
|
|
34
38
|
export type AuditLogMessages = typeof translations.en;
|
|
35
|
-
export type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
export type AuditLogTableProps = DataTableStatus & {
|
|
40
|
+
/** Full application-owned event catalog, with localized display labels. */
|
|
41
|
+
events?: readonly {
|
|
42
|
+
value: string;
|
|
43
|
+
label: string;
|
|
44
|
+
}[];
|
|
45
|
+
state?: EventQuery;
|
|
46
|
+
onStateChange?: (state: EventQuery) => void;
|
|
40
47
|
entries: readonly EventLogRecord[];
|
|
41
48
|
/** Total matching records from the query response; paging lives in state. */
|
|
42
49
|
rowCount: number;
|
|
50
|
+
/** Display time zone for the dateTime column. Defaults to America/New_York. */
|
|
51
|
+
timeZone?: string;
|
|
43
52
|
/** Overrides the shared KrakstackProvider locale when supplied. */
|
|
44
53
|
locale?: string;
|
|
45
54
|
messages?: Readonly<Record<string, Partial<AuditLogMessages>>>;
|
|
46
|
-
/** Current profiles the viewer may access. Matched by type and ID, including user impersonators.
|
|
47
|
-
* Missing profiles use neutral labels: the list may be loading, incomplete, or unavailable.
|
|
48
|
-
*/
|
|
49
|
-
actors?: readonly AuditActor[];
|
|
50
55
|
renderAction?: (entry: EventLogRecord) => ReactNode;
|
|
51
56
|
};
|
|
52
|
-
export declare const AuditLogTable: ({ entries, rowCount, locale: localeOverride, messages,
|
|
57
|
+
export declare const AuditLogTable: ({ entries, events, rowCount, timeZone, locale: localeOverride, messages, renderAction, state, onStateChange, ...status }: AuditLogTableProps) => import("react").JSX.Element;
|
|
53
58
|
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// ../../src/services/events/client/audit-log-table.tsx
|
|
2
|
+
import { ListFilterIcon } from "lucide-react";
|
|
3
|
+
|
|
1
4
|
// ../../src/components/ui/data-table.tsx
|
|
2
5
|
import { useAtom, useAtomSet } from "@effect/atom-react";
|
|
3
6
|
import { BrowserKeyValueStore } from "@effect/platform-browser";
|
|
@@ -3501,7 +3504,9 @@ var eventTextAttribute = (record, key) => Schema2.decodeUnknownOption(TextValue)
|
|
|
3501
3504
|
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3502
3505
|
var translations = {
|
|
3503
3506
|
en: {
|
|
3504
|
-
title: "
|
|
3507
|
+
title: "Activity history",
|
|
3508
|
+
event: "Action",
|
|
3509
|
+
allEvents: "All actions",
|
|
3505
3510
|
time: "Time",
|
|
3506
3511
|
action: "Action",
|
|
3507
3512
|
target: "Target",
|
|
@@ -3515,7 +3520,9 @@ var translations = {
|
|
|
3515
3520
|
methodUnknown: "Unknown"
|
|
3516
3521
|
},
|
|
3517
3522
|
fr: {
|
|
3518
|
-
title: "
|
|
3523
|
+
title: "Historique d’activité",
|
|
3524
|
+
event: "Action",
|
|
3525
|
+
allEvents: "Toutes les actions",
|
|
3519
3526
|
time: "Date",
|
|
3520
3527
|
action: "Action",
|
|
3521
3528
|
target: "Cible",
|
|
@@ -3531,10 +3538,11 @@ var translations = {
|
|
|
3531
3538
|
};
|
|
3532
3539
|
var AuditLogTable = ({
|
|
3533
3540
|
entries,
|
|
3541
|
+
events = [],
|
|
3534
3542
|
rowCount,
|
|
3543
|
+
timeZone = "America/New_York",
|
|
3535
3544
|
locale: localeOverride,
|
|
3536
3545
|
messages,
|
|
3537
|
-
actors = [],
|
|
3538
3546
|
renderAction,
|
|
3539
3547
|
state,
|
|
3540
3548
|
onStateChange,
|
|
@@ -3552,18 +3560,20 @@ var AuditLogTable = ({
|
|
|
3552
3560
|
["session", labels.methodSession],
|
|
3553
3561
|
["api_key", labels.methodApiKey]
|
|
3554
3562
|
]);
|
|
3555
|
-
const actorsByKey = new Map(actors.map((actor) => [`${actor.type}:${actor.id}`, actor]));
|
|
3556
3563
|
const getActor = (entry) => {
|
|
3557
3564
|
const type = eventTextAttribute(entry, "app.actor.type");
|
|
3558
|
-
const id = eventTextAttribute(entry, "app.actor.id");
|
|
3559
|
-
const actor = actorsByKey.get(`${type}:${id}`);
|
|
3560
|
-
if (actor)
|
|
3561
|
-
return actor;
|
|
3565
|
+
const id = eventTextAttribute(entry, "app.actor.id") ?? eventTextAttribute(entry, "user.id");
|
|
3562
3566
|
if (type === "organization") {
|
|
3563
3567
|
return { label: labels.actorOrganization, description: id };
|
|
3564
3568
|
}
|
|
3565
|
-
if (type === "user") {
|
|
3566
|
-
|
|
3569
|
+
if (type === "user" || eventTextAttribute(entry, "user.id") !== null) {
|
|
3570
|
+
const fullName = eventTextAttribute(entry, "user.full_name");
|
|
3571
|
+
const name = eventTextAttribute(entry, "user.name");
|
|
3572
|
+
const email = eventTextAttribute(entry, "user.email");
|
|
3573
|
+
return {
|
|
3574
|
+
label: fullName || name || email || labels.actorMember,
|
|
3575
|
+
description: fullName || name ? email || id : id
|
|
3576
|
+
};
|
|
3567
3577
|
}
|
|
3568
3578
|
return { label: type ?? labels.actor, description: id };
|
|
3569
3579
|
};
|
|
@@ -3572,12 +3582,13 @@ var AuditLogTable = ({
|
|
|
3572
3582
|
colId: "time",
|
|
3573
3583
|
headerName: labels.time,
|
|
3574
3584
|
type: "dateTime",
|
|
3585
|
+
typeOptions: { timeZone },
|
|
3575
3586
|
valueGetter: ({ data }) => new Date(Number(BigInt(data.timeUnixNano) / 1000000n))
|
|
3576
3587
|
},
|
|
3577
3588
|
{
|
|
3578
3589
|
field: "eventName",
|
|
3579
3590
|
headerName: labels.action,
|
|
3580
|
-
cellRenderer: ({ data }) => renderAction?.(data) ?? data.eventName
|
|
3591
|
+
cellRenderer: ({ data }) => renderAction?.(data) ?? events.find((event) => event.value === data.eventName)?.label ?? data.eventName
|
|
3581
3592
|
},
|
|
3582
3593
|
{
|
|
3583
3594
|
colId: "record",
|
|
@@ -3588,9 +3599,10 @@ var AuditLogTable = ({
|
|
|
3588
3599
|
getItem: (entry) => {
|
|
3589
3600
|
const id = eventTextAttribute(entry, "app.audit.target.id");
|
|
3590
3601
|
const name = eventTextAttribute(entry, "app.audit.target.name");
|
|
3602
|
+
const type = eventTextAttribute(entry, "app.audit.target.type");
|
|
3591
3603
|
return id === null ? null : {
|
|
3592
|
-
label: name ||
|
|
3593
|
-
description: name && name !== id ? id :
|
|
3604
|
+
label: name && name !== id ? name : type || labels.target,
|
|
3605
|
+
description: name && name !== id && type ? `${type} · ${id}` : id
|
|
3594
3606
|
};
|
|
3595
3607
|
}
|
|
3596
3608
|
}
|
|
@@ -3615,9 +3627,8 @@ var AuditLogTable = ({
|
|
|
3615
3627
|
className: "text-muted-foreground text-xs",
|
|
3616
3628
|
children: [
|
|
3617
3629
|
labels.impersonatedBy,
|
|
3618
|
-
":",
|
|
3619
|
-
|
|
3620
|
-
actorsByKey.get(`user:${impersonatorId}`)?.label ?? impersonatorId
|
|
3630
|
+
": ",
|
|
3631
|
+
impersonatorId
|
|
3621
3632
|
]
|
|
3622
3633
|
}) : null
|
|
3623
3634
|
]
|
|
@@ -3636,12 +3647,55 @@ var AuditLogTable = ({
|
|
|
3636
3647
|
];
|
|
3637
3648
|
return /* @__PURE__ */ jsx15("section", {
|
|
3638
3649
|
"aria-label": labels.title,
|
|
3650
|
+
className: "flex flex-col gap-4",
|
|
3639
3651
|
children: /* @__PURE__ */ jsx15(DataTable, {
|
|
3640
3652
|
locale,
|
|
3641
3653
|
status,
|
|
3642
3654
|
state,
|
|
3643
|
-
onStateChange
|
|
3655
|
+
onStateChange: onStateChange ? (next) => onStateChange({
|
|
3656
|
+
...next,
|
|
3657
|
+
eventName: state?.eventName
|
|
3658
|
+
}) : undefined,
|
|
3644
3659
|
features: {
|
|
3660
|
+
toolbar: state && onStateChange ? {
|
|
3661
|
+
items: /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
3662
|
+
children: [
|
|
3663
|
+
/* @__PURE__ */ jsxs9(MenubarTrigger, {
|
|
3664
|
+
children: [
|
|
3665
|
+
/* @__PURE__ */ jsx15(ListFilterIcon, {
|
|
3666
|
+
"aria-hidden": "true",
|
|
3667
|
+
"data-icon": "inline-start"
|
|
3668
|
+
}),
|
|
3669
|
+
labels.event,
|
|
3670
|
+
state.eventName ? `: ${events.find((event) => event.value === state.eventName)?.label ?? state.eventName}` : ""
|
|
3671
|
+
]
|
|
3672
|
+
}),
|
|
3673
|
+
/* @__PURE__ */ jsx15(MenubarContent, {
|
|
3674
|
+
className: "w-80",
|
|
3675
|
+
children: /* @__PURE__ */ jsxs9(MenubarGroup, {
|
|
3676
|
+
children: [
|
|
3677
|
+
/* @__PURE__ */ jsx15(MenubarItem, {
|
|
3678
|
+
onClick: () => onStateChange({
|
|
3679
|
+
...state,
|
|
3680
|
+
eventName: undefined,
|
|
3681
|
+
page: 0
|
|
3682
|
+
}),
|
|
3683
|
+
children: labels.allEvents
|
|
3684
|
+
}),
|
|
3685
|
+
events.map((event) => /* @__PURE__ */ jsx15(MenubarItem, {
|
|
3686
|
+
onClick: () => onStateChange({
|
|
3687
|
+
...state,
|
|
3688
|
+
eventName: event.value,
|
|
3689
|
+
page: 0
|
|
3690
|
+
}),
|
|
3691
|
+
children: event.label
|
|
3692
|
+
}, event.value))
|
|
3693
|
+
]
|
|
3694
|
+
})
|
|
3695
|
+
})
|
|
3696
|
+
]
|
|
3697
|
+
})
|
|
3698
|
+
} : false,
|
|
3645
3699
|
pagination: { mode: "server", rowCount }
|
|
3646
3700
|
},
|
|
3647
3701
|
columnDefs: columns,
|
|
@@ -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:
|
|
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,
|
|
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";
|
|
@@ -6,7 +6,7 @@ import { OtlpEvents } from "../opentelemetry/events.js";
|
|
|
6
6
|
import { EventIdentity, EventGeolocation, EventConflictError, EventsPersistenceError } from "./schema.js";
|
|
7
7
|
export declare const SESSION_TIMEOUT_MS: number;
|
|
8
8
|
export type { EventGeolocation } from "./schema.js";
|
|
9
|
-
export { AuditTarget, TrackEvent, EventLogRecord,
|
|
9
|
+
export { AuditTarget, TrackEvent, EventLogRecord, ListEvents } from "./schema.js";
|
|
10
10
|
export type EventGeolocationResolver = (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<EventGeolocation | null, unknown>;
|
|
11
11
|
export interface EventsOptions {
|
|
12
12
|
/** Enforce the shared browser preference for ingestion and request-scoped analytics. */
|
|
@@ -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,
|
|
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,8 +70,8 @@ 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 |
|
|
74
|
-
|
|
73
|
+
}, EventConflictError | EventsPersistenceError | Schema.SchemaError, never>;
|
|
74
|
+
list: (input: {
|
|
75
75
|
readonly page?: string | number | undefined;
|
|
76
76
|
readonly pageSize?: string | number | undefined;
|
|
77
77
|
readonly globalFilter?: string | undefined;
|
|
@@ -79,7 +79,9 @@ 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 eventName?: string | undefined;
|
|
82
83
|
readonly organizationId: string;
|
|
84
|
+
readonly category: "analytics" | "audit";
|
|
83
85
|
}) => Effect.Effect<{
|
|
84
86
|
data: {
|
|
85
87
|
readonly eventName: string;
|
|
@@ -158,8 +160,8 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
158
160
|
}) => Effect.Effect<{
|
|
159
161
|
eventId: string;
|
|
160
162
|
inserted: boolean;
|
|
161
|
-
}, EventConflictError | EventsPersistenceError |
|
|
162
|
-
|
|
163
|
+
}, EventConflictError | EventsPersistenceError | Schema.SchemaError, never>;
|
|
164
|
+
list: (input: {
|
|
163
165
|
readonly page?: string | number | undefined;
|
|
164
166
|
readonly pageSize?: string | number | undefined;
|
|
165
167
|
readonly globalFilter?: string | undefined;
|
|
@@ -167,7 +169,9 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
167
169
|
readonly id: string;
|
|
168
170
|
readonly direction: "asc" | "desc";
|
|
169
171
|
}[] | undefined;
|
|
172
|
+
readonly eventName?: string | undefined;
|
|
170
173
|
readonly organizationId: string;
|
|
174
|
+
readonly category: "analytics" | "audit";
|
|
171
175
|
}) => Effect.Effect<{
|
|
172
176
|
data: {
|
|
173
177
|
readonly eventName: string;
|
|
@@ -208,14 +212,14 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
208
212
|
pageCount: number;
|
|
209
213
|
};
|
|
210
214
|
}, EventsPersistenceError | import("effect/Cause").NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
|
|
211
|
-
}, EventsConfigurationError,
|
|
215
|
+
}, EventsConfigurationError, Otlp | OtlpEvents>;
|
|
212
216
|
};
|
|
213
217
|
export declare class Events extends Events_base {
|
|
214
218
|
/** Missing options resolve from APP_SECRET, VITE_SITE_URL and Otlp. */
|
|
215
|
-
static readonly baseLayerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError,
|
|
216
|
-
static readonly baseLayer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError,
|
|
219
|
+
static readonly baseLayerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError, Otlp | OtlpEvents>;
|
|
220
|
+
static readonly baseLayer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError, Otlp | OtlpEvents>;
|
|
217
221
|
/** An injected PostgreSQL/SQLite SqlClient enables persistence and the initial migration. */
|
|
218
|
-
static readonly layerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError,
|
|
219
|
-
static readonly layer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError,
|
|
222
|
+
static readonly layerWith: (options?: Partial<EventsOptions>) => Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Otlp | OtlpEvents>;
|
|
223
|
+
static readonly layer: Layer.Layer<Events, Config.ConfigError | EventsConfigurationError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Otlp | OtlpEvents>;
|
|
220
224
|
static readonly ingestionLayer: Layer.Layer<OtlpLogsProcessor, never, Events>;
|
|
221
225
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Config as Config2,
|
|
4
4
|
Context as Context4,
|
|
5
|
-
Crypto,
|
|
6
5
|
DateTime as DateTime2,
|
|
7
6
|
Effect as Effect8,
|
|
8
7
|
Layer as Layer3,
|
|
@@ -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";
|
|
@@ -395,10 +395,16 @@ var TrackEvent = Schema6.Union([
|
|
|
395
395
|
target: AuditTarget
|
|
396
396
|
})
|
|
397
397
|
]).annotate({ identifier: "TrackEvent" });
|
|
398
|
-
var
|
|
398
|
+
var EventQuery = Schema6.Struct({
|
|
399
|
+
...Query.fields,
|
|
400
|
+
eventName: Schema6.optional(trackEventFields.name)
|
|
401
|
+
}).annotate({ identifier: "EventQuery" });
|
|
402
|
+
var EventQueryStandard = Schema6.toStandardSchemaV1(EventQuery);
|
|
403
|
+
var ListEvents = Schema6.Struct({
|
|
399
404
|
organizationId: Schema6.NonEmptyString,
|
|
400
|
-
|
|
401
|
-
|
|
405
|
+
category: Schema6.Literals(["audit", "analytics"]),
|
|
406
|
+
...EventQuery.fields
|
|
407
|
+
}).annotate({ identifier: "ListEvents" });
|
|
402
408
|
var AuditSortId = Schema6.Literals([
|
|
403
409
|
"time",
|
|
404
410
|
"eventName",
|
|
@@ -570,6 +576,7 @@ var migrateEvents = Migrator.make({})({
|
|
|
570
576
|
});
|
|
571
577
|
|
|
572
578
|
// ../../src/services/opentelemetry/consent.ts
|
|
579
|
+
import { SecureRandom } from "effect/crypto";
|
|
573
580
|
import { Effect as Effect7, Option as Option5, Schema as Schema8 } from "effect";
|
|
574
581
|
var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
|
|
575
582
|
var ANALYTICS_NOTICE_VERSION = "1";
|
|
@@ -650,15 +657,15 @@ var eventContent = (record, source, compareTimestamp = source === "browser") =>
|
|
|
650
657
|
].includes(key) || key === "user.id" || key === "organization.id").sort((a, b) => a.key.localeCompare(b.key))
|
|
651
658
|
});
|
|
652
659
|
var dailyVisitorId = Effect8.fnUntraced(function* (input) {
|
|
653
|
-
const
|
|
660
|
+
const digestService = yield* Digest.Digest.pipe(Effect8.provide(Digest.layerWebCrypto));
|
|
654
661
|
const encoder = new TextEncoder;
|
|
655
|
-
const salt = yield*
|
|
662
|
+
const salt = yield* digestService.digest(Digest.sha256, encoder.encode(JSON.stringify([
|
|
656
663
|
"analytics.visitor.salt.v2",
|
|
657
664
|
Redacted.value(input.secret),
|
|
658
665
|
input.serviceName,
|
|
659
666
|
input.day
|
|
660
667
|
])));
|
|
661
|
-
const digest = yield*
|
|
668
|
+
const digest = yield* digestService.digest(Digest.sha256, encoder.encode(JSON.stringify([
|
|
662
669
|
"analytics.visitor.v2",
|
|
663
670
|
input.serviceName,
|
|
664
671
|
input.day,
|
|
@@ -671,7 +678,7 @@ var dailyVisitorId = Effect8.fnUntraced(function* (input) {
|
|
|
671
678
|
|
|
672
679
|
class Events extends Context4.Service()("krakstack/events/Events", {
|
|
673
680
|
make: (options) => Effect8.gen(function* () {
|
|
674
|
-
const
|
|
681
|
+
const random = yield* SecureRandom2.SecureRandom.pipe(Effect8.provide(SecureRandom2.layerWebCrypto));
|
|
675
682
|
const telemetry = yield* Otlp;
|
|
676
683
|
const exporter = yield* OtlpEvents;
|
|
677
684
|
const resource = options.serviceName ? yield* OtlpResource3.fromConfig({ serviceName: options.serviceName }) : yield* telemetry.resource;
|
|
@@ -770,12 +777,12 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
770
777
|
ip: location2.ip,
|
|
771
778
|
userAgent,
|
|
772
779
|
day: DateTime2.formatIsoDate(now)
|
|
773
|
-
})
|
|
780
|
+
}) : undefined;
|
|
774
781
|
let sessionId;
|
|
775
782
|
if (visitorId && storage) {
|
|
776
783
|
yield* storage.lockVisitor(visitorId);
|
|
777
784
|
const latest = yield* storage.latestSession({ visitorId });
|
|
778
|
-
sessionId = Option6.isSome(latest) && latest.value.received_at > DateTime2.toEpochMillis(now) - SESSION_TIMEOUT_MS ? latest.value.session_id : yield*
|
|
785
|
+
sessionId = Option6.isSome(latest) && latest.value.received_at > DateTime2.toEpochMillis(now) - SESSION_TIMEOUT_MS ? latest.value.session_id : yield* random.uuidV7();
|
|
779
786
|
}
|
|
780
787
|
const identity = {};
|
|
781
788
|
if (visitorId)
|
|
@@ -791,7 +798,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
791
798
|
});
|
|
792
799
|
const track = Effect8.fn("Events.track")(function* (input) {
|
|
793
800
|
const event = yield* Schema9.decodeUnknownEffect(TrackEvent)(input);
|
|
794
|
-
const eventId = event.eventId ?? (yield*
|
|
801
|
+
const eventId = event.eventId ?? (yield* random.uuidV7());
|
|
795
802
|
const category = event.category ?? "analytics";
|
|
796
803
|
const receivedAt = yield* DateTime2.now;
|
|
797
804
|
const now = DateTime2.toEpochMillis(receivedAt);
|
|
@@ -819,7 +826,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
819
826
|
attributes[name] = value;
|
|
820
827
|
}
|
|
821
828
|
Object.assign(attributes, identityAttributes(identity));
|
|
822
|
-
Object.assign(attributes, Object.fromEntries(Object.entries(annotations).filter(([key]) =>
|
|
829
|
+
Object.assign(attributes, Object.fromEntries(Object.entries(annotations).filter(([key]) => (category === "audit" || !["user.full_name", "user.name", "user.email"].includes(key)) && key !== "user.image" && key !== "app.user.image")));
|
|
823
830
|
attributes["log.record.uid"] = eventId;
|
|
824
831
|
if (event.category === "audit") {
|
|
825
832
|
attributes["app.audit.target.id"] = event.target.id;
|
|
@@ -880,8 +887,8 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
880
887
|
operation: "track"
|
|
881
888
|
})));
|
|
882
889
|
});
|
|
883
|
-
const
|
|
884
|
-
const request = yield* Schema9.decodeUnknownEffect(
|
|
890
|
+
const list = Effect8.fn("Events.list")(function* (input) {
|
|
891
|
+
const request = yield* Schema9.decodeUnknownEffect(ListEvents)(input);
|
|
885
892
|
if (!storage)
|
|
886
893
|
return yield* new EventsPersistenceError({
|
|
887
894
|
operation: "persistence-disabled"
|
|
@@ -908,17 +915,8 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
908
915
|
const id = yield* Schema9.decodeUnknownEffect(AuditSortId)(part.id);
|
|
909
916
|
return sql`${sortColumns[id]} ${sql.literal(part.direction === "desc" ? "DESC" : "ASC")}`;
|
|
910
917
|
}));
|
|
911
|
-
const category = sql
|
|
912
|
-
|
|
913
|
-
orElse: () => sql`EXISTS (
|
|
914
|
-
SELECT 1 FROM json_each(payload_json, '$.resourceLogs') AS resource,
|
|
915
|
-
json_each(resource.value, '$.scopeLogs') AS scope,
|
|
916
|
-
json_each(scope.value, '$.logRecords') AS record,
|
|
917
|
-
json_each(record.value, '$.attributes') AS attribute
|
|
918
|
-
WHERE json_extract(attribute.value, '$.key') = 'app.event.category'
|
|
919
|
-
AND json_extract(attribute.value, '$.value.stringValue') = 'audit'
|
|
920
|
-
)`
|
|
921
|
-
});
|
|
918
|
+
const source = request.category === "audit" ? sql`AND source = 'server'` : sql``;
|
|
919
|
+
const event = request.eventName ? sql`AND event_name = ${request.eventName}` : sql``;
|
|
922
920
|
const search = request.globalFilter?.trim();
|
|
923
921
|
const filter = search ? sql`AND ${sql.or([
|
|
924
922
|
sql`LOWER(event_name) LIKE ${`%${search.toLowerCase()}%`}`,
|
|
@@ -932,14 +930,14 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
932
930
|
].map((key) => sql`LOWER(${text(key)}) LIKE ${`%${search.toLowerCase()}%`}`)
|
|
933
931
|
])}` : sql``;
|
|
934
932
|
const predicate = sql`service_name = ${configuration.serviceName} AND organization_id = ${request.organizationId}
|
|
935
|
-
AND
|
|
933
|
+
AND ${text("app.event.category")} = ${request.category} ${source} ${event} ${filter}`;
|
|
936
934
|
const total = yield* SqlSchema.findOne({
|
|
937
|
-
Request:
|
|
935
|
+
Request: ListEvents,
|
|
938
936
|
Result: AuditCount,
|
|
939
937
|
execute: () => sql`SELECT CAST(COUNT(*) AS INTEGER) AS total FROM events WHERE ${predicate}`
|
|
940
938
|
})(request);
|
|
941
939
|
const find = SqlSchema.findAll({
|
|
942
|
-
Request:
|
|
940
|
+
Request: ListEvents,
|
|
943
941
|
Result: StoredEventPayload,
|
|
944
942
|
execute: () => sql`
|
|
945
943
|
SELECT payload_json FROM events
|
|
@@ -1092,7 +1090,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
1092
1090
|
status: error._tag === "EventConflictError" ? 409 : 503
|
|
1093
1091
|
})));
|
|
1094
1092
|
});
|
|
1095
|
-
return { process, track,
|
|
1093
|
+
return { process, track, list };
|
|
1096
1094
|
})
|
|
1097
1095
|
}) {
|
|
1098
1096
|
static baseLayerWith = (options = {}) => Layer3.effect(this, Effect8.gen(function* () {
|
|
@@ -1124,7 +1122,7 @@ export {
|
|
|
1124
1122
|
EventLogRecord,
|
|
1125
1123
|
Events,
|
|
1126
1124
|
EventsConfigurationError,
|
|
1127
|
-
|
|
1125
|
+
ListEvents,
|
|
1128
1126
|
SESSION_TIMEOUT_MS,
|
|
1129
1127
|
TrackEvent,
|
|
1130
1128
|
dailyVisitorId
|
|
@@ -72,7 +72,7 @@ export declare const TrackEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
72
72
|
}>;
|
|
73
73
|
}>]>;
|
|
74
74
|
export type TrackEvent = typeof TrackEvent.Type;
|
|
75
|
-
export declare const
|
|
75
|
+
export declare const EventQuery: Schema.Struct<{
|
|
76
76
|
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
77
77
|
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
78
78
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
@@ -83,7 +83,57 @@ export declare const ListAudit: Schema.Struct<{
|
|
|
83
83
|
readonly id: string;
|
|
84
84
|
readonly direction: "asc" | "desc";
|
|
85
85
|
}[]>>;
|
|
86
|
+
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
87
|
+
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
88
|
+
}>;
|
|
89
|
+
export type EventQuery = typeof EventQuery.Type;
|
|
90
|
+
export declare const EventQueryStandard: import("effect/StandardSchema").StandardSchemaV1<{
|
|
91
|
+
readonly page?: string | number | undefined;
|
|
92
|
+
readonly pageSize?: string | number | undefined;
|
|
93
|
+
readonly globalFilter?: string | undefined;
|
|
94
|
+
readonly sort?: readonly {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly direction: "asc" | "desc";
|
|
97
|
+
}[] | undefined;
|
|
98
|
+
readonly eventName?: string | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
readonly page: number;
|
|
101
|
+
readonly pageSize: number;
|
|
102
|
+
readonly globalFilter?: string | undefined;
|
|
103
|
+
readonly sort?: readonly {
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly direction: "asc" | "desc";
|
|
106
|
+
}[] | undefined;
|
|
107
|
+
readonly eventName?: string | undefined;
|
|
108
|
+
}> & Schema.Struct<{
|
|
109
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
110
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
111
|
+
readonly globalFilter: Schema.optional<Schema.String>;
|
|
112
|
+
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
113
|
+
readonly id: string;
|
|
114
|
+
readonly direction: "asc" | "desc";
|
|
115
|
+
}[], readonly {
|
|
116
|
+
readonly id: string;
|
|
117
|
+
readonly direction: "asc" | "desc";
|
|
118
|
+
}[]>>;
|
|
119
|
+
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
120
|
+
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
121
|
+
}>;
|
|
122
|
+
export declare const ListEvents: Schema.Struct<{
|
|
123
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
124
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
125
|
+
readonly globalFilter: Schema.optional<Schema.String>;
|
|
126
|
+
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
127
|
+
readonly id: string;
|
|
128
|
+
readonly direction: "asc" | "desc";
|
|
129
|
+
}[], readonly {
|
|
130
|
+
readonly id: string;
|
|
131
|
+
readonly direction: "asc" | "desc";
|
|
132
|
+
}[]>>;
|
|
133
|
+
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
134
|
+
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
86
135
|
readonly organizationId: Schema.NonEmptyString;
|
|
136
|
+
readonly category: Schema.Literals<readonly ["audit", "analytics"]>;
|
|
87
137
|
}>;
|
|
88
138
|
export declare const AuditSortId: Schema.Literals<readonly ["time", "eventName", "recordType", "record", "actorType", "actorId"]>;
|
|
89
139
|
export declare const AuditCount: Schema.Struct<{
|
|
@@ -229,10 +229,16 @@ var TrackEvent = Schema3.Union([
|
|
|
229
229
|
target: AuditTarget
|
|
230
230
|
})
|
|
231
231
|
]).annotate({ identifier: "TrackEvent" });
|
|
232
|
-
var
|
|
232
|
+
var EventQuery = Schema3.Struct({
|
|
233
|
+
...Query.fields,
|
|
234
|
+
eventName: Schema3.optional(trackEventFields.name)
|
|
235
|
+
}).annotate({ identifier: "EventQuery" });
|
|
236
|
+
var EventQueryStandard = Schema3.toStandardSchemaV1(EventQuery);
|
|
237
|
+
var ListEvents = Schema3.Struct({
|
|
233
238
|
organizationId: Schema3.NonEmptyString,
|
|
234
|
-
|
|
235
|
-
|
|
239
|
+
category: Schema3.Literals(["audit", "analytics"]),
|
|
240
|
+
...EventQuery.fields
|
|
241
|
+
}).annotate({ identifier: "ListEvents" });
|
|
236
242
|
var AuditSortId = Schema3.Literals([
|
|
237
243
|
"time",
|
|
238
244
|
"eventName",
|
|
@@ -354,12 +360,14 @@ export {
|
|
|
354
360
|
EventIdentity,
|
|
355
361
|
EventIpAddress,
|
|
356
362
|
EventLogRecord,
|
|
363
|
+
EventQuery,
|
|
364
|
+
EventQueryStandard,
|
|
357
365
|
EventRegion,
|
|
358
366
|
EventSource,
|
|
359
367
|
EventUuid,
|
|
360
368
|
EventsPersistenceError,
|
|
361
369
|
ExistingEventRequest,
|
|
362
|
-
|
|
370
|
+
ListEvents,
|
|
363
371
|
OtlpLogs,
|
|
364
372
|
RequestActorAttribution,
|
|
365
373
|
StoredEventId,
|
|
@@ -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.
|
|
3
|
+
"version": "0.1.56",
|
|
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.
|
|
275
|
-
"@effect/platform-browser": "^4.
|
|
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.
|
|
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"
|