@routier/core 0.3.0 → 0.5.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.
Files changed (35) hide show
  1. package/README.md +2 -2
  2. package/dist/index.cjs +549 -462
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.js +554 -462
  6. package/dist/index.js.map +1 -1
  7. package/dist/plugins/TelemetryDbPlugin.d.ts +43 -0
  8. package/dist/plugins/index.cjs +538 -24
  9. package/dist/plugins/index.cjs.map +1 -1
  10. package/dist/plugins/index.d.ts +1 -0
  11. package/dist/plugins/index.js +544 -22
  12. package/dist/plugins/index.js.map +1 -1
  13. package/dist/plugins/query/QueryOptionsCollection.d.ts +13 -0
  14. package/dist/plugins/query/explain.d.ts +82 -0
  15. package/dist/plugins/query/formatExplanation.d.ts +9 -0
  16. package/dist/plugins/query/index.d.ts +2 -0
  17. package/dist/plugins/query/types.d.ts +11 -0
  18. package/dist/plugins/types.d.ts +43 -1
  19. package/dist/plugins/wire/types.d.ts +17 -1
  20. package/dist/utilities/index.cjs +43 -12
  21. package/dist/utilities/index.cjs.map +1 -1
  22. package/dist/utilities/index.js +43 -12
  23. package/dist/utilities/index.js.map +1 -1
  24. package/package.json +6 -10
  25. package/dist/capabilities/Capability.d.ts +0 -11
  26. package/dist/capabilities/PerformanceCapability.d.ts +0 -13
  27. package/dist/capabilities/TracingCapability.d.ts +0 -11
  28. package/dist/capabilities/index.cjs +0 -820
  29. package/dist/capabilities/index.cjs.map +0 -1
  30. package/dist/capabilities/index.d.ts +0 -4
  31. package/dist/capabilities/index.js +0 -808
  32. package/dist/capabilities/index.js.map +0 -1
  33. package/dist/capabilities/performance/PerformanceTracker.d.ts +0 -11
  34. package/dist/capabilities/tracing/CallTraceManager.d.ts +0 -12
  35. package/dist/capabilities/types.d.ts +0 -17
@@ -0,0 +1,43 @@
1
+ import { BulkPersistResult } from "../collections";
2
+ import { PluginEventCallbackPartialResult, PluginEventCallbackResult } from "../results";
3
+ import { ITranslatedValue } from "./translators";
4
+ import { DbPluginBulkPersistEvent, DbPluginEvent, DbPluginQueryEvent, IDbPlugin } from "./types";
5
+ /**
6
+ * Measures every operation an inner plugin performs and hands one event per call to a sink.
7
+ *
8
+ * ```ts
9
+ * const store = new MyStore(new TelemetryDbPlugin(new SomeDbPlugin(...)));
10
+ * ```
11
+ */
12
+ export type TelemetryEvent = {
13
+ operation: "query" | "bulkPersist" | "destroy";
14
+ /** `id` of the plugin event that produced this measurement. */
15
+ eventId: string;
16
+ /** The class/component that triggered the operation (`event.source`). */
17
+ source: string;
18
+ /** Collection names involved, from `event.schemas`. */
19
+ schemas: string[];
20
+ durationMs: number;
21
+ ok: "success" | "partial" | "error";
22
+ /** Present when ok is "error" or "partial". */
23
+ error?: unknown;
24
+ };
25
+ export type TelemetrySink = (e: TelemetryEvent) => void;
26
+ export type TelemetryDbPluginOptions = {
27
+ /** Where events go. Default: `loggerSink()`. */
28
+ onEvent?: TelemetrySink;
29
+ };
30
+ /** Default sink: writes through the levelled logger, so ROUTIER_LOG_LEVEL governs it. */
31
+ export declare const loggerSink: () => TelemetrySink;
32
+ /** Pushes every event into `into`. For tests and custom buffering. */
33
+ export declare const collectingSink: (into: TelemetryEvent[]) => TelemetrySink;
34
+ export declare class TelemetryDbPlugin implements IDbPlugin {
35
+ private readonly plugin;
36
+ private readonly onEvent;
37
+ constructor(plugin: IDbPlugin, options?: TelemetryDbPluginOptions);
38
+ get databaseName(): string;
39
+ query<TRoot extends {}, TShape extends any = TRoot>(event: DbPluginQueryEvent<TRoot, TShape>, done: PluginEventCallbackResult<ITranslatedValue<TShape>>): void;
40
+ bulkPersist(event: DbPluginBulkPersistEvent, done: PluginEventCallbackPartialResult<BulkPersistResult>): void;
41
+ destroy(event: DbPluginEvent, done: PluginEventCallbackResult<never>): void;
42
+ private emit;
43
+ }