@adonis-agora/telescope 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 +26 -0
- package/dist/configure.d.ts +16 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +75 -0
- package/dist/configure.js.map +1 -0
- package/dist/providers/telescope_ai_provider.d.ts +20 -0
- package/dist/providers/telescope_ai_provider.d.ts.map +1 -0
- package/dist/providers/telescope_ai_provider.js +45 -0
- package/dist/providers/telescope_ai_provider.js.map +1 -0
- package/dist/providers/telescope_alerts_provider.d.ts +23 -0
- package/dist/providers/telescope_alerts_provider.d.ts.map +1 -0
- package/dist/providers/telescope_alerts_provider.js +72 -0
- package/dist/providers/telescope_alerts_provider.js.map +1 -0
- package/dist/providers/telescope_provider.d.ts +43 -0
- package/dist/providers/telescope_provider.d.ts.map +1 -0
- package/dist/providers/telescope_provider.js +103 -0
- package/dist/providers/telescope_provider.js.map +1 -0
- package/dist/providers/telescope_ui_provider.d.ts +21 -0
- package/dist/providers/telescope_ui_provider.d.ts.map +1 -0
- package/dist/providers/telescope_ui_provider.js +119 -0
- package/dist/providers/telescope_ui_provider.js.map +1 -0
- package/dist/providers/telescope_watchers_provider.d.ts +31 -0
- package/dist/providers/telescope_watchers_provider.d.ts.map +1 -0
- package/dist/providers/telescope_watchers_provider.js +116 -0
- package/dist/providers/telescope_watchers_provider.js.map +1 -0
- package/dist/src/ai/define_config.d.ts +56 -0
- package/dist/src/ai/define_config.d.ts.map +1 -0
- package/dist/src/ai/define_config.js +39 -0
- package/dist/src/ai/define_config.js.map +1 -0
- package/dist/src/ai/diagnoser.d.ts +34 -0
- package/dist/src/ai/diagnoser.d.ts.map +1 -0
- package/dist/src/ai/diagnoser.js +74 -0
- package/dist/src/ai/diagnoser.js.map +1 -0
- package/dist/src/ai/diagnosis_cache.d.ts +43 -0
- package/dist/src/ai/diagnosis_cache.d.ts.map +1 -0
- package/dist/src/ai/diagnosis_cache.js +56 -0
- package/dist/src/ai/diagnosis_cache.js.map +1 -0
- package/dist/src/ai/factory.d.ts +15 -0
- package/dist/src/ai/factory.d.ts.map +1 -0
- package/dist/src/ai/factory.js +24 -0
- package/dist/src/ai/factory.js.map +1 -0
- package/dist/src/ai/index.d.ts +14 -0
- package/dist/src/ai/index.d.ts.map +1 -0
- package/dist/src/ai/index.js +15 -0
- package/dist/src/ai/index.js.map +1 -0
- package/dist/src/ai/prompt.d.ts +31 -0
- package/dist/src/ai/prompt.d.ts.map +1 -0
- package/dist/src/ai/prompt.js +66 -0
- package/dist/src/ai/prompt.js.map +1 -0
- package/dist/src/ai/telescope_ai_diagnoser.d.ts +79 -0
- package/dist/src/ai/telescope_ai_diagnoser.d.ts.map +1 -0
- package/dist/src/ai/telescope_ai_diagnoser.js +111 -0
- package/dist/src/ai/telescope_ai_diagnoser.js.map +1 -0
- package/dist/src/alerts/alert_channel.d.ts +69 -0
- package/dist/src/alerts/alert_channel.d.ts.map +1 -0
- package/dist/src/alerts/alert_channel.js +114 -0
- package/dist/src/alerts/alert_channel.js.map +1 -0
- package/dist/src/alerts/alert_rule.d.ts +86 -0
- package/dist/src/alerts/alert_rule.d.ts.map +1 -0
- package/dist/src/alerts/alert_rule.js +2 -0
- package/dist/src/alerts/alert_rule.js.map +1 -0
- package/dist/src/alerts/alerter.d.ts +72 -0
- package/dist/src/alerts/alerter.d.ts.map +1 -0
- package/dist/src/alerts/alerter.js +248 -0
- package/dist/src/alerts/alerter.js.map +1 -0
- package/dist/src/alerts/define_config.d.ts +68 -0
- package/dist/src/alerts/define_config.d.ts.map +1 -0
- package/dist/src/alerts/define_config.js +57 -0
- package/dist/src/alerts/define_config.js.map +1 -0
- package/dist/src/alerts/exception_source.d.ts +44 -0
- package/dist/src/alerts/exception_source.d.ts.map +1 -0
- package/dist/src/alerts/exception_source.js +79 -0
- package/dist/src/alerts/exception_source.js.map +1 -0
- package/dist/src/alerts/index.d.ts +16 -0
- package/dist/src/alerts/index.d.ts.map +1 -0
- package/dist/src/alerts/index.js +17 -0
- package/dist/src/alerts/index.js.map +1 -0
- package/dist/src/alerts/new_exception_tracker.d.ts +50 -0
- package/dist/src/alerts/new_exception_tracker.d.ts.map +1 -0
- package/dist/src/alerts/new_exception_tracker.js +74 -0
- package/dist/src/alerts/new_exception_tracker.js.map +1 -0
- package/dist/src/alerts/parse_duration.d.ts +10 -0
- package/dist/src/alerts/parse_duration.d.ts.map +1 -0
- package/dist/src/alerts/parse_duration.js +27 -0
- package/dist/src/alerts/parse_duration.js.map +1 -0
- package/dist/src/alerts/slack_format.d.ts +60 -0
- package/dist/src/alerts/slack_format.d.ts.map +1 -0
- package/dist/src/alerts/slack_format.js +122 -0
- package/dist/src/alerts/slack_format.js.map +1 -0
- package/dist/src/context_accessor.d.ts +30 -0
- package/dist/src/context_accessor.d.ts.map +1 -0
- package/dist/src/context_accessor.js +20 -0
- package/dist/src/context_accessor.js.map +1 -0
- package/dist/src/define_config.d.ts +109 -0
- package/dist/src/define_config.d.ts.map +1 -0
- package/dist/src/define_config.js +38 -0
- package/dist/src/define_config.js.map +1 -0
- package/dist/src/diagnostics_registry.d.ts +46 -0
- package/dist/src/diagnostics_registry.d.ts.map +1 -0
- package/dist/src/diagnostics_registry.js +34 -0
- package/dist/src/diagnostics_registry.js.map +1 -0
- package/dist/src/diagnostics_watcher.d.ts +72 -0
- package/dist/src/diagnostics_watcher.d.ts.map +1 -0
- package/dist/src/diagnostics_watcher.js +119 -0
- package/dist/src/diagnostics_watcher.js.map +1 -0
- package/dist/src/entry.d.ts +81 -0
- package/dist/src/entry.d.ts.map +1 -0
- package/dist/src/entry.js +34 -0
- package/dist/src/entry.js.map +1 -0
- package/dist/src/exception_family_hash.d.ts +29 -0
- package/dist/src/exception_family_hash.d.ts.map +1 -0
- package/dist/src/exception_family_hash.js +30 -0
- package/dist/src/exception_family_hash.js.map +1 -0
- package/dist/src/exception_watcher.d.ts +66 -0
- package/dist/src/exception_watcher.d.ts.map +1 -0
- package/dist/src/exception_watcher.js +94 -0
- package/dist/src/exception_watcher.js.map +1 -0
- package/dist/src/extension/registry.d.ts +17 -0
- package/dist/src/extension/registry.d.ts.map +1 -0
- package/dist/src/extension/registry.js +56 -0
- package/dist/src/extension/registry.js.map +1 -0
- package/dist/src/extension/types.d.ts +158 -0
- package/dist/src/extension/types.d.ts.map +1 -0
- package/dist/src/extension/types.js +5 -0
- package/dist/src/extension/types.js.map +1 -0
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +28 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/redaction/redact.d.ts +93 -0
- package/dist/src/redaction/redact.d.ts.map +1 -0
- package/dist/src/redaction/redact.js +184 -0
- package/dist/src/redaction/redact.js.map +1 -0
- package/dist/src/redaction/redacting_store.d.ts +28 -0
- package/dist/src/redaction/redacting_store.d.ts.map +1 -0
- package/dist/src/redaction/redacting_store.js +49 -0
- package/dist/src/redaction/redacting_store.js.map +1 -0
- package/dist/src/registry.d.ts +26 -0
- package/dist/src/registry.d.ts.map +1 -0
- package/dist/src/registry.js +28 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/request_watcher.d.ts +44 -0
- package/dist/src/request_watcher.d.ts.map +1 -0
- package/dist/src/request_watcher.js +37 -0
- package/dist/src/request_watcher.js.map +1 -0
- package/dist/src/service.d.ts +36 -0
- package/dist/src/service.d.ts.map +1 -0
- package/dist/src/service.js +65 -0
- package/dist/src/service.js.map +1 -0
- package/dist/src/store.d.ts +56 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +2 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/stores/factory.d.ts +61 -0
- package/dist/src/stores/factory.d.ts.map +1 -0
- package/dist/src/stores/factory.js +42 -0
- package/dist/src/stores/factory.js.map +1 -0
- package/dist/src/stores/lucid.d.ts +138 -0
- package/dist/src/stores/lucid.d.ts.map +1 -0
- package/dist/src/stores/lucid.js +257 -0
- package/dist/src/stores/lucid.js.map +1 -0
- package/dist/src/stores/memory.d.ts +31 -0
- package/dist/src/stores/memory.d.ts.map +1 -0
- package/dist/src/stores/memory.js +117 -0
- package/dist/src/stores/memory.js.map +1 -0
- package/dist/src/telescope_middleware.d.ts +19 -0
- package/dist/src/telescope_middleware.d.ts.map +1 -0
- package/dist/src/telescope_middleware.js +56 -0
- package/dist/src/telescope_middleware.js.map +1 -0
- package/dist/src/ui/api.d.ts +49 -0
- package/dist/src/ui/api.d.ts.map +1 -0
- package/dist/src/ui/api.js +155 -0
- package/dist/src/ui/api.js.map +1 -0
- package/dist/src/ui/dashboard.d.ts +8 -0
- package/dist/src/ui/dashboard.d.ts.map +1 -0
- package/dist/src/ui/dashboard.html +626 -0
- package/dist/src/ui/dashboard.js +29 -0
- package/dist/src/ui/dashboard.js.map +1 -0
- package/dist/src/ui/define_config.d.ts +87 -0
- package/dist/src/ui/define_config.d.ts.map +1 -0
- package/dist/src/ui/define_config.js +104 -0
- package/dist/src/ui/define_config.js.map +1 -0
- package/dist/src/ui/extension_api.d.ts +23 -0
- package/dist/src/ui/extension_api.d.ts.map +1 -0
- package/dist/src/ui/extension_api.js +50 -0
- package/dist/src/ui/extension_api.js.map +1 -0
- package/dist/src/ui/guard.d.ts +33 -0
- package/dist/src/ui/guard.d.ts.map +1 -0
- package/dist/src/ui/guard.js +47 -0
- package/dist/src/ui/guard.js.map +1 -0
- package/dist/src/ui/http.d.ts +47 -0
- package/dist/src/ui/http.d.ts.map +1 -0
- package/dist/src/ui/http.js +43 -0
- package/dist/src/ui/http.js.map +1 -0
- package/dist/src/ui/index.d.ts +12 -0
- package/dist/src/ui/index.d.ts.map +1 -0
- package/dist/src/ui/index.js +13 -0
- package/dist/src/ui/index.js.map +1 -0
- package/dist/src/watchers/cache_watcher.d.ts +60 -0
- package/dist/src/watchers/cache_watcher.d.ts.map +1 -0
- package/dist/src/watchers/cache_watcher.js +72 -0
- package/dist/src/watchers/cache_watcher.js.map +1 -0
- package/dist/src/watchers/define_config.d.ts +38 -0
- package/dist/src/watchers/define_config.d.ts.map +1 -0
- package/dist/src/watchers/define_config.js +17 -0
- package/dist/src/watchers/define_config.js.map +1 -0
- package/dist/src/watchers/emitter.d.ts +32 -0
- package/dist/src/watchers/emitter.d.ts.map +1 -0
- package/dist/src/watchers/emitter.js +2 -0
- package/dist/src/watchers/emitter.js.map +1 -0
- package/dist/src/watchers/http_client_watcher.d.ts +74 -0
- package/dist/src/watchers/http_client_watcher.d.ts.map +1 -0
- package/dist/src/watchers/http_client_watcher.js +168 -0
- package/dist/src/watchers/http_client_watcher.js.map +1 -0
- package/dist/src/watchers/index.d.ts +19 -0
- package/dist/src/watchers/index.d.ts.map +1 -0
- package/dist/src/watchers/index.js +19 -0
- package/dist/src/watchers/index.js.map +1 -0
- package/dist/src/watchers/logs_watcher.d.ts +82 -0
- package/dist/src/watchers/logs_watcher.d.ts.map +1 -0
- package/dist/src/watchers/logs_watcher.js +145 -0
- package/dist/src/watchers/logs_watcher.js.map +1 -0
- package/dist/src/watchers/lucid_query_watcher.d.ts +64 -0
- package/dist/src/watchers/lucid_query_watcher.d.ts.map +1 -0
- package/dist/src/watchers/lucid_query_watcher.js +84 -0
- package/dist/src/watchers/lucid_query_watcher.js.map +1 -0
- package/dist/src/watchers/mail_watcher.d.ts +51 -0
- package/dist/src/watchers/mail_watcher.d.ts.map +1 -0
- package/dist/src/watchers/mail_watcher.js +93 -0
- package/dist/src/watchers/mail_watcher.js.map +1 -0
- package/dist/src/watchers/normalize_http_target.d.ts +17 -0
- package/dist/src/watchers/normalize_http_target.d.ts.map +1 -0
- package/dist/src/watchers/normalize_http_target.js +41 -0
- package/dist/src/watchers/normalize_http_target.js.map +1 -0
- package/dist/src/watchers/query_family_hash.d.ts +8 -0
- package/dist/src/watchers/query_family_hash.d.ts.map +1 -0
- package/dist/src/watchers/query_family_hash.js +31 -0
- package/dist/src/watchers/query_family_hash.js.map +1 -0
- package/dist/src/watchers/record.d.ts +22 -0
- package/dist/src/watchers/record.d.ts.map +1 -0
- package/dist/src/watchers/record.js +48 -0
- package/dist/src/watchers/record.js.map +1 -0
- package/dist/stubs/config/telescope.stub +56 -0
- package/dist/stubs/config/telescope_ai.stub +36 -0
- package/dist/stubs/config/telescope_alerts.stub +47 -0
- package/dist/stubs/config/telescope_ui.stub +40 -0
- package/dist/stubs/config/telescope_watchers.stub +30 -0
- package/dist/stubs/database/migrations/create_telescope_entries_table.stub +39 -0
- package/dist/stubs/main.d.ts +6 -0
- package/dist/stubs/main.d.ts.map +1 -0
- package/dist/stubs/main.js +7 -0
- package/dist/stubs/main.js.map +1 -0
- package/package.json +140 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/extension/registry.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IACnB,WAAW,GAAyB,EAAE,CAAC;IACvC,WAAW,GAAoB,EAAE,CAAC;IAClC,UAAU,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC7C,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAErD,YAAY,UAAyC,EAAE,GAAqB;QAC1E,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC9C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE7C,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC7C,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACpC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;oBACvB,MAAM,IAAI,KAAK,CACb,yBAAyB,EAAE,CAAC,EAAE,6BAA6B,IAAI,UAAU,GAAG,CAAC,IAAI,mCAAmC,CACrH,CAAC;gBACJ,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,CAAC;IACH,CAAC;IAED,UAAU;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IACD,UAAU;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IACD,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { ResolvedTelescopeConfig } from '../define_config.js';
|
|
2
|
+
import type { TelescopeStore } from '../store.js';
|
|
3
|
+
/**
|
|
4
|
+
* The published, versioned extension contract for `@adonis-agora/telescope`.
|
|
5
|
+
*
|
|
6
|
+
* An extension is a plain object (usually returned by a factory so it can take options), registered
|
|
7
|
+
* via `config/telescope.ts`'s `extensions: [...]`. The provider runs its hooks once at boot. Hooks
|
|
8
|
+
* are **multi** (every extension runs; results accumulate). A sibling lib (e.g. `@adonis-agora/durable`)
|
|
9
|
+
* contributes navigable entry types, declarative dashboard pages, and the server-side data providers
|
|
10
|
+
* those pages bind to — without `@adonis-agora/telescope` knowing anything about it.
|
|
11
|
+
*
|
|
12
|
+
* @remarks Semver 0.x — the shape may change until 1.0.
|
|
13
|
+
*/
|
|
14
|
+
export interface TelescopeExtension {
|
|
15
|
+
/** Unique id — used in collision errors and for deterministic ordering. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Contribute navigable entry types — makes the UI's entry-type nav dynamic. */
|
|
18
|
+
entryTypes?(ctx: ExtensionContext): ExtensionEntryType[];
|
|
19
|
+
/** Contribute declarative dashboard pages (the panel IR). */
|
|
20
|
+
dashboards?(ctx: ExtensionContext): DashboardSpec[];
|
|
21
|
+
/** Named server-side queries that panels bind to via `{ provider, query }`. */
|
|
22
|
+
dataProviders?(ctx: ExtensionContext): DataProvider[];
|
|
23
|
+
}
|
|
24
|
+
/** The slice of the AdonisJS container an extension needs to resolve host services. */
|
|
25
|
+
export interface ContainerLike {
|
|
26
|
+
make<T>(token: unknown): Promise<T>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Read-only context handed to every extension hook at boot. Replaces NestJS's `ModuleRef`: the
|
|
30
|
+
* telescope `store` is passed directly (for reading recorded entries), and `container` resolves host
|
|
31
|
+
* services — e.g. a durable provider does `await ctx.container.make(WorkflowEngine)`.
|
|
32
|
+
*/
|
|
33
|
+
export interface ExtensionContext {
|
|
34
|
+
/** The telescope store — read recorded entries for aggregation. */
|
|
35
|
+
readonly store: TelescopeStore;
|
|
36
|
+
/** Resolve host services (e.g. a durable `WorkflowEngine`) from the app container. */
|
|
37
|
+
readonly container: ContainerLike;
|
|
38
|
+
/** The resolved telescope config. */
|
|
39
|
+
readonly config: ResolvedTelescopeConfig;
|
|
40
|
+
}
|
|
41
|
+
/** A navigable entry type contributed by an extension (subset of the UI's entry-type nav). */
|
|
42
|
+
export interface ExtensionEntryType {
|
|
43
|
+
/** Backend `type`/`tag` filter value, e.g. 'durable'. */
|
|
44
|
+
id: string;
|
|
45
|
+
/** Nav label, e.g. 'Workflows'. */
|
|
46
|
+
label: string;
|
|
47
|
+
/** Tailwind `bg-*` dot color for the nav, e.g. 'bg-amber-400'. */
|
|
48
|
+
dot: string;
|
|
49
|
+
}
|
|
50
|
+
/** Threshold coloring for a numeric panel. `direction` says which way is worse. */
|
|
51
|
+
export interface PanelThresholds {
|
|
52
|
+
warn: number;
|
|
53
|
+
bad: number;
|
|
54
|
+
direction: 'up-bad' | 'down-bad';
|
|
55
|
+
}
|
|
56
|
+
/** A group of panels rendered together with its own column count. */
|
|
57
|
+
export interface DashboardSection {
|
|
58
|
+
title?: string;
|
|
59
|
+
cols?: 2 | 3 | 4;
|
|
60
|
+
panels: Panel[];
|
|
61
|
+
}
|
|
62
|
+
/** A declarative dashboard page. */
|
|
63
|
+
export interface DashboardSpec {
|
|
64
|
+
/** Stable route id, e.g. 'durable.workflows'. Globally unique across extensions. */
|
|
65
|
+
id: string;
|
|
66
|
+
/** Nav label, e.g. 'Workflows'. */
|
|
67
|
+
label: string;
|
|
68
|
+
/** Optional nav grouping header. */
|
|
69
|
+
navGroup?: string;
|
|
70
|
+
/** Flat layout. Prefer `sections` for hierarchy. */
|
|
71
|
+
panels: Panel[];
|
|
72
|
+
/** Sectioned layout. When present, the UI renders these instead of `panels`. */
|
|
73
|
+
sections?: DashboardSection[];
|
|
74
|
+
}
|
|
75
|
+
/** A bind from a panel to a named server-side provider + an opaque query object. */
|
|
76
|
+
export interface DataBinding {
|
|
77
|
+
/** Provider name, e.g. 'durable.timeseries'. Resolved on the server. */
|
|
78
|
+
provider: string;
|
|
79
|
+
/** Opaque query passed through to the provider's `resolve`. */
|
|
80
|
+
query?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
/** A deep-link out of a table cell (to the durable dashboard, a telescope trace, etc.). */
|
|
83
|
+
export interface LinkSpec {
|
|
84
|
+
/** A URL template with `{key}` placeholders filled from the row, e.g. '/durable/runs/{runId}'. */
|
|
85
|
+
href: string;
|
|
86
|
+
/** When true, open in a new tab. */
|
|
87
|
+
external?: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface Column {
|
|
90
|
+
key: string;
|
|
91
|
+
label: string;
|
|
92
|
+
link?: LinkSpec;
|
|
93
|
+
}
|
|
94
|
+
export type Panel = {
|
|
95
|
+
kind: 'stat';
|
|
96
|
+
title: string;
|
|
97
|
+
data: DataBinding;
|
|
98
|
+
format?: 'number' | 'percent' | 'duration' | 'rate';
|
|
99
|
+
accent?: string;
|
|
100
|
+
/** When true, the provider also returns `spark: number[]` and the card draws a sparkline. */
|
|
101
|
+
spark?: boolean;
|
|
102
|
+
thresholds?: PanelThresholds;
|
|
103
|
+
} | {
|
|
104
|
+
kind: 'timeseries';
|
|
105
|
+
title: string;
|
|
106
|
+
data: DataBinding;
|
|
107
|
+
series: string[];
|
|
108
|
+
style?: 'area' | 'stacked';
|
|
109
|
+
} | {
|
|
110
|
+
kind: 'topN';
|
|
111
|
+
title: string;
|
|
112
|
+
data: DataBinding;
|
|
113
|
+
limit?: number;
|
|
114
|
+
} | {
|
|
115
|
+
kind: 'table';
|
|
116
|
+
title: string;
|
|
117
|
+
data: DataBinding;
|
|
118
|
+
columns: Column[];
|
|
119
|
+
} | {
|
|
120
|
+
kind: 'distribution';
|
|
121
|
+
title: string;
|
|
122
|
+
data: DataBinding;
|
|
123
|
+
markers?: Array<'p50' | 'p95' | 'p99'>;
|
|
124
|
+
format?: 'duration' | 'number';
|
|
125
|
+
} | {
|
|
126
|
+
kind: 'gauge';
|
|
127
|
+
title: string;
|
|
128
|
+
data: DataBinding;
|
|
129
|
+
min?: number;
|
|
130
|
+
max?: number;
|
|
131
|
+
format?: 'number' | 'percent' | 'duration' | 'rate';
|
|
132
|
+
thresholds?: PanelThresholds;
|
|
133
|
+
} | {
|
|
134
|
+
kind: 'breakdown';
|
|
135
|
+
title: string;
|
|
136
|
+
data: DataBinding;
|
|
137
|
+
style?: 'donut' | 'bar';
|
|
138
|
+
};
|
|
139
|
+
/** A named server-side query a panel binds to. */
|
|
140
|
+
export interface DataProvider {
|
|
141
|
+
/** Stable name referenced by a panel's `DataBinding.provider`, e.g. 'durable.timeseries'. */
|
|
142
|
+
name: string;
|
|
143
|
+
/**
|
|
144
|
+
* Resolve a panel's data. `query` is the panel's `DataBinding.query` merged with the request query
|
|
145
|
+
* string. Return value shape is per panel kind:
|
|
146
|
+
* - stat → `{ value: number; delta?: number; deltaLabel?: string; spark?: number[] }`
|
|
147
|
+
* - timeseries → `{ rows: Array<{ label: string } & Record<string, number>> }`
|
|
148
|
+
* - topN → `{ items: Array<{ label: string; value: number; id?: string }> }`
|
|
149
|
+
* - table → `{ rows: Array<Record<string, unknown>> }`
|
|
150
|
+
* - distribution → `{ buckets: Array<{ label: string; count: number }>; p50?: number; p95?: number; p99?: number }`
|
|
151
|
+
* - gauge → `{ value: number; min?: number; max?: number }`
|
|
152
|
+
* - breakdown → `{ segments: Array<{ label: string; value: number; color?: string }> }`
|
|
153
|
+
*/
|
|
154
|
+
resolve(query: Record<string, unknown> | undefined, ctx: ExtensionContext): Promise<unknown>;
|
|
155
|
+
}
|
|
156
|
+
/** Identity helper for authoring extensions with full type inference. */
|
|
157
|
+
export declare function defineTelescopeExtension(ext: TelescopeExtension): TelescopeExtension;
|
|
158
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/extension/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,UAAU,CAAC,CAAC,GAAG,EAAE,gBAAgB,GAAG,kBAAkB,EAAE,CAAC;IACzD,6DAA6D;IAC7D,UAAU,CAAC,CAAC,GAAG,EAAE,gBAAgB,GAAG,aAAa,EAAE,CAAC;IACpD,+EAA+E;IAC/E,aAAa,CAAC,CAAC,GAAG,EAAE,gBAAgB,GAAG,YAAY,EAAE,CAAC;CACvD;AAED,uFAAuF;AACvF,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACrC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,sFAAsF;IACtF,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,qCAAqC;IACrC,QAAQ,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,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IACpD,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B,GACD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;CAAE,CAAC;AAErF,kDAAkD;AAClD,MAAM,WAAW,YAAY;IAC3B,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;;;OAUG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9F;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,kBAAkB,GAAG,kBAAkB,CAEpF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/extension/types.ts"],"names":[],"mappings":"AAgKA,yEAAyE;AACzE,MAAM,UAAU,wBAAwB,CAAC,GAAuB;IAC9D,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Keep in sync with this package's `version` in package.json. */
|
|
2
|
+
export declare const VERSION = "0.1.0";
|
|
3
|
+
export { EntryType, isBatchOrigin } from './entry.js';
|
|
4
|
+
export type { BatchOrigin, BuiltinEntryType, Entry, RecordInput } from './entry.js';
|
|
5
|
+
export type { EntryQuery, TelescopeStore } from './store.js';
|
|
6
|
+
export { InMemoryTelescopeStore } from './stores/memory.js';
|
|
7
|
+
export type { InMemoryStoreOptions } from './stores/memory.js';
|
|
8
|
+
export { createTableStatements, createTelescopeTable, DEFAULT_TABLE_NAME, LucidTelescopeStore, } from './stores/lucid.js';
|
|
9
|
+
export type { CreateTableOptions, LucidDatabaseLike, LucidInsertBuilderLike, LucidQueryBuilderLike, LucidStoreOptions, TelescopeColumns, } from './stores/lucid.js';
|
|
10
|
+
export { storage } from './stores/factory.js';
|
|
11
|
+
export type { LucidStoreConfig, MemoryStoreConfig, StoreContext, StoreProvider, } from './stores/factory.js';
|
|
12
|
+
export { TelescopeService } from './service.js';
|
|
13
|
+
export type { CountBucket } from './service.js';
|
|
14
|
+
export { buildDiagnosticEntry, DIAGNOSTIC_ENTRY_TYPE, DiagnosticsWatcher, } from './diagnostics_watcher.js';
|
|
15
|
+
export type { DiagnosticEntryContent } from './diagnostics_watcher.js';
|
|
16
|
+
export { recordRequest } from './request_watcher.js';
|
|
17
|
+
export type { HttpContextLike, RecordRequestOptions, RequestEntryContent, } from './request_watcher.js';
|
|
18
|
+
export { buildExceptionInput, recordException, recordExceptionInStore, } from './exception_watcher.js';
|
|
19
|
+
export type { ExceptionEntryContent, RecordExceptionContext, } from './exception_watcher.js';
|
|
20
|
+
export { exceptionFamilyHash } from './exception_family_hash.js';
|
|
21
|
+
export type { ExceptionFamilyParts } from './exception_family_hash.js';
|
|
22
|
+
export { defineTelescopeExtension } from './extension/types.js';
|
|
23
|
+
export type { Column, ContainerLike, DashboardSection, DashboardSpec, DataBinding, DataProvider, ExtensionContext, ExtensionEntryType, LinkSpec, Panel, PanelThresholds, TelescopeExtension, } from './extension/types.js';
|
|
24
|
+
export { ExtensionRegistry } from './extension/registry.js';
|
|
25
|
+
export { defineConfig, resolveConfig } from './define_config.js';
|
|
26
|
+
export type { RedactConfig, ResolvedTelescopeConfig, TelescopeConfig, WatcherName, } from './define_config.js';
|
|
27
|
+
export { compileRedactSpec, DEFAULT_MASK, DEFAULT_REDACT_KEYS, redact, redactBounded, redactBoundedWith, } from './redaction/redact.js';
|
|
28
|
+
export type { CompiledRedactSpec, RedactBoundedResult, RedactOptions, } from './redaction/redact.js';
|
|
29
|
+
export { RedactingTelescopeStore } from './redaction/redacting_store.js';
|
|
30
|
+
export { getTelescopeRuntime, resetTelescopeRuntime, setTelescopeExtensionRegistry, setTelescopeRuntime, } from './registry.js';
|
|
31
|
+
export type { TelescopeRuntime } from './registry.js';
|
|
32
|
+
export { currentTraceId, getContextAccessor } from './context_accessor.js';
|
|
33
|
+
export type { ContextAccessor } from './context_accessor.js';
|
|
34
|
+
export { getDiagnosticsRegistry, isDiagnosticEvent, } from './diagnostics_registry.js';
|
|
35
|
+
export type { DiagnosticEvent, DiagnosticsRegistry } from './diagnostics_registry.js';
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGpF,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,aAAa,GACd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,WAAW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zE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Keep in sync with this package's `version` in package.json. */
|
|
2
|
+
export const VERSION = '0.1.0';
|
|
3
|
+
// — entry model —
|
|
4
|
+
export { EntryType, isBatchOrigin } from './entry.js';
|
|
5
|
+
export { InMemoryTelescopeStore } from './stores/memory.js';
|
|
6
|
+
export { createTableStatements, createTelescopeTable, DEFAULT_TABLE_NAME, LucidTelescopeStore, } from './stores/lucid.js';
|
|
7
|
+
export { storage } from './stores/factory.js';
|
|
8
|
+
// — query API —
|
|
9
|
+
export { TelescopeService } from './service.js';
|
|
10
|
+
// — watchers —
|
|
11
|
+
export { buildDiagnosticEntry, DIAGNOSTIC_ENTRY_TYPE, DiagnosticsWatcher, } from './diagnostics_watcher.js';
|
|
12
|
+
export { recordRequest } from './request_watcher.js';
|
|
13
|
+
export { buildExceptionInput, recordException, recordExceptionInStore, } from './exception_watcher.js';
|
|
14
|
+
export { exceptionFamilyHash } from './exception_family_hash.js';
|
|
15
|
+
// — extension SDK —
|
|
16
|
+
export { defineTelescopeExtension } from './extension/types.js';
|
|
17
|
+
export { ExtensionRegistry } from './extension/registry.js';
|
|
18
|
+
// — config —
|
|
19
|
+
export { defineConfig, resolveConfig } from './define_config.js';
|
|
20
|
+
// — redaction —
|
|
21
|
+
export { compileRedactSpec, DEFAULT_MASK, DEFAULT_REDACT_KEYS, redact, redactBounded, redactBoundedWith, } from './redaction/redact.js';
|
|
22
|
+
export { RedactingTelescopeStore } from './redaction/redacting_store.js';
|
|
23
|
+
// — runtime (advanced) —
|
|
24
|
+
export { getTelescopeRuntime, resetTelescopeRuntime, setTelescopeExtensionRegistry, setTelescopeRuntime, } from './registry.js';
|
|
25
|
+
// — structural ecosystem readers —
|
|
26
|
+
export { currentTraceId, getContextAccessor } from './context_accessor.js';
|
|
27
|
+
export { getDiagnosticsRegistry, isDiagnosticEvent, } from './diagnostics_registry.js';
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,kBAAkB;AAClB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAQ9C,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAe;AACf,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMrD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,oBAAoB;AACpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAehE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,aAAa;AACb,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQjE,gBAAgB;AAChB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,yBAAyB;AACzB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAGvB,mCAAmC;AACnC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default set of sensitive key names masked by {@link redact}. Matched
|
|
3
|
+
* case-insensitively at any depth. Mirrors the NestJS original 1:1.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_REDACT_KEYS: readonly string[];
|
|
6
|
+
/** The default replacement for a masked sensitive leaf. */
|
|
7
|
+
export declare const DEFAULT_MASK = "[REDACTED]";
|
|
8
|
+
export interface RedactOptions {
|
|
9
|
+
/** Extra keys to mask (merged with {@link DEFAULT_REDACT_KEYS}, case-insensitive). */
|
|
10
|
+
keys?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Exact dot-paths to mask regardless of key name, e.g. `'body.ssn'`.
|
|
13
|
+
* Unlike `keys` (which match that key at any depth), a path must match the
|
|
14
|
+
* full traversal location from the root of the value passed to {@link redact}.
|
|
15
|
+
*/
|
|
16
|
+
paths?: string[];
|
|
17
|
+
/** Replacement string. Defaults to {@link DEFAULT_MASK}. */
|
|
18
|
+
mask?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum object/array nesting depth to clone. Beyond it, the subtree is
|
|
21
|
+
* replaced with `'[Truncated: depth]'`. ON BY DEFAULT (8).
|
|
22
|
+
*/
|
|
23
|
+
maxDepth?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum cloned string length. Longer strings are clipped to the first N
|
|
26
|
+
* chars plus a `'…[truncated]'` suffix. ON BY DEFAULT (8_192).
|
|
27
|
+
*/
|
|
28
|
+
maxStringLength?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Maximum number of array items to clone. Longer arrays keep the first N items
|
|
31
|
+
* and append a final `'[Truncated: N of M items]'` marker element. ON BY
|
|
32
|
+
* DEFAULT (200).
|
|
33
|
+
*/
|
|
34
|
+
maxArrayLength?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Per-call walked-node budget: every object, array, and leaf visited counts
|
|
37
|
+
* against it. Once exhausted, remaining subtrees become `'[Truncated: size]'`.
|
|
38
|
+
* ON BY DEFAULT (5_000).
|
|
39
|
+
*/
|
|
40
|
+
maxNodes?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Approximate serialized-byte budget per cloned content: every string charges
|
|
43
|
+
* its length, every visited node a small fixed overhead. Once exhausted,
|
|
44
|
+
* remaining subtrees become `'[Truncated: size]'`. ON BY DEFAULT (16_384).
|
|
45
|
+
*/
|
|
46
|
+
maxContentBytes?: number;
|
|
47
|
+
}
|
|
48
|
+
/** Result of a bounded redaction: the detached clone plus whether anything was clipped. */
|
|
49
|
+
export interface RedactBoundedResult {
|
|
50
|
+
/** The detached, masked, bounded clone. */
|
|
51
|
+
value: unknown;
|
|
52
|
+
/** True when any bound (depth/string/array/node/byte) clipped some content. */
|
|
53
|
+
truncated: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The masking decision derived from {@link RedactOptions}, compiled ONCE so the
|
|
57
|
+
* per-entry hot path never rebuilds these Sets. `keySet` holds the lowercased
|
|
58
|
+
* union of {@link DEFAULT_REDACT_KEYS} and `options.keys`; `paths` holds the exact
|
|
59
|
+
* dot-paths. Build it via {@link compileRedactSpec} at boot and feed it to
|
|
60
|
+
* {@link redactBoundedWith}.
|
|
61
|
+
*/
|
|
62
|
+
export interface CompiledRedactSpec {
|
|
63
|
+
/** Lowercased union of default + configured keys, matched at any depth. */
|
|
64
|
+
keySet: ReadonlySet<string>;
|
|
65
|
+
/** Exact dot-paths to mask regardless of key name. */
|
|
66
|
+
paths: ReadonlySet<string>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Precompiles the immutable key/path Sets from {@link RedactOptions}. Call once
|
|
70
|
+
* (config is immutable after boot) and reuse the result across every entry.
|
|
71
|
+
*/
|
|
72
|
+
export declare function compileRedactSpec(options: RedactOptions): CompiledRedactSpec;
|
|
73
|
+
/**
|
|
74
|
+
* Bounded, never-throwing, SYNCHRONOUS deep clone of `value` with sensitive
|
|
75
|
+
* leaves masked. Same key/path masking semantics as {@link redact}, plus the
|
|
76
|
+
* hard memory bounds in {@link RedactOptions} (all defaulted on). Returns the
|
|
77
|
+
* clone AND whether truncation happened.
|
|
78
|
+
*/
|
|
79
|
+
export declare function redactBounded(value: unknown, options?: RedactOptions): RedactBoundedResult;
|
|
80
|
+
/**
|
|
81
|
+
* Bounded redaction using an ALREADY-COMPILED {@link CompiledRedactSpec}, so the
|
|
82
|
+
* per-entry hot path never rebuilds the key/path Sets. Identical behaviour to
|
|
83
|
+
* {@link redactBounded}; only the `keys`/`paths` of `options` are ignored in
|
|
84
|
+
* favour of the prebuilt `spec` (the remaining bound options are still read).
|
|
85
|
+
*/
|
|
86
|
+
export declare function redactBoundedWith(value: unknown, options: RedactOptions, spec: CompiledRedactSpec): RedactBoundedResult;
|
|
87
|
+
/**
|
|
88
|
+
* Returns a deep clone of `value` with sensitive leaves replaced by the mask.
|
|
89
|
+
* Never mutates the input. Memory-bounded by default (see {@link RedactOptions});
|
|
90
|
+
* delegates to {@link redactBounded} and discards the truncation flag.
|
|
91
|
+
*/
|
|
92
|
+
export declare function redact(value: unknown, options?: RedactOptions): unknown;
|
|
93
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../../src/redaction/redact.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAgBhD,CAAC;AAyBF,2DAA2D;AAC3D,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,2FAA2F;AAC3F,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf,+EAA+E;IAC/E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,sDAAsD;IACtD,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,kBAAkB,CAO5E;AAKD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,aAAkB,GAAG,mBAAmB,CAE9F;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,kBAAkB,GACvB,mBAAmB,CAqGrB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAE3E"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// packages/core/src/redaction/redact.ts
|
|
2
|
+
//
|
|
3
|
+
// Framework-agnostic, sensitive-data REDACTION. Ported from `nestjs-telescope`'s
|
|
4
|
+
// `redaction/redact.ts`: a bounded, never-throwing, cycle-safe deep clone that
|
|
5
|
+
// masks sensitive keys (case-insensitive) before content is persisted. Telescope
|
|
6
|
+
// wires it once at the store boundary so NO watcher can leak a secret into storage.
|
|
7
|
+
/**
|
|
8
|
+
* The default set of sensitive key names masked by {@link redact}. Matched
|
|
9
|
+
* case-insensitively at any depth. Mirrors the NestJS original 1:1.
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_REDACT_KEYS = [
|
|
12
|
+
'authorization',
|
|
13
|
+
'cookie',
|
|
14
|
+
'set-cookie',
|
|
15
|
+
'password',
|
|
16
|
+
'passwd',
|
|
17
|
+
'secret',
|
|
18
|
+
'token',
|
|
19
|
+
'access_token',
|
|
20
|
+
'refresh_token',
|
|
21
|
+
'api-key',
|
|
22
|
+
'api_key',
|
|
23
|
+
'apikey',
|
|
24
|
+
'x-api-key',
|
|
25
|
+
'client_secret',
|
|
26
|
+
'private_key',
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Hard, on-by-default bounds that cap how much {@link redact} clones from a single
|
|
30
|
+
* input. A captured payload (a request body, an ORM entity reachable from query
|
|
31
|
+
* bindings, a mail context) can be an arbitrarily large or deep graph; cloning it
|
|
32
|
+
* whole would let a single entry retain an unbounded snapshot. These defaults are
|
|
33
|
+
* generous enough that a NORMAL entry is cloned byte-identically and only bite on
|
|
34
|
+
* pathological mega-graphs.
|
|
35
|
+
*/
|
|
36
|
+
const DEFAULT_MAX_DEPTH = 8;
|
|
37
|
+
const DEFAULT_MAX_STRING_LENGTH = 8_192;
|
|
38
|
+
const DEFAULT_MAX_ARRAY_LENGTH = 200;
|
|
39
|
+
const DEFAULT_MAX_NODES = 5_000;
|
|
40
|
+
const DEFAULT_MAX_CONTENT_BYTES = 16_384;
|
|
41
|
+
/** Approximate per-node overhead charged against `maxContentBytes` (keys,
|
|
42
|
+
* punctuation, numbers — a coarse stand-in for serialized size). */
|
|
43
|
+
const NODE_BYTE_OVERHEAD = 8;
|
|
44
|
+
/** Marker substituted for a subtree pruned because it exceeded `maxDepth`. */
|
|
45
|
+
const DEPTH_MARKER = '[Truncated: depth]';
|
|
46
|
+
/** Suffix appended to a string clipped to `maxStringLength`. */
|
|
47
|
+
const STRING_TRUNCATION_SUFFIX = '…[truncated]';
|
|
48
|
+
/** Marker substituted for a subtree pruned because the node/byte budget ran out. */
|
|
49
|
+
const SIZE_MARKER = '[Truncated: size]';
|
|
50
|
+
/** The default replacement for a masked sensitive leaf. */
|
|
51
|
+
export const DEFAULT_MASK = '[REDACTED]';
|
|
52
|
+
/**
|
|
53
|
+
* Precompiles the immutable key/path Sets from {@link RedactOptions}. Call once
|
|
54
|
+
* (config is immutable after boot) and reuse the result across every entry.
|
|
55
|
+
*/
|
|
56
|
+
export function compileRedactSpec(options) {
|
|
57
|
+
return {
|
|
58
|
+
keySet: new Set([...DEFAULT_REDACT_KEYS, ...(options.keys ?? [])].map((key) => key.toLowerCase())),
|
|
59
|
+
paths: new Set(options.paths ?? []),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
63
|
+
/**
|
|
64
|
+
* Bounded, never-throwing, SYNCHRONOUS deep clone of `value` with sensitive
|
|
65
|
+
* leaves masked. Same key/path masking semantics as {@link redact}, plus the
|
|
66
|
+
* hard memory bounds in {@link RedactOptions} (all defaulted on). Returns the
|
|
67
|
+
* clone AND whether truncation happened.
|
|
68
|
+
*/
|
|
69
|
+
export function redactBounded(value, options = {}) {
|
|
70
|
+
return redactBoundedWith(value, options, compileRedactSpec(options));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Bounded redaction using an ALREADY-COMPILED {@link CompiledRedactSpec}, so the
|
|
74
|
+
* per-entry hot path never rebuilds the key/path Sets. Identical behaviour to
|
|
75
|
+
* {@link redactBounded}; only the `keys`/`paths` of `options` are ignored in
|
|
76
|
+
* favour of the prebuilt `spec` (the remaining bound options are still read).
|
|
77
|
+
*/
|
|
78
|
+
export function redactBoundedWith(value, options, spec) {
|
|
79
|
+
const mask = options.mask ?? DEFAULT_MASK;
|
|
80
|
+
const keySet = spec.keySet;
|
|
81
|
+
const paths = spec.paths;
|
|
82
|
+
const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
83
|
+
const maxStringLength = options.maxStringLength ?? DEFAULT_MAX_STRING_LENGTH;
|
|
84
|
+
const maxArrayLength = options.maxArrayLength ?? DEFAULT_MAX_ARRAY_LENGTH;
|
|
85
|
+
const maxNodes = options.maxNodes ?? DEFAULT_MAX_NODES;
|
|
86
|
+
const maxContentBytes = options.maxContentBytes ?? DEFAULT_MAX_CONTENT_BYTES;
|
|
87
|
+
const seen = new WeakSet();
|
|
88
|
+
// Mutable walk state: node + byte budgets and a truncation flag. Kept in the
|
|
89
|
+
// closure (not threaded through args) so the per-call accounting stays cheap.
|
|
90
|
+
let nodesRemaining = maxNodes;
|
|
91
|
+
let bytesRemaining = maxContentBytes;
|
|
92
|
+
let truncated = false;
|
|
93
|
+
const walk = (node, path, depth) => {
|
|
94
|
+
// Every visited node (object, array, or leaf) costs one node unit and a small
|
|
95
|
+
// byte overhead; strings additionally charge their length. Once either budget
|
|
96
|
+
// is gone, prune the rest of the graph regardless of its shape.
|
|
97
|
+
if (nodesRemaining <= 0 || bytesRemaining <= 0) {
|
|
98
|
+
truncated = true;
|
|
99
|
+
return SIZE_MARKER;
|
|
100
|
+
}
|
|
101
|
+
nodesRemaining -= 1;
|
|
102
|
+
bytesRemaining -= NODE_BYTE_OVERHEAD;
|
|
103
|
+
if (typeof node === 'string') {
|
|
104
|
+
const kept = node.length > maxStringLength ? maxStringLength : node.length;
|
|
105
|
+
bytesRemaining -= kept;
|
|
106
|
+
if (node.length > maxStringLength) {
|
|
107
|
+
truncated = true;
|
|
108
|
+
return `${node.slice(0, maxStringLength)}${STRING_TRUNCATION_SUFFIX}`;
|
|
109
|
+
}
|
|
110
|
+
return node;
|
|
111
|
+
}
|
|
112
|
+
// `seen` tracks only the current ancestor path (added on the way down, removed
|
|
113
|
+
// on the way up), so genuine cycles are caught while a non-cyclic shared
|
|
114
|
+
// reference appearing in two sibling positions is NOT a false hit.
|
|
115
|
+
if (Array.isArray(node)) {
|
|
116
|
+
if (seen.has(node))
|
|
117
|
+
return '[Circular]';
|
|
118
|
+
if (depth >= maxDepth) {
|
|
119
|
+
truncated = true;
|
|
120
|
+
return DEPTH_MARKER;
|
|
121
|
+
}
|
|
122
|
+
seen.add(node);
|
|
123
|
+
const limit = Math.min(node.length, maxArrayLength);
|
|
124
|
+
const mapped = [];
|
|
125
|
+
for (let index = 0; index < limit; index++) {
|
|
126
|
+
// Stop iterating the moment a budget runs out: ONE trailing marker, not
|
|
127
|
+
// one marker per remaining item (markers themselves cost bytes).
|
|
128
|
+
if (nodesRemaining <= 0 || bytesRemaining <= 0) {
|
|
129
|
+
truncated = true;
|
|
130
|
+
mapped.push(SIZE_MARKER);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
mapped.push(walk(node[index], path ? `${path}.${index}` : String(index), depth + 1));
|
|
134
|
+
}
|
|
135
|
+
if (node.length > maxArrayLength) {
|
|
136
|
+
truncated = true;
|
|
137
|
+
mapped.push(`[Truncated: ${maxArrayLength} of ${node.length} items]`);
|
|
138
|
+
}
|
|
139
|
+
seen.delete(node);
|
|
140
|
+
return mapped;
|
|
141
|
+
}
|
|
142
|
+
if (isPlainObject(node)) {
|
|
143
|
+
if (seen.has(node))
|
|
144
|
+
return '[Circular]';
|
|
145
|
+
if (depth >= maxDepth) {
|
|
146
|
+
truncated = true;
|
|
147
|
+
return DEPTH_MARKER;
|
|
148
|
+
}
|
|
149
|
+
seen.add(node);
|
|
150
|
+
const result = {};
|
|
151
|
+
for (const [key, child] of Object.entries(node)) {
|
|
152
|
+
// Stop iterating the moment a budget runs out: ONE trailing marker, not
|
|
153
|
+
// one marker per remaining field (keys + markers themselves cost bytes).
|
|
154
|
+
if (nodesRemaining <= 0 || bytesRemaining <= 0) {
|
|
155
|
+
truncated = true;
|
|
156
|
+
result['…'] = SIZE_MARKER;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
// Object keys are real serialized bytes — charge them too.
|
|
160
|
+
bytesRemaining -= key.length;
|
|
161
|
+
const childPath = path ? `${path}.${key}` : key;
|
|
162
|
+
if (keySet.has(key.toLowerCase()) || paths.has(childPath)) {
|
|
163
|
+
result[key] = mask;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
result[key] = walk(child, childPath, depth + 1);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
seen.delete(node);
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
return node;
|
|
173
|
+
};
|
|
174
|
+
return { value: walk(value, '', 0), truncated };
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Returns a deep clone of `value` with sensitive leaves replaced by the mask.
|
|
178
|
+
* Never mutates the input. Memory-bounded by default (see {@link RedactOptions});
|
|
179
|
+
* delegates to {@link redactBounded} and discards the truncation flag.
|
|
180
|
+
*/
|
|
181
|
+
export function redact(value, options = {}) {
|
|
182
|
+
return redactBounded(value, options).value;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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,2DAA2D;gBAC3D,cAAc,IAAI,GAAG,CAAC,MAAM,CAAC;gBAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;gBAChD,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC1D,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;gBACrB,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAClB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,UAAyB,EAAE;IAChE,OAAO,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Entry, RecordInput } from '../entry.js';
|
|
2
|
+
import type { EntryQuery, TelescopeStore } from '../store.js';
|
|
3
|
+
import { type RedactOptions } from './redact.js';
|
|
4
|
+
/**
|
|
5
|
+
* The CENTRAL redaction choke point. A {@link TelescopeStore} decorator whose
|
|
6
|
+
* `record()` masks the entry's `content` (and `tags`) through {@link redactBoundedWith}
|
|
7
|
+
* BEFORE delegating to the inner store — every other operation passes through
|
|
8
|
+
* untouched.
|
|
9
|
+
*
|
|
10
|
+
* Wiring redaction here, at the one boundary every watcher records through
|
|
11
|
+
* (`request`, `exception`, `diagnostic`, `lucid query` bindings, `mail`, `cache`,
|
|
12
|
+
* and any custom watcher), guarantees no watcher can bypass it: there is exactly
|
|
13
|
+
* one write path and it always scrubs. The key/path Sets are compiled ONCE at
|
|
14
|
+
* construction so the per-entry hot path never rebuilds them.
|
|
15
|
+
*/
|
|
16
|
+
export declare class RedactingTelescopeStore implements TelescopeStore {
|
|
17
|
+
private readonly inner;
|
|
18
|
+
private readonly options;
|
|
19
|
+
private readonly spec;
|
|
20
|
+
constructor(inner: TelescopeStore, options?: RedactOptions);
|
|
21
|
+
record<TContent>(input: RecordInput<TContent>): Promise<Entry<TContent>>;
|
|
22
|
+
get(id: string): Promise<Entry | null>;
|
|
23
|
+
list(query?: EntryQuery): Promise<Entry[]>;
|
|
24
|
+
count(): Promise<number>;
|
|
25
|
+
prune(olderThan: Date, keepLast?: number): Promise<number>;
|
|
26
|
+
clear(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=redacting_store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redacting_store.d.ts","sourceRoot":"","sources":["../../../src/redaction/redacting_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAwB,YAAW,cAAc;IAI1D,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;gBAGvB,KAAK,EAAE,cAAc,EACrB,OAAO,GAAE,aAAkB;IAKxC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAW9E,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAItC,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAI1C,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAIxB,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { compileRedactSpec, redactBoundedWith, } from './redact.js';
|
|
2
|
+
/**
|
|
3
|
+
* The CENTRAL redaction choke point. A {@link TelescopeStore} decorator whose
|
|
4
|
+
* `record()` masks the entry's `content` (and `tags`) through {@link redactBoundedWith}
|
|
5
|
+
* BEFORE delegating to the inner store — every other operation passes through
|
|
6
|
+
* untouched.
|
|
7
|
+
*
|
|
8
|
+
* Wiring redaction here, at the one boundary every watcher records through
|
|
9
|
+
* (`request`, `exception`, `diagnostic`, `lucid query` bindings, `mail`, `cache`,
|
|
10
|
+
* and any custom watcher), guarantees no watcher can bypass it: there is exactly
|
|
11
|
+
* one write path and it always scrubs. The key/path Sets are compiled ONCE at
|
|
12
|
+
* construction so the per-entry hot path never rebuilds them.
|
|
13
|
+
*/
|
|
14
|
+
export class RedactingTelescopeStore {
|
|
15
|
+
inner;
|
|
16
|
+
options;
|
|
17
|
+
spec;
|
|
18
|
+
constructor(inner, options = {}) {
|
|
19
|
+
this.inner = inner;
|
|
20
|
+
this.options = options;
|
|
21
|
+
this.spec = compileRedactSpec(options);
|
|
22
|
+
}
|
|
23
|
+
async record(input) {
|
|
24
|
+
const redacted = {
|
|
25
|
+
...input,
|
|
26
|
+
content: redactBoundedWith(input.content, this.options, this.spec).value,
|
|
27
|
+
};
|
|
28
|
+
if (input.tags !== undefined) {
|
|
29
|
+
redacted.tags = redactBoundedWith(input.tags, this.options, this.spec).value;
|
|
30
|
+
}
|
|
31
|
+
return this.inner.record(redacted);
|
|
32
|
+
}
|
|
33
|
+
get(id) {
|
|
34
|
+
return this.inner.get(id);
|
|
35
|
+
}
|
|
36
|
+
list(query) {
|
|
37
|
+
return this.inner.list(query);
|
|
38
|
+
}
|
|
39
|
+
count() {
|
|
40
|
+
return this.inner.count();
|
|
41
|
+
}
|
|
42
|
+
prune(olderThan, keepLast) {
|
|
43
|
+
return this.inner.prune(olderThan, keepLast);
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
return this.inner.clear();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=redacting_store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redacting_store.js","sourceRoot":"","sources":["../../../src/redaction/redacting_store.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,uBAAuB;IAIf;IACA;IAJF,IAAI,CAAqB;IAE1C,YACmB,KAAqB,EACrB,UAAyB,EAAE;QAD3B,UAAK,GAAL,KAAK,CAAgB;QACrB,YAAO,GAAP,OAAO,CAAoB;QAE5C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,MAAM,CAAW,KAA4B;QACjD,MAAM,QAAQ,GAA0B;YACtC,GAAG,KAAK;YACR,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAiB;SACrF,CAAC;QACF,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC7B,Q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