@everscribe/components-core 0.1.0
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/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/index.cjs +661 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +286 -0
- package/dist/index.d.ts +286 -0
- package/dist/index.js +634 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
interface Event {
|
|
2
|
+
id: string;
|
|
3
|
+
tenant_id?: string;
|
|
4
|
+
occurred_at: string;
|
|
5
|
+
actor?: Record<string, unknown>;
|
|
6
|
+
action: string;
|
|
7
|
+
target?: Record<string, unknown>;
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
origin?: Record<string, unknown>;
|
|
10
|
+
result?: Record<string, unknown>;
|
|
11
|
+
change?: Record<string, unknown>;
|
|
12
|
+
idempotency_key?: string;
|
|
13
|
+
}
|
|
14
|
+
interface EmbedClaims {
|
|
15
|
+
v: number;
|
|
16
|
+
iss: string;
|
|
17
|
+
sub: string;
|
|
18
|
+
aud: string;
|
|
19
|
+
exp: number;
|
|
20
|
+
iat: number;
|
|
21
|
+
jti: string;
|
|
22
|
+
tenant_id?: string;
|
|
23
|
+
columns?: string[];
|
|
24
|
+
actions?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* actions_prefix is a list of action prefixes the token can read
|
|
27
|
+
* (e.g. ["user.", "billing."]). Server-enforced; the component
|
|
28
|
+
* uses it only when filtering the action dropdown.
|
|
29
|
+
*/
|
|
30
|
+
actions_prefix?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* allowed_fields restricts which catalog fields the token can
|
|
33
|
+
* use in DSL filters (and the NLP endpoint). When set, the
|
|
34
|
+
* Query and AI tabs constrain what the user can ask for; the
|
|
35
|
+
* server rejects out-of-scope fields independently.
|
|
36
|
+
*/
|
|
37
|
+
allowed_fields?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* allow_dsl_input toggles the Query (advanced DSL) tab. When
|
|
40
|
+
* false, the embed API also rejects ?q=... requests.
|
|
41
|
+
*/
|
|
42
|
+
allow_dsl_input?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* allow_nlp toggles the AI ("Ask in plain English") tab. When
|
|
45
|
+
* false, POST /v1/embed/events/nlp returns 403.
|
|
46
|
+
*/
|
|
47
|
+
allow_nlp?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* MetadataKey describes one entry in the project's metadata
|
|
51
|
+
* vocabulary side table - surfaced for the inline metadata-filter
|
|
52
|
+
* builder's autocomplete and the NLP context.
|
|
53
|
+
*/
|
|
54
|
+
interface MetadataKey {
|
|
55
|
+
key: string;
|
|
56
|
+
observed_type: string;
|
|
57
|
+
sample_value?: string;
|
|
58
|
+
event_count: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* ChangeField names a field that's been observed changing on
|
|
62
|
+
* mutation events. Drives the change-field picker autocomplete.
|
|
63
|
+
*/
|
|
64
|
+
interface ChangeField {
|
|
65
|
+
field: string;
|
|
66
|
+
event_count: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* GenerateNLPFiltersRequest is the JSON body for
|
|
70
|
+
* POST /v1/embed/events/nlp. Mirrors the server's NLP response shape.
|
|
71
|
+
*/
|
|
72
|
+
interface GenerateNLPFiltersRequest {
|
|
73
|
+
q: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* GenerateNLPFiltersResponse is the JSON shape returned by
|
|
77
|
+
* POST /v1/embed/events/nlp. DSL is empty when the model couldn't
|
|
78
|
+
* translate anything; the caller falls back to rendering the
|
|
79
|
+
* unsupported list.
|
|
80
|
+
*/
|
|
81
|
+
interface GenerateNLPFiltersResponse {
|
|
82
|
+
dsl: string;
|
|
83
|
+
unsupported?: string[];
|
|
84
|
+
explanation?: string;
|
|
85
|
+
model?: string;
|
|
86
|
+
input_tokens?: number;
|
|
87
|
+
output_tokens?: number;
|
|
88
|
+
cache_hit_tokens?: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type ApiErrorKind = 'unauthorized' | 'not_found' | 'rate_limited' | 'bad_request' | 'server' | 'network';
|
|
92
|
+
interface ApiErrorInfo {
|
|
93
|
+
kind: ApiErrorKind;
|
|
94
|
+
status?: number;
|
|
95
|
+
retryAfterMs?: number;
|
|
96
|
+
message?: string;
|
|
97
|
+
cause?: unknown;
|
|
98
|
+
}
|
|
99
|
+
declare class EmbedError extends Error {
|
|
100
|
+
readonly kind: ApiErrorKind;
|
|
101
|
+
readonly status?: number;
|
|
102
|
+
readonly retryAfterMs?: number;
|
|
103
|
+
constructor(info: ApiErrorInfo);
|
|
104
|
+
}
|
|
105
|
+
interface ListEventsResponse {
|
|
106
|
+
events: Event[];
|
|
107
|
+
next_cursor?: string;
|
|
108
|
+
}
|
|
109
|
+
interface GetEventResponse {
|
|
110
|
+
event: Event;
|
|
111
|
+
}
|
|
112
|
+
interface ListEventsParams {
|
|
113
|
+
limit?: number;
|
|
114
|
+
cursor?: string;
|
|
115
|
+
since?: string;
|
|
116
|
+
before?: string;
|
|
117
|
+
action?: string;
|
|
118
|
+
actor?: string;
|
|
119
|
+
actorType?: string;
|
|
120
|
+
tenantId?: string;
|
|
121
|
+
targetType?: string;
|
|
122
|
+
targetId?: string;
|
|
123
|
+
resultStatus?: string;
|
|
124
|
+
originIP?: string;
|
|
125
|
+
/**
|
|
126
|
+
* q is the Lucene-flavored DSL accepted by the embed events
|
|
127
|
+
* endpoint. Server rejects it (claim_error) when the token
|
|
128
|
+
* lacks allow_dsl_input.
|
|
129
|
+
*/
|
|
130
|
+
q?: string;
|
|
131
|
+
}
|
|
132
|
+
interface DistinctActionsResponse {
|
|
133
|
+
actions: string[];
|
|
134
|
+
}
|
|
135
|
+
interface DistinctActorTypesResponse {
|
|
136
|
+
actor_types: string[];
|
|
137
|
+
}
|
|
138
|
+
interface DistinctTargetTypesResponse {
|
|
139
|
+
target_types: string[];
|
|
140
|
+
}
|
|
141
|
+
interface DistinctTenantsResponse {
|
|
142
|
+
tenants: string[];
|
|
143
|
+
}
|
|
144
|
+
interface DistinctResultStatusesResponse {
|
|
145
|
+
statuses: string[];
|
|
146
|
+
}
|
|
147
|
+
interface MetadataKeysResponse {
|
|
148
|
+
keys: MetadataKey[];
|
|
149
|
+
}
|
|
150
|
+
interface ChangeFieldsResponse {
|
|
151
|
+
fields: ChangeField[];
|
|
152
|
+
}
|
|
153
|
+
type ExportFormat = 'csv' | 'json';
|
|
154
|
+
interface ExportEventsParams {
|
|
155
|
+
format: ExportFormat;
|
|
156
|
+
since?: string;
|
|
157
|
+
before?: string;
|
|
158
|
+
action?: string;
|
|
159
|
+
actor?: string;
|
|
160
|
+
actorType?: string;
|
|
161
|
+
tenantId?: string;
|
|
162
|
+
targetType?: string;
|
|
163
|
+
targetId?: string;
|
|
164
|
+
resultStatus?: string;
|
|
165
|
+
originIP?: string;
|
|
166
|
+
q?: string;
|
|
167
|
+
}
|
|
168
|
+
interface ExportEventsResult {
|
|
169
|
+
blob: Blob;
|
|
170
|
+
filename: string;
|
|
171
|
+
}
|
|
172
|
+
interface RequestOptions {
|
|
173
|
+
apiBase: string;
|
|
174
|
+
token: string;
|
|
175
|
+
signal?: AbortSignal;
|
|
176
|
+
}
|
|
177
|
+
declare function listEvents(opts: RequestOptions & {
|
|
178
|
+
params?: ListEventsParams;
|
|
179
|
+
}): Promise<ListEventsResponse>;
|
|
180
|
+
declare function getEvent(opts: RequestOptions & {
|
|
181
|
+
id: string;
|
|
182
|
+
}): Promise<GetEventResponse>;
|
|
183
|
+
declare function listDistinctActions(opts: RequestOptions): Promise<DistinctActionsResponse>;
|
|
184
|
+
declare function listDistinctActorTypes(opts: RequestOptions): Promise<DistinctActorTypesResponse>;
|
|
185
|
+
declare function listDistinctTargetTypes(opts: RequestOptions): Promise<DistinctTargetTypesResponse>;
|
|
186
|
+
declare function listDistinctTenants(opts: RequestOptions): Promise<DistinctTenantsResponse>;
|
|
187
|
+
declare function listDistinctResultStatuses(opts: RequestOptions): Promise<DistinctResultStatusesResponse>;
|
|
188
|
+
declare function listMetadataKeys(opts: RequestOptions): Promise<MetadataKeysResponse>;
|
|
189
|
+
declare function listChangeFields(opts: RequestOptions): Promise<ChangeFieldsResponse>;
|
|
190
|
+
declare function generateNLPFilters(opts: RequestOptions & {
|
|
191
|
+
query: string;
|
|
192
|
+
}): Promise<GenerateNLPFiltersResponse>;
|
|
193
|
+
declare function exportEvents(opts: RequestOptions & {
|
|
194
|
+
params: ExportEventsParams;
|
|
195
|
+
}): Promise<ExportEventsResult>;
|
|
196
|
+
interface TokenSourceOptions {
|
|
197
|
+
tokenEndpoint?: string;
|
|
198
|
+
onTokenExpired?: () => Promise<string>;
|
|
199
|
+
}
|
|
200
|
+
declare function fetchTokenViaOpts(opts: TokenSourceOptions): Promise<string | null>;
|
|
201
|
+
|
|
202
|
+
declare function decodeJwtPayload<T = unknown>(token: string): T;
|
|
203
|
+
|
|
204
|
+
declare function parseClaims(token: string | null | undefined): EmbedClaims | null;
|
|
205
|
+
|
|
206
|
+
type DiffKind = 'same' | 'removed' | 'added' | '';
|
|
207
|
+
interface DiffLine {
|
|
208
|
+
before: string;
|
|
209
|
+
after: string;
|
|
210
|
+
beforeKind: DiffKind;
|
|
211
|
+
afterKind: DiffKind;
|
|
212
|
+
}
|
|
213
|
+
interface DiffView {
|
|
214
|
+
lines: DiffLine[];
|
|
215
|
+
}
|
|
216
|
+
declare function renderDiff(change: unknown): DiffView;
|
|
217
|
+
declare function hasParseableDiff(change: unknown): boolean;
|
|
218
|
+
|
|
219
|
+
declare const COLUMN_LABELS: Record<string, string>;
|
|
220
|
+
declare const ALL_COLUMNS: string[];
|
|
221
|
+
|
|
222
|
+
declare function formatAbsolute(rfc3339: string): string;
|
|
223
|
+
declare function formatRelative(rfc3339: string, now: number): string;
|
|
224
|
+
declare function formatTimeCell(rfc3339: string, now: number): string;
|
|
225
|
+
declare const RELATIVE_TIME_TICK_MS = 30000;
|
|
226
|
+
|
|
227
|
+
type EventsStatus = 'loading' | 'ok' | 'error' | 'expired';
|
|
228
|
+
interface EventsStoreConfig {
|
|
229
|
+
apiBase: string;
|
|
230
|
+
token: string | null;
|
|
231
|
+
pageSize: number;
|
|
232
|
+
pollInterval: number;
|
|
233
|
+
tokenEndpoint?: string;
|
|
234
|
+
onTokenExpired?: () => Promise<string>;
|
|
235
|
+
onError?: (err: Error) => void;
|
|
236
|
+
since?: string;
|
|
237
|
+
before?: string;
|
|
238
|
+
action?: string;
|
|
239
|
+
actor?: string;
|
|
240
|
+
actorType?: string;
|
|
241
|
+
tenantId?: string;
|
|
242
|
+
targetType?: string;
|
|
243
|
+
targetId?: string;
|
|
244
|
+
resultStatus?: string;
|
|
245
|
+
originIP?: string;
|
|
246
|
+
q?: string;
|
|
247
|
+
}
|
|
248
|
+
interface EventsStoreState {
|
|
249
|
+
events: Event[];
|
|
250
|
+
nextCursor: string | null;
|
|
251
|
+
status: EventsStatus;
|
|
252
|
+
error: EmbedError | null;
|
|
253
|
+
}
|
|
254
|
+
interface EventsStore {
|
|
255
|
+
getSnapshot(): EventsStoreState;
|
|
256
|
+
subscribe(listener: () => void): () => void;
|
|
257
|
+
loadMore(): void;
|
|
258
|
+
refresh(): void;
|
|
259
|
+
dispose(): void;
|
|
260
|
+
}
|
|
261
|
+
declare function createEventsStore(config: EventsStoreConfig): EventsStore;
|
|
262
|
+
|
|
263
|
+
interface DistinctValues {
|
|
264
|
+
actions: string[];
|
|
265
|
+
actorTypes: string[];
|
|
266
|
+
targetTypes: string[];
|
|
267
|
+
tenants: string[];
|
|
268
|
+
resultStatuses: string[];
|
|
269
|
+
metadataKeys: MetadataKey[];
|
|
270
|
+
changeFields: ChangeField[];
|
|
271
|
+
}
|
|
272
|
+
interface DistinctValuesStoreConfig {
|
|
273
|
+
apiBase: string;
|
|
274
|
+
token: string | null;
|
|
275
|
+
tokenEndpoint?: string;
|
|
276
|
+
onTokenExpired?: () => Promise<string>;
|
|
277
|
+
}
|
|
278
|
+
interface DistinctValuesStore {
|
|
279
|
+
getSnapshot(): DistinctValues;
|
|
280
|
+
subscribe(listener: () => void): () => void;
|
|
281
|
+
dispose(): void;
|
|
282
|
+
}
|
|
283
|
+
declare const EMPTY_DISTINCT_VALUES: DistinctValues;
|
|
284
|
+
declare function createDistinctValuesStore(config: DistinctValuesStoreConfig): DistinctValuesStore;
|
|
285
|
+
|
|
286
|
+
export { ALL_COLUMNS, type ApiErrorInfo, type ApiErrorKind, COLUMN_LABELS, type ChangeField, type ChangeFieldsResponse, type DiffKind, type DiffLine, type DiffView, type DistinctActionsResponse, type DistinctActorTypesResponse, type DistinctResultStatusesResponse, type DistinctTargetTypesResponse, type DistinctTenantsResponse, type DistinctValues, type DistinctValuesStore, type DistinctValuesStoreConfig, EMPTY_DISTINCT_VALUES, type EmbedClaims, EmbedError, type Event, type EventsStatus, type EventsStore, type EventsStoreConfig, type EventsStoreState, type ExportEventsParams, type ExportEventsResult, type ExportFormat, type GenerateNLPFiltersRequest, type GenerateNLPFiltersResponse, type GetEventResponse, type ListEventsParams, type ListEventsResponse, type MetadataKey, type MetadataKeysResponse, RELATIVE_TIME_TICK_MS, type RequestOptions, type TokenSourceOptions, createDistinctValuesStore, createEventsStore, decodeJwtPayload, exportEvents, fetchTokenViaOpts, formatAbsolute, formatRelative, formatTimeCell, generateNLPFilters, getEvent, hasParseableDiff, listChangeFields, listDistinctActions, listDistinctActorTypes, listDistinctResultStatuses, listDistinctTargetTypes, listDistinctTenants, listEvents, listMetadataKeys, parseClaims, renderDiff };
|