@dyrected/core 2.12.0 → 2.13.1
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/dist/access-P6Z2XAFS.js +10 -0
- package/dist/ai-X3M2SE5A.js +17 -0
- package/dist/ai-tools-UPKJY3TX.js +14 -0
- package/dist/{app-config-C6hYM8WO.d.cts → app-De-3eNn1.d.cts} +476 -2
- package/dist/{app-config-C6hYM8WO.d.ts → app-De-3eNn1.d.ts} +476 -2
- package/dist/chunk-254THFDS.js +202 -0
- package/dist/chunk-27YRIGK5.js +1758 -0
- package/dist/chunk-4RAQJVJM.js +18 -0
- package/dist/chunk-HRRJ3RYT.js +70 -0
- package/dist/{chunk-VOE2LOLF.js → chunk-LYENW2EN.js} +280 -1760
- package/dist/chunk-W7GKJM2X.js +1136 -0
- package/dist/chunk-ZYYDTHF3.js +635 -0
- package/dist/index.cjs +518 -525
- package/dist/index.d.cts +91 -4
- package/dist/index.d.ts +91 -4
- package/dist/index.js +45 -2
- package/dist/rag.service-YDGEYTXS.js +11 -0
- package/dist/server.cjs +5004 -1391
- package/dist/server.d.cts +358 -328
- package/dist/server.d.ts +358 -328
- package/dist/server.js +2059 -267
- package/package.json +4 -1
- package/dist/chunk-FRSJJO27.js +0 -519
- package/dist/observability-HQF4EUSV.js +0 -35
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as hono_types from 'hono/types';
|
|
2
|
+
import { Context, Hono } from 'hono';
|
|
2
3
|
import { LoggerOptions, DestinationStream, Logger } from 'pino';
|
|
4
|
+
import { icons } from 'lucide-react';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { JWTPayload } from 'jose';
|
|
7
|
+
import { Tracer, Counter, Attributes, Histogram, Span } from '@opentelemetry/api';
|
|
8
|
+
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
|
|
3
9
|
|
|
4
10
|
/**
|
|
5
11
|
* Minimum HTTP request context passed to every server-side hook and resolver.
|
|
@@ -159,6 +165,287 @@ interface FileData {
|
|
|
159
165
|
[key: string]: unknown;
|
|
160
166
|
}
|
|
161
167
|
|
|
168
|
+
interface AIThread {
|
|
169
|
+
id: string;
|
|
170
|
+
projectId: string;
|
|
171
|
+
userId: string;
|
|
172
|
+
title?: string;
|
|
173
|
+
summary?: string;
|
|
174
|
+
createdAt: Date | string;
|
|
175
|
+
updatedAt: Date | string;
|
|
176
|
+
[key: string]: unknown;
|
|
177
|
+
}
|
|
178
|
+
interface AIMessage {
|
|
179
|
+
id: string;
|
|
180
|
+
threadId: string;
|
|
181
|
+
role: 'user' | 'assistant' | 'system';
|
|
182
|
+
content: string;
|
|
183
|
+
parts?: any[];
|
|
184
|
+
createdAt: Date | string;
|
|
185
|
+
metadata?: Record<string, unknown>;
|
|
186
|
+
[key: string]: unknown;
|
|
187
|
+
}
|
|
188
|
+
interface DyrectedAIContext {
|
|
189
|
+
project: {
|
|
190
|
+
name: string;
|
|
191
|
+
id: string;
|
|
192
|
+
};
|
|
193
|
+
globalPrompt?: string;
|
|
194
|
+
collections: Array<{
|
|
195
|
+
slug: string;
|
|
196
|
+
label?: string;
|
|
197
|
+
prompt?: string;
|
|
198
|
+
fields?: Array<{
|
|
199
|
+
name: string;
|
|
200
|
+
type: string;
|
|
201
|
+
required?: boolean;
|
|
202
|
+
}>;
|
|
203
|
+
}>;
|
|
204
|
+
globals: Array<{
|
|
205
|
+
slug: string;
|
|
206
|
+
label?: string;
|
|
207
|
+
prompt?: string;
|
|
208
|
+
}>;
|
|
209
|
+
user: {
|
|
210
|
+
name?: string;
|
|
211
|
+
role?: string;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
interface AIToolContext {
|
|
215
|
+
db: any;
|
|
216
|
+
user?: any;
|
|
217
|
+
projectId?: string;
|
|
218
|
+
config?: any;
|
|
219
|
+
}
|
|
220
|
+
interface AIToolDefinition<TParams = any, TResult = any> {
|
|
221
|
+
description: string;
|
|
222
|
+
inputSchema?: z.ZodType<TParams>;
|
|
223
|
+
parameters?: z.ZodType<TParams>;
|
|
224
|
+
execute: (args: TParams, context: AIToolContext) => Promise<TResult> | TResult;
|
|
225
|
+
}
|
|
226
|
+
interface GlobalRAGConfig {
|
|
227
|
+
/** Enable or disable automatic RAG indexing globally. Defaults to true. */
|
|
228
|
+
enabled?: boolean;
|
|
229
|
+
/** Embedding model identifier. Defaults to 'text-embedding-004' (Google) or 'text-embedding-3-small' (OpenAI/AgentRouter). */
|
|
230
|
+
embeddingModel?: string;
|
|
231
|
+
/** Default character budget per chunk. Defaults to 1500 (~375-500 tokens). */
|
|
232
|
+
maxChunkSize?: number;
|
|
233
|
+
/** Default character overlap between chunks. Defaults to 150. */
|
|
234
|
+
chunkOverlap?: number;
|
|
235
|
+
/** Default minimum cosine similarity score threshold (0.0 to 1.0). Defaults to 0.45. */
|
|
236
|
+
minScore?: number;
|
|
237
|
+
/** Default number of top snippets to retrieve. Defaults to 4. */
|
|
238
|
+
topK?: number;
|
|
239
|
+
}
|
|
240
|
+
interface CollectionRAGConfig {
|
|
241
|
+
/** Enable or disable RAG indexing for this collection. Defaults to true. */
|
|
242
|
+
enabled?: boolean;
|
|
243
|
+
/** Whitelist of specific field names to index. Defaults to all text/richText/textarea fields. */
|
|
244
|
+
fields?: string[];
|
|
245
|
+
/** Field to use for citation display titles (e.g. 'title', 'name', 'question'). */
|
|
246
|
+
titleField?: string;
|
|
247
|
+
/** Custom character budget per chunk for this collection. */
|
|
248
|
+
maxChunkSize?: number;
|
|
249
|
+
/** Custom character overlap between chunks for this collection. */
|
|
250
|
+
chunkOverlap?: number;
|
|
251
|
+
}
|
|
252
|
+
interface AIChunk {
|
|
253
|
+
id: string;
|
|
254
|
+
projectId: string;
|
|
255
|
+
collection: string;
|
|
256
|
+
documentId: string;
|
|
257
|
+
field: string;
|
|
258
|
+
chunkIndex: number;
|
|
259
|
+
text: string;
|
|
260
|
+
embedding: number[];
|
|
261
|
+
tokenCount: number;
|
|
262
|
+
contentHash: string;
|
|
263
|
+
metadata?: {
|
|
264
|
+
title?: string;
|
|
265
|
+
slug?: string;
|
|
266
|
+
locale?: string;
|
|
267
|
+
status?: string;
|
|
268
|
+
updatedAt?: Date | string;
|
|
269
|
+
[key: string]: unknown;
|
|
270
|
+
};
|
|
271
|
+
createdAt: Date | string;
|
|
272
|
+
updatedAt: Date | string;
|
|
273
|
+
[key: string]: unknown;
|
|
274
|
+
}
|
|
275
|
+
interface RAGSearchResult {
|
|
276
|
+
id: string;
|
|
277
|
+
collection: string;
|
|
278
|
+
documentId: string;
|
|
279
|
+
title: string;
|
|
280
|
+
field: string;
|
|
281
|
+
score: number;
|
|
282
|
+
text: string;
|
|
283
|
+
url: string;
|
|
284
|
+
metadata?: Record<string, unknown>;
|
|
285
|
+
}
|
|
286
|
+
interface AIRateLimitResult {
|
|
287
|
+
allowed: boolean;
|
|
288
|
+
remaining: number;
|
|
289
|
+
resetTimeSec: number;
|
|
290
|
+
retryAfter?: number;
|
|
291
|
+
}
|
|
292
|
+
interface AIRateLimitStore {
|
|
293
|
+
consume(key: string, limit: number, windowMs: number): Promise<AIRateLimitResult> | AIRateLimitResult;
|
|
294
|
+
}
|
|
295
|
+
interface AIConfig {
|
|
296
|
+
/** Master switch to enable/disable AI endpoints. Defaults to true. */
|
|
297
|
+
enabled?: boolean;
|
|
298
|
+
/** AI Provider to use. Defaults to 'google' or auto-detects from environment variables. */
|
|
299
|
+
provider?: 'google' | 'agentrouter' | 'openrouter' | 'openai' | 'custom';
|
|
300
|
+
/** Custom base URL for OpenAI-compatible gateways (e.g. https://agentrouter.org/v1). */
|
|
301
|
+
baseURL?: string;
|
|
302
|
+
/** Optional custom API key (or read from environment variables). */
|
|
303
|
+
apiKey?: string;
|
|
304
|
+
/** Global system prompt / brand persona instructions for the project. */
|
|
305
|
+
systemPrompt?: string;
|
|
306
|
+
/** Model to use for AI assistant. Defaults to 'gemini-2.0-flash' for Google or 'claude-3-haiku-20240307' for AgentRouter. */
|
|
307
|
+
model?: string;
|
|
308
|
+
/** Fallback model to use if primary model hits rate limits. */
|
|
309
|
+
fallbackModel?: string;
|
|
310
|
+
/** Maximum number of sequential tool execution steps per user message. Defaults to 5. */
|
|
311
|
+
maxSteps?: number;
|
|
312
|
+
/** Number of automatic retry attempts on transient rate limits / network errors. Defaults to 3. */
|
|
313
|
+
maxRetries?: number;
|
|
314
|
+
/** Rate limiting options per user and per project. */
|
|
315
|
+
rateLimit?: {
|
|
316
|
+
userMax?: number;
|
|
317
|
+
projectMax?: number;
|
|
318
|
+
store?: AIRateLimitStore;
|
|
319
|
+
};
|
|
320
|
+
/** Global RAG (Retrieval-Augmented Generation) configuration options. */
|
|
321
|
+
rag?: GlobalRAGConfig;
|
|
322
|
+
/** Conversation compaction options. */
|
|
323
|
+
compaction?: {
|
|
324
|
+
enabled?: boolean;
|
|
325
|
+
maxMessages?: number;
|
|
326
|
+
recentMessagesCount?: number;
|
|
327
|
+
};
|
|
328
|
+
/** Automated PII redaction and de-identification settings. */
|
|
329
|
+
pii?: AIPIIConfig;
|
|
330
|
+
/** Custom developer-defined tools. */
|
|
331
|
+
tools?: Record<string, AIToolDefinition>;
|
|
332
|
+
}
|
|
333
|
+
type AIPIIPattern = "email" | "phone" | "phone_number" | "phoneNumber" | "ssn" | "credit_card" | "ipv4" | "ipv6" | "iban" | "api_key" | "jwt" | "passport";
|
|
334
|
+
interface AIPIIConfig {
|
|
335
|
+
/** If true, automatically scrubs known PII from unstructured text before AI embedding or inference. */
|
|
336
|
+
enabled?: boolean;
|
|
337
|
+
/** Patterns to scrub. Defaults to ['email', 'phone', 'ssn', 'credit_card', 'ipv4']. */
|
|
338
|
+
patterns?: AIPIIPattern[];
|
|
339
|
+
/** Redaction strategy: 'mask' (e.g. b***@example.com) or 'token' (e.g. [REDACTED_EMAIL]). Defaults to 'mask'. */
|
|
340
|
+
strategy?: 'mask' | 'token';
|
|
341
|
+
/** Optional custom scrubber function to transform text before AI consumption. */
|
|
342
|
+
customScrubber?: (text: string) => string;
|
|
343
|
+
}
|
|
344
|
+
interface CollectionSummaryResult {
|
|
345
|
+
slug: string;
|
|
346
|
+
label: string;
|
|
347
|
+
auth: boolean;
|
|
348
|
+
timestamps: boolean;
|
|
349
|
+
}
|
|
350
|
+
interface CollectionSchemaResult {
|
|
351
|
+
slug: string;
|
|
352
|
+
label: string;
|
|
353
|
+
auth: boolean;
|
|
354
|
+
fields: Array<{
|
|
355
|
+
name: string;
|
|
356
|
+
type: string;
|
|
357
|
+
label?: string;
|
|
358
|
+
required: boolean;
|
|
359
|
+
unique: boolean;
|
|
360
|
+
relationTo?: string;
|
|
361
|
+
options?: any;
|
|
362
|
+
}>;
|
|
363
|
+
}
|
|
364
|
+
interface GlobalSummaryResult {
|
|
365
|
+
slug: string;
|
|
366
|
+
label: string;
|
|
367
|
+
}
|
|
368
|
+
interface GlobalSchemaResult {
|
|
369
|
+
slug: string;
|
|
370
|
+
label: string;
|
|
371
|
+
fields: Array<{
|
|
372
|
+
name: string;
|
|
373
|
+
type: string;
|
|
374
|
+
label?: string;
|
|
375
|
+
required: boolean;
|
|
376
|
+
}>;
|
|
377
|
+
data: Record<string, unknown> | null;
|
|
378
|
+
}
|
|
379
|
+
interface QueryCollectionResult {
|
|
380
|
+
collection: string;
|
|
381
|
+
docs: Array<Record<string, unknown>>;
|
|
382
|
+
total: number;
|
|
383
|
+
totalPages: number;
|
|
384
|
+
page: number;
|
|
385
|
+
limit: number;
|
|
386
|
+
}
|
|
387
|
+
interface GetDocumentResult {
|
|
388
|
+
collection: string;
|
|
389
|
+
doc: Record<string, unknown>;
|
|
390
|
+
}
|
|
391
|
+
interface AggregateCollectionResult {
|
|
392
|
+
collection: string;
|
|
393
|
+
result: Record<string, unknown>;
|
|
394
|
+
}
|
|
395
|
+
type AIActionType = 'createDocument' | 'updateDocument' | 'deleteDocument' | 'updateGlobal';
|
|
396
|
+
type AIActionStatus = 'pending' | 'approved' | 'rejected' | 'executed' | 'failed';
|
|
397
|
+
interface AIAction {
|
|
398
|
+
id: string;
|
|
399
|
+
projectId: string;
|
|
400
|
+
threadId?: string;
|
|
401
|
+
userId?: string;
|
|
402
|
+
type: AIActionType;
|
|
403
|
+
targetCollection?: string;
|
|
404
|
+
targetGlobal?: string;
|
|
405
|
+
documentId?: string;
|
|
406
|
+
summary: string;
|
|
407
|
+
beforeSnapshot?: Record<string, unknown> | null;
|
|
408
|
+
proposedData: Record<string, unknown>;
|
|
409
|
+
status: AIActionStatus;
|
|
410
|
+
errorMessage?: string;
|
|
411
|
+
expiresAt: Date | string;
|
|
412
|
+
createdAt: Date | string;
|
|
413
|
+
executedAt?: Date | string;
|
|
414
|
+
[key: string]: unknown;
|
|
415
|
+
}
|
|
416
|
+
type AIAuditActionType = AIActionType | 'chat_turn' | 'rag_search' | 'action_rejected';
|
|
417
|
+
interface AIAuditRecord {
|
|
418
|
+
id: string;
|
|
419
|
+
projectId: string;
|
|
420
|
+
actionId?: string;
|
|
421
|
+
threadId?: string;
|
|
422
|
+
executedBy?: string;
|
|
423
|
+
actionType: AIAuditActionType;
|
|
424
|
+
target: string;
|
|
425
|
+
snapshotBefore?: Record<string, unknown> | null;
|
|
426
|
+
snapshotAfter?: Record<string, unknown> | null;
|
|
427
|
+
rollbackPayload?: Record<string, unknown> | null;
|
|
428
|
+
tokens?: {
|
|
429
|
+
promptTokens?: number;
|
|
430
|
+
completionTokens?: number;
|
|
431
|
+
totalTokens?: number;
|
|
432
|
+
};
|
|
433
|
+
estimatedCostUsd?: number;
|
|
434
|
+
latencyMs?: {
|
|
435
|
+
total?: number;
|
|
436
|
+
retrieval?: number;
|
|
437
|
+
generation?: number;
|
|
438
|
+
};
|
|
439
|
+
createdAt: Date | string;
|
|
440
|
+
[key: string]: unknown;
|
|
441
|
+
}
|
|
442
|
+
declare const AI_THREADS_COLLECTION = "_dyrected_ai_threads";
|
|
443
|
+
declare const AI_MESSAGES_COLLECTION = "_dyrected_ai_messages";
|
|
444
|
+
declare const AI_CHUNKS_COLLECTION = "_dyrected_ai_chunks";
|
|
445
|
+
declare const AI_ACTIONS_COLLECTION = "_dyrected_ai_actions";
|
|
446
|
+
declare const AI_AUDIT_COLLECTION = "_dyrected_ai_audit";
|
|
447
|
+
declare function isAICollection(slug: string): boolean;
|
|
448
|
+
|
|
162
449
|
/** A valid icon component name from the Lucide icon set bundled with Dyrected Admin. */
|
|
163
450
|
type AdminIconName = keyof typeof icons;
|
|
164
451
|
/** Ordered custom component keys rendered around the built-in Admin dashboard. */
|
|
@@ -1406,6 +1693,12 @@ interface AuthConfig {
|
|
|
1406
1693
|
* Defaults to `10 * 60 * 1000` (10 minutes).
|
|
1407
1694
|
*/
|
|
1408
1695
|
lockTime?: number;
|
|
1696
|
+
/**
|
|
1697
|
+
* The role name designated as the superuser/admin role for this collection.
|
|
1698
|
+
*
|
|
1699
|
+
* Defaults to `'admin'`.
|
|
1700
|
+
*/
|
|
1701
|
+
adminRole?: string;
|
|
1409
1702
|
}
|
|
1410
1703
|
/**
|
|
1411
1704
|
* Use this contract when you want the exact shape of a collection config.
|
|
@@ -1743,6 +2036,21 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
|
|
|
1743
2036
|
*/
|
|
1744
2037
|
urlPattern?: string;
|
|
1745
2038
|
};
|
|
2039
|
+
/**
|
|
2040
|
+
* Optional custom AI assistant instructions and RAG indexing options for this collection.
|
|
2041
|
+
*/
|
|
2042
|
+
ai?: {
|
|
2043
|
+
/** Specific editorial guidelines, brand voice, or instructions for this collection. */
|
|
2044
|
+
prompt?: string;
|
|
2045
|
+
/** Collection-level RAG (Retrieval-Augmented Generation) indexing settings. */
|
|
2046
|
+
rag?: CollectionRAGConfig;
|
|
2047
|
+
/** Field names to completely omit from AI context and RAG indexing. */
|
|
2048
|
+
excludeFields?: string[];
|
|
2049
|
+
/** Field names to mask (e.g. j***@example.com) before sending to AI. */
|
|
2050
|
+
redactFields?: string[];
|
|
2051
|
+
/** Custom hook to transform/sanitize/pseudonymize documents before AI inspection. */
|
|
2052
|
+
sanitizeDoc?: (doc: Record<string, unknown>) => Record<string, unknown>;
|
|
2053
|
+
};
|
|
1746
2054
|
/**
|
|
1747
2055
|
* Detail view layout configuration for the Admin UI.
|
|
1748
2056
|
*
|
|
@@ -1888,6 +2196,13 @@ interface GlobalConfig<TDoc extends object = Record<string, unknown>> {
|
|
|
1888
2196
|
/** If `true`, this global is not shown in the Admin UI sidebar. */
|
|
1889
2197
|
hidden?: boolean;
|
|
1890
2198
|
};
|
|
2199
|
+
/**
|
|
2200
|
+
* Optional custom AI assistant instructions for this global singleton.
|
|
2201
|
+
*/
|
|
2202
|
+
ai?: {
|
|
2203
|
+
/** Specific guidelines, context, or instructions when interacting with this global. */
|
|
2204
|
+
prompt?: string;
|
|
2205
|
+
};
|
|
1891
2206
|
/**
|
|
1892
2207
|
* Initial data to seed this global with the first time it is fetched and
|
|
1893
2208
|
* found to be empty.
|
|
@@ -2217,6 +2532,15 @@ interface FieldBase {
|
|
|
2217
2532
|
renameTo?: string;
|
|
2218
2533
|
/** Whether SQL adapters should promote this field into a first-class column. */
|
|
2219
2534
|
promoted?: boolean;
|
|
2535
|
+
/** AI assistant privacy and PII redaction settings for this field. */
|
|
2536
|
+
ai?: {
|
|
2537
|
+
/** If true, completely removes this field from AI queries, RAG chunks, and context. */
|
|
2538
|
+
exclude?: boolean;
|
|
2539
|
+
/** If true or 'mask', masks the field value (e.g. b***@example.com) before sending to AI. */
|
|
2540
|
+
redact?: boolean | 'mask';
|
|
2541
|
+
/** If true, opts out of automatic default PII masking (e.g. for email/phone fields). */
|
|
2542
|
+
allowRaw?: boolean;
|
|
2543
|
+
};
|
|
2220
2544
|
}
|
|
2221
2545
|
interface BaseFieldAdmin {
|
|
2222
2546
|
/** Placeholder text shown when the input has no value. */
|
|
@@ -3153,6 +3477,156 @@ interface DyrectedConfig<TUser extends AuthenticatedUser = AuthenticatedUser> {
|
|
|
3153
3477
|
admin?: AdminConfig;
|
|
3154
3478
|
adminAuth?: AdminAuthConfig;
|
|
3155
3479
|
}>;
|
|
3480
|
+
/**
|
|
3481
|
+
* AI Assistant and LLM tools configuration.
|
|
3482
|
+
*/
|
|
3483
|
+
ai?: AIConfig;
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
interface CollectionTokenPayload extends JWTPayload {
|
|
3487
|
+
sub: string;
|
|
3488
|
+
email: string;
|
|
3489
|
+
collection: string;
|
|
3490
|
+
sid?: string;
|
|
3491
|
+
purpose?: 'invite' | 'reset';
|
|
3492
|
+
providerId?: string;
|
|
3493
|
+
authSource?: 'local' | 'external';
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
type RequestVars = DyrectedContext["Variables"];
|
|
3497
|
+
interface ResolvedObservabilityConfig {
|
|
3498
|
+
requestLogging: {
|
|
3499
|
+
enabled: boolean;
|
|
3500
|
+
logBodies: boolean;
|
|
3501
|
+
maxBodyBytes: number;
|
|
3502
|
+
redactPaths: string[];
|
|
3503
|
+
includeHeaders: string[];
|
|
3504
|
+
redactHeaders: string[];
|
|
3505
|
+
};
|
|
3506
|
+
sampling: {
|
|
3507
|
+
successRate: number;
|
|
3508
|
+
traceSuccessRate: number;
|
|
3509
|
+
bodySuccessRate: number;
|
|
3510
|
+
alwaysKeep4xx: boolean;
|
|
3511
|
+
alwaysKeep5xx: boolean;
|
|
3512
|
+
};
|
|
3513
|
+
tracing: {
|
|
3514
|
+
enabled: boolean;
|
|
3515
|
+
serviceName: string;
|
|
3516
|
+
exporter: "otlp" | "console" | "none";
|
|
3517
|
+
headers: Record<string, string>;
|
|
3518
|
+
endpoint?: string;
|
|
3519
|
+
};
|
|
3520
|
+
metrics: {
|
|
3521
|
+
enabled: boolean;
|
|
3522
|
+
exporter: "otlp" | "prometheus" | "none";
|
|
3523
|
+
endpoint?: string;
|
|
3524
|
+
path: string;
|
|
3525
|
+
};
|
|
3526
|
+
transports: {
|
|
3527
|
+
targets: Array<{
|
|
3528
|
+
type: "stdout";
|
|
3529
|
+
} | {
|
|
3530
|
+
type: "stderr";
|
|
3531
|
+
} | {
|
|
3532
|
+
type: "file";
|
|
3533
|
+
path: string;
|
|
3534
|
+
} | {
|
|
3535
|
+
type: "otlp";
|
|
3536
|
+
endpoint: string;
|
|
3537
|
+
headers?: Record<string, string>;
|
|
3538
|
+
}>;
|
|
3539
|
+
};
|
|
3156
3540
|
}
|
|
3541
|
+
interface RequestTraceContext {
|
|
3542
|
+
span: Span;
|
|
3543
|
+
traceId: string;
|
|
3544
|
+
spanId: string;
|
|
3545
|
+
sampled: boolean;
|
|
3546
|
+
}
|
|
3547
|
+
interface RequestBodyCapture {
|
|
3548
|
+
attempted: boolean;
|
|
3549
|
+
contentType?: string;
|
|
3550
|
+
contentLength?: number;
|
|
3551
|
+
truncated?: boolean;
|
|
3552
|
+
parseFailed?: boolean;
|
|
3553
|
+
body?: unknown;
|
|
3554
|
+
}
|
|
3555
|
+
interface MetricsRuntime {
|
|
3556
|
+
requestCount: Counter<Attributes>;
|
|
3557
|
+
authFailureCount: Counter<Attributes>;
|
|
3558
|
+
uncaughtErrorCount: Counter<Attributes>;
|
|
3559
|
+
auditWriteFailureCount: Counter<Attributes>;
|
|
3560
|
+
emailSendFailureCount: Counter<Attributes>;
|
|
3561
|
+
workflowHookFailureCount: Counter<Attributes>;
|
|
3562
|
+
requestDuration: Histogram<Attributes>;
|
|
3563
|
+
}
|
|
3564
|
+
interface DyrectedObservabilityRuntime {
|
|
3565
|
+
logger: Logger;
|
|
3566
|
+
config: ResolvedObservabilityConfig;
|
|
3567
|
+
tracer?: Tracer;
|
|
3568
|
+
metrics?: MetricsRuntime;
|
|
3569
|
+
prometheusExporter?: PrometheusExporter;
|
|
3570
|
+
shutdown: () => Promise<void>;
|
|
3571
|
+
recordAuthFailure: (attributes?: Attributes) => void;
|
|
3572
|
+
recordUncaughtError: (attributes?: Attributes) => void;
|
|
3573
|
+
recordAuditWriteFailure: (attributes?: Attributes) => void;
|
|
3574
|
+
recordEmailSendFailure: (attributes?: Attributes) => void;
|
|
3575
|
+
recordWorkflowHookFailure: (attributes?: Attributes) => void;
|
|
3576
|
+
}
|
|
3577
|
+
declare function resolveObservabilityConfig(config?: DyrectedObservabilityConfig): ResolvedObservabilityConfig;
|
|
3578
|
+
declare function createObservabilityRuntime(config: DyrectedConfig): DyrectedObservabilityRuntime;
|
|
3579
|
+
declare function bindObservabilityRuntime(config: DyrectedConfig, runtime: DyrectedObservabilityRuntime): void;
|
|
3580
|
+
declare function getObservabilityRuntime(config: Pick<DyrectedConfig, "logger"> | undefined): DyrectedObservabilityRuntime | undefined;
|
|
3581
|
+
declare function getConfigLogger(config: Pick<DyrectedConfig, "logger"> | undefined, component: string): Logger;
|
|
3582
|
+
declare function getRequestLogger(c: Context<DyrectedContext>, component?: string): Logger;
|
|
3583
|
+
declare function buildRequestLogger(runtime: DyrectedObservabilityRuntime, vars: RequestVars, requestId?: string): Logger;
|
|
3584
|
+
declare function shouldSampleRequest(requestId: string | undefined, statusCode: number, sampling: ResolvedObservabilityConfig["sampling"], kind: "log" | "trace" | "body"): boolean;
|
|
3585
|
+
declare function redactHeaders(headers: Record<string, string>, observability: ResolvedObservabilityConfig): Record<string, string>;
|
|
3586
|
+
declare function captureRequestBody(request: Request, observability: ResolvedObservabilityConfig): Promise<RequestBodyCapture>;
|
|
3587
|
+
declare function redactBody(value: unknown, redactPaths: string[]): unknown;
|
|
3588
|
+
declare function createRequestSpan(runtime: DyrectedObservabilityRuntime, name: string, attributes: Attributes): RequestTraceContext | undefined;
|
|
3589
|
+
declare function endRequestSpan(requestTrace: RequestTraceContext | undefined, statusCode: number, error?: unknown): void;
|
|
3590
|
+
declare function attachRequestMetrics(runtime: DyrectedObservabilityRuntime, args: {
|
|
3591
|
+
method: string;
|
|
3592
|
+
route: string;
|
|
3593
|
+
statusCode: number;
|
|
3594
|
+
durationMs: number;
|
|
3595
|
+
}): void;
|
|
3596
|
+
declare function renderPrometheusMetrics(exporter: PrometheusExporter): Promise<{
|
|
3597
|
+
body: string;
|
|
3598
|
+
headers: Record<string, string>;
|
|
3599
|
+
statusCode: number;
|
|
3600
|
+
}>;
|
|
3601
|
+
|
|
3602
|
+
interface DyrectedContext {
|
|
3603
|
+
Variables: {
|
|
3604
|
+
config: DyrectedConfig;
|
|
3605
|
+
logger?: Logger;
|
|
3606
|
+
observability?: DyrectedObservabilityRuntime;
|
|
3607
|
+
siteId?: string;
|
|
3608
|
+
workspaceId?: string;
|
|
3609
|
+
requestBodyCapture?: RequestBodyCapture;
|
|
3610
|
+
requestTrace?: RequestTraceContext;
|
|
3611
|
+
/**
|
|
3612
|
+
* The authenticated user set by requireAuth() or optionalAuth() middleware.
|
|
3613
|
+
* Hydrated from the full user record (minus password) when a db adapter is
|
|
3614
|
+
* configured, so collection fields like `roles` are available; falls back to
|
|
3615
|
+
* the token's identity claims otherwise.
|
|
3616
|
+
*/
|
|
3617
|
+
user?: {
|
|
3618
|
+
sub: string;
|
|
3619
|
+
email?: string;
|
|
3620
|
+
collection: string;
|
|
3621
|
+
[key: string]: any;
|
|
3622
|
+
};
|
|
3623
|
+
clientIp?: string;
|
|
3624
|
+
authTokenPayload?: CollectionTokenPayload;
|
|
3625
|
+
};
|
|
3626
|
+
}
|
|
3627
|
+
/**
|
|
3628
|
+
* Create the main Dyrected Hono application.
|
|
3629
|
+
*/
|
|
3630
|
+
declare function createDyrectedApp(rawConfig: DyrectedConfig | any): Promise<Hono<DyrectedContext, hono_types.BlankSchema, "/">>;
|
|
3157
3631
|
|
|
3158
|
-
export { type
|
|
3632
|
+
export { type MultiSelectField as $, type AdminAuthConfig as A, type Block as B, type CollectionConfig as C, type DyrectedConfig as D, type DetailText as E, type Field as F, type GlobalConfig as G, type HookRequestContext as H, type DetailSchema as I, type DyrectedContext as J, type AIConfig as K, type LifecycleEventName as L, type AIPIIConfig as M, type ArrayField as N, type BlocksField as O, type PublicAdminAuthConfig as P, type BooleanField as Q, type AuthConfig as R, type AccessPolicyResolver as S, type DateField as T, type DateTimeField as U, type EmailField as V, type WorkflowConfig as W, type IconField as X, type ImageField as Y, type JoinField as Z, type JsonField as _, type DeclarativeHookExpression as a, type CollectionAfterReadHook as a$, type NumberField as a0, type ObjectField as a1, type RadioField as a2, type RelationshipField as a3, type RichTextField as a4, type RowField as a5, type SelectField as a6, type TextField as a7, type TextareaField as a8, type TimeField as a9, type ActionType as aA, type AdminAuthAccessResolution as aB, type AdminAuthClaimMapping as aC, type AdminAuthMember as aD, type AdminAuthProvider as aE, type AdminAuthProviderMembersConfig as aF, type AdminAuthProvisioningMode as aG, type AdminAuthResolveAccessArgs as aH, type AdminAuthResolvedIdentity as aI, type AdminConfig as aJ, type AdminDashboardComponentSlots as aK, type AdminIconName as aL, type AggregateArgs as aM, type AggregateCastType as aN, type AggregateCollectionResult as aO, type AggregateInput as aP, type AggregateOperation as aQ, type AggregateResult as aR, type BaseAdminAuthProvider as aS, type BaseFieldAdmin as aT, type BlockVariant as aU, type BooleanFieldAdmin as aV, type BooleanFormat as aW, type CharacterLimitFieldAdmin as aX, type CharacterLimitFieldConfig as aY, type CollectionAfterChangeHook as aZ, type CollectionAfterDeleteHook as a_, type UrlField as aa, type AIAction as ab, type AIActionStatus as ac, type AIActionType as ad, type AIAuditActionType as ae, type AIAuditRecord as af, type AIChunk as ag, type AIMessage as ah, type AIPIIPattern as ai, type AIRateLimitResult as aj, type AIRateLimitStore as ak, type AIThread as al, type AIToolContext as am, type AIToolDefinition as an, AI_ACTIONS_COLLECTION as ao, AI_AUDIT_COLLECTION as ap, AI_CHUNKS_COLLECTION as aq, AI_MESSAGES_COLLECTION as ar, AI_THREADS_COLLECTION as as, type AccessConfig as at, type AccessFunction as au, type AccessFunctionArgs as av, type AccessResult as aw, type AccessRule as ax, type ActionConfig as ay, type ActionContext as az, type AuthenticatedUser as b, type ImageTransformOptions as b$, type CollectionAfterReadHookEntry as b0, type CollectionAfterTransitionHook as b1, type CollectionBeforeChangeHook as b2, type CollectionBeforeChangeHookEntry as b3, type CollectionBeforeDeleteHook as b4, type CollectionBeforeReadHook as b5, type CollectionBeforeReadHookEntry as b6, type CollectionBeforeTransitionHook as b7, type CollectionListComponentSlots as b8, type CollectionRAGConfig as b9, type FieldAdminOptionsHook as bA, type FieldAdminOptionsHookArgs as bB, type FieldAdminOptionsHookResult as bC, type FieldAfterReadHook as bD, type FieldAfterReadHookArgs as bE, type FieldBase as bF, type FieldBeforeChangeHook as bG, type FieldBeforeChangeHookArgs as bH, type FieldHook as bI, type FieldHooks as bJ, type FieldType as bK, type FileData as bL, type GetDocumentResult as bM, type GlobalAfterChangeHook as bN, type GlobalAfterReadHook as bO, type GlobalAfterReadHookEntry as bP, type GlobalBeforeChangeHook as bQ, type GlobalBeforeChangeHookEntry as bR, type GlobalBeforeReadHook as bS, type GlobalBeforeReadHookEntry as bT, type GlobalRAGConfig as bU, type GlobalSchemaResult as bV, type GlobalSummaryResult as bW, type HeadingLevel as bX, type HookFunction as bY, type IconFieldAdmin as bZ, type ImageService as b_, type CollectionSchemaResult as ba, type CollectionSummaryResult as bb, type CollectionViewComponentSlots as bc, type CountOperation as bd, type CustomAdminAuthProvider as be, type DatabaseAdapter as bf, type DateFieldAdmin as bg, type DateFormat as bh, type DefineActionOptions as bi, type DefineViewOptions as bj, type DetailSpan as bk, type DisplayTone as bl, type DisplayVariant as bm, type DistinctCountOperation as bn, type DistinctValuesOperation as bo, type DynamicOptionItem as bp, type DynamicOptionsConfig as bq, type DynamicOptionsResolver as br, type DynamicOptionsResolverArgs as bs, type DyrectedAIContext as bt, type DyrectedLoggerConfig as bu, type DyrectedObservabilityConfig as bv, type EmailFieldAdmin as bw, type FieldAdminHooks as bx, type FieldAdminOnChangeHook as by, type FieldAdminOnChangeHookArgs as bz, type WorkflowTransition as c, buildRequestLogger as c$, type InferAggregateResult as c0, type JoinFieldAdmin as c1, type JsonFieldAdmin as c2, type JsonFormat as c3, LIFECYCLE_EVENT_NAMES as c4, type LifecycleEventHandler as c5, type LinkFormat as c6, type MetricColor as c7, type MultiSelectFieldAdmin as c8, type NamedAccessPolicy as c9, type UrlLinkValue as cA, type ViewActionFeatures as cB, type ViewComponentSlots as cC, type ViewConfig as cD, type ViewLayout as cE, type ViewMetric as cF, type ViewSubMetric as cG, type WhereClause as cH, type WhereOperator as cI, type WhereOperatorName as cJ, type WordLimitFieldAdmin as cK, type WordLimitFieldConfig as cL, type WorkflowMetadata as cM, type WorkflowRole as cN, type WorkflowState as cO, type WorkflowTransitionContext as cP, defineAction as cQ, defineView as cR, isAICollection as cS, parseMongoWhere as cT, parseSqlWhere as cU, type DyrectedObservabilityRuntime as cV, type RequestBodyCapture as cW, type RequestTraceContext as cX, type ResolvedObservabilityConfig as cY, attachRequestMetrics as cZ, bindObservabilityRuntime as c_, type NumberFieldAdmin as ca, type NumberFormat as cb, type NumberLimitFieldAdmin as cc, type NumberLimitFieldConfig as cd, type NumericOperation as ce, type OIDCAdminAuthProvider as cf, type OptionFormat as cg, type PaginatedResult as ch, type PublicAdminAuthProvider as ci, type QueryCollectionResult as cj, type RAGSearchResult as ck, type RadioFieldAdmin as cl, type RateLimitConfig as cm, type ReadonlyDatabaseAdapter as cn, type RichTextFeature as co, type RichTextFieldConfig as cp, type SelectFieldAdmin as cq, type SqlWhereResult as cr, type StorageAdapter as cs, type TextFieldAdmin as ct, type TextFormat as cu, type TextareaFieldAdmin as cv, type TrustProxyConfig as cw, type TypedField as cx, type UploadConfig as cy, type UrlFieldAdmin as cz, type LifecycleEvent as d, captureRequestBody as d0, createDyrectedApp as d1, createObservabilityRuntime as d2, createRequestSpan as d3, endRequestSpan as d4, getConfigLogger as d5, getObservabilityRuntime as d6, getRequestLogger as d7, redactBody as d8, redactHeaders as d9, renderPrometheusMetrics as da, resolveObservabilityConfig as db, shouldSampleRequest as dc, type BaseDocument as e, type DetailComputedOptions as f, type ComputedHandler as g, type DetailComputed as h, type DetailCustomOptions as i, type DetailCustom as j, type DetailDividerOptions as k, type DetailDivider as l, type DisplayFieldOptions as m, type DetailField as n, type DetailItem as o, type DetailGridOptions as p, type DetailGrid as q, type DetailRepeatOptions as r, type DetailRepeat as s, type DetailSectionOptions as t, type DetailSection as u, type DetailTabOptions as v, type DetailTab as w, type DetailTabsOptions as x, type DetailTabs as y, type DetailTextOptions as z };
|