@arcote.tech/arc 0.1.12 → 0.3.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 (154) hide show
  1. package/dist/adapters/auth-adapter.d.ts +47 -0
  2. package/dist/adapters/command-wire.d.ts +28 -0
  3. package/dist/adapters/event-publisher.d.ts +106 -0
  4. package/dist/adapters/event-wire.d.ts +79 -0
  5. package/dist/adapters/index.d.ts +18 -0
  6. package/dist/adapters/wire.d.ts +20 -0
  7. package/dist/context/context.d.ts +49 -52
  8. package/dist/context/index.d.ts +1 -10
  9. package/dist/context-element/command/command-context.d.ts +71 -0
  10. package/dist/context-element/command/command-data.d.ts +33 -0
  11. package/dist/context-element/command/command-handler.d.ts +6 -0
  12. package/dist/context-element/command/command.d.ts +198 -0
  13. package/dist/context-element/command/index.d.ts +6 -0
  14. package/dist/context-element/context-element.d.ts +75 -0
  15. package/dist/context-element/event/event-data.d.ts +35 -0
  16. package/dist/context-element/event/event.d.ts +158 -0
  17. package/dist/context-element/event/index.d.ts +5 -0
  18. package/dist/context-element/event/instance.d.ts +26 -0
  19. package/dist/context-element/index.d.ts +10 -0
  20. package/dist/context-element/view/index.d.ts +5 -0
  21. package/dist/context-element/view/view-context.d.ts +51 -0
  22. package/dist/context-element/view/view-data.d.ts +40 -0
  23. package/dist/context-element/view/view.d.ts +194 -0
  24. package/dist/data-storage/data-storage-forked.d.ts +1 -1
  25. package/dist/data-storage/data-storage-master.d.ts +7 -10
  26. package/dist/data-storage/data-storage-observable.d.ts +61 -0
  27. package/dist/data-storage/data-storage.abstract.d.ts +1 -1
  28. package/dist/{db/interface.d.ts → data-storage/database-adapter.d.ts} +8 -3
  29. package/dist/{database → data-storage}/database-store.d.ts +45 -0
  30. package/dist/data-storage/{types.d.ts → find-options.d.ts} +1 -1
  31. package/dist/data-storage/index.d.ts +6 -2
  32. package/dist/{db/postgresAdapter.d.ts → data-storage/postgresql-adapter.d.ts} +7 -33
  33. package/dist/data-storage/query-result-resolver.d.ts +18 -0
  34. package/dist/data-storage/query-result-resolver.test.d.ts +2 -0
  35. package/dist/{db/sqliteAdapter.d.ts → data-storage/sqlite-adapter.d.ts} +5 -31
  36. package/dist/data-storage/store-state-fork.d.ts +1 -1
  37. package/dist/data-storage/store-state-master.d.ts +6 -2
  38. package/dist/data-storage/store-state.abstract.d.ts +1 -1
  39. package/dist/elements/abstract.d.ts +1 -1
  40. package/dist/elements/any.d.ts +1 -1
  41. package/dist/elements/array.d.ts +5 -5
  42. package/dist/elements/blob.d.ts +1 -1
  43. package/dist/elements/boolean.d.ts +1 -1
  44. package/dist/elements/branded.d.ts +5 -5
  45. package/dist/elements/date.d.ts +1 -1
  46. package/dist/elements/default.d.ts +5 -5
  47. package/dist/elements/file.d.ts +1 -1
  48. package/dist/elements/id.d.ts +3 -3
  49. package/dist/elements/index.d.ts +1 -0
  50. package/dist/elements/number.d.ts +1 -1
  51. package/dist/elements/object.d.ts +11 -10
  52. package/dist/elements/optional.d.ts +5 -5
  53. package/dist/elements/or.d.ts +5 -5
  54. package/dist/elements/record.d.ts +3 -3
  55. package/dist/elements/string-enum.d.ts +1 -1
  56. package/dist/elements/string.d.ts +1 -1
  57. package/dist/index.d.ts +8 -7
  58. package/dist/index.js +2373 -3439
  59. package/dist/model/index.d.ts +2 -0
  60. package/dist/model/live-query/index.d.ts +2 -0
  61. package/dist/model/live-query/live-query.d.ts +31 -0
  62. package/dist/model/live-query/query-cache.d.ts +60 -0
  63. package/dist/model/model-adapters.d.ts +13 -0
  64. package/dist/model/model.d.ts +19 -78
  65. package/dist/model/mutation-executor/index.d.ts +2 -0
  66. package/dist/model/mutation-executor/mutation-executor.d.ts +29 -0
  67. package/dist/token/index.d.ts +41 -0
  68. package/dist/token/secured-data-storage.d.ts +125 -0
  69. package/dist/token/token-cache.d.ts +100 -0
  70. package/dist/token/token-data.d.ts +38 -0
  71. package/dist/token/token-instance.d.ts +71 -0
  72. package/dist/token/token.d.ts +127 -0
  73. package/dist/utils/index.d.ts +4 -0
  74. package/dist/utils/types/add-question-marks.d.ts +9 -0
  75. package/dist/utils/types/first-argument.d.ts +5 -0
  76. package/dist/utils/types/get-type.d.ts +13 -0
  77. package/dist/utils/types/index.d.ts +6 -0
  78. package/dist/utils/types/merge.d.ts +7 -0
  79. package/dist/utils/types/object-util.d.ts +6 -0
  80. package/dist/utils/types/simplify.d.ts +7 -0
  81. package/package.json +10 -6
  82. package/dist/command/command-definition.d.ts +0 -5
  83. package/dist/command/command.d.ts +0 -45
  84. package/dist/command/index.d.ts +0 -2
  85. package/dist/context/commands.d.ts +0 -12
  86. package/dist/context/element.d.ts +0 -80
  87. package/dist/context/event.d.ts +0 -45
  88. package/dist/context/query-builder-context.d.ts +0 -15
  89. package/dist/context/query-builders.d.ts +0 -17
  90. package/dist/context/query-cache.d.ts +0 -9
  91. package/dist/context/query.d.ts +0 -12
  92. package/dist/context/reactive-query.d.ts +0 -23
  93. package/dist/context/serializable-query.d.ts +0 -11
  94. package/dist/context/translator.d.ts +0 -4
  95. package/dist/database/database-mappers.d.ts +0 -39
  96. package/dist/database/index.d.ts +0 -3
  97. package/dist/db/index.d.ts +0 -4
  98. package/dist/listener/index.d.ts +0 -2
  99. package/dist/listener/listener.d.ts +0 -23
  100. package/dist/model/EventPublisher.d.ts +0 -12
  101. package/dist/model/event-publisher.d.ts +0 -12
  102. package/dist/query/query-definition.d.ts +0 -8
  103. package/dist/route/index.d.ts +0 -2
  104. package/dist/route/route.d.ts +0 -35
  105. package/dist/rtc/client.d.ts +0 -3
  106. package/dist/rtc/index.d.ts +0 -4
  107. package/dist/rtc/messages.d.ts +0 -20
  108. package/dist/rtc/rtc.d.ts +0 -11
  109. package/dist/server/query-handler.d.ts +0 -43
  110. package/dist/state/index.d.ts +0 -2
  111. package/dist/state/query-builder.d.ts +0 -2
  112. package/dist/state/query.d.ts +0 -2
  113. package/dist/state/state.d.ts +0 -2
  114. package/dist/strategies/cache-strategy.d.ts +0 -20
  115. package/dist/strategies/datastorage-strategy.d.ts +0 -15
  116. package/dist/strategies/index.d.ts +0 -7
  117. package/dist/strategies/leader-strategy.d.ts +0 -16
  118. package/dist/strategies/model-strategy.d.ts +0 -9
  119. package/dist/strategies/query-strategy.d.ts +0 -20
  120. package/dist/telemetry/context.d.ts +0 -65
  121. package/dist/telemetry/index.d.ts +0 -47
  122. package/dist/telemetry/interfaces.d.ts +0 -84
  123. package/dist/telemetry/logger.d.ts +0 -67
  124. package/dist/telemetry/no-op.d.ts +0 -54
  125. package/dist/telemetry/tracer.d.ts +0 -85
  126. package/dist/tests/context/context.test.d.ts +0 -2
  127. package/dist/tests/pipe.d.ts +0 -2
  128. package/dist/tests/query/advance-query.test.d.ts +0 -2
  129. package/dist/tests/query/collection-all.test.d.ts +0 -2
  130. package/dist/tests/utils/expect-not-false.d.ts +0 -2
  131. package/dist/tests/utils/sqlite-adapter.d.ts +0 -3
  132. package/dist/tests/utils/test-model.d.ts +0 -25
  133. package/dist/tests/validations/array.test.d.ts +0 -2
  134. package/dist/tests/validations/date.test.d.ts +0 -2
  135. package/dist/tests/validations/number.test.d.ts +0 -2
  136. package/dist/tests/validations/object.test.d.ts +0 -2
  137. package/dist/tests/validations/record.test.d.ts +0 -2
  138. package/dist/tests/validations/string-enum.test.d.ts +0 -2
  139. package/dist/tests/validations/string.test.d.ts +0 -2
  140. package/dist/utils.d.ts +0 -56
  141. package/dist/view/index.d.ts +0 -6
  142. package/dist/view/queries/abstract-view-query.d.ts +0 -19
  143. package/dist/view/queries/find-one.d.ts +0 -13
  144. package/dist/view/queries/find.d.ts +0 -21
  145. package/dist/view/queries/index.d.ts +0 -3
  146. package/dist/view/query-builders/find-one.d.ts +0 -14
  147. package/dist/view/query-builders/find.d.ts +0 -14
  148. package/dist/view/query-builders/index.d.ts +0 -2
  149. package/dist/view/query-builders/new-query-builder.d.ts +0 -2
  150. package/dist/view/record.d.ts +0 -4
  151. package/dist/view/static-view.d.ts +0 -43
  152. package/dist/view/view.d.ts +0 -68
  153. /package/dist/{database → data-storage}/schema-extraction.d.ts +0 -0
  154. /package/dist/{data-storage → utils}/deep-merge.d.ts +0 -0
@@ -1,8 +0,0 @@
1
- export type QueryDefinition<TResult = any> = {
2
- readonly contextElementName: string;
3
- readonly queryAlias: string;
4
- readonly parameters: any[];
5
- readonly restrictions?: any;
6
- };
7
- export type QueryDefinitionResult<QD extends QueryDefinition> = QD extends QueryDefinition<infer T> ? T : unknown;
8
- //# sourceMappingURL=query-definition.d.ts.map
@@ -1,2 +0,0 @@
1
- export * from "./route";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,35 +0,0 @@
1
- import type { ArcCommandContext } from "../context";
2
- import { ArcContextElement, type ArcContextElementAny } from "../context/element";
3
- export type ArcRouteHandler<ContextElements extends ArcContextElementAny[]> = (ctx: ArcCommandContext<ContextElements>, request: Request, params: Record<string, string>, url: URL) => Promise<Response> | Response;
4
- export type ArcRouteHandlers<ContextElements extends ArcContextElementAny[]> = {
5
- [Method in "GET" | "POST" | "PUT" | "DELETE" | "PATCH"]?: ArcRouteHandler<ContextElements>;
6
- };
7
- export declare class ArcRoute<Name extends string, const Elements extends ArcContextElementAny[]> extends ArcContextElement<null, Name> {
8
- readonly name: Name;
9
- private _description?;
10
- private _path?;
11
- private _elements?;
12
- private _handlers?;
13
- private _isPublic;
14
- constructor(name: Name);
15
- use<const E extends ArcContextElementAny[]>(elements: E): ArcRoute<Name, E>;
16
- description(description: string): ArcRoute<Name, Elements>;
17
- path(path: string): ArcRoute<Name, Elements>;
18
- public(): ArcRoute<Name, Elements>;
19
- get isPublic(): boolean;
20
- get routePath(): string;
21
- handle(handlers: ArcRouteHandlers<Elements>): ArcRoute<Name, Elements>;
22
- getHandler(method: string): ArcRouteHandler<Elements> | undefined;
23
- matchesPath(pathname: string): {
24
- matches: boolean;
25
- params: Record<string, string>;
26
- };
27
- matchesRoutePath(pathname: string): {
28
- matches: boolean;
29
- isPublic: boolean;
30
- params?: Record<string, string>;
31
- };
32
- private clone;
33
- }
34
- export declare function route<Name extends string>(name: Name): ArcRoute<Name, any[]>;
35
- //# sourceMappingURL=route.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { RealTimeCommunicationAdapterFactory } from "./rtc";
2
- export declare const rtcClientFactory: (token: string) => RealTimeCommunicationAdapterFactory;
3
- //# sourceMappingURL=client.d.ts.map
@@ -1,4 +0,0 @@
1
- export * from "./client";
2
- export * from "./messages";
3
- export * from "./rtc";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,20 +0,0 @@
1
- import type { DataStorageChanges } from "../data-storage/data-storage.abstract";
2
- export type MessageClientToHost = {
3
- type: "sync";
4
- lastDate: string | null;
5
- } | {
6
- type: "changes-executed";
7
- changes: DataStorageChanges[];
8
- };
9
- export type MessageHostToClient = {
10
- type: "sync-result";
11
- store: string;
12
- items: any[];
13
- } | {
14
- type: "state-changes";
15
- changes: DataStorageChanges[];
16
- } | {
17
- type: "sync-done";
18
- date: string;
19
- };
20
- //# sourceMappingURL=messages.d.ts.map
package/dist/rtc/rtc.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { MasterDataStorage } from "../data-storage";
2
- import type { DataStorageChanges } from "../data-storage/data-storage.abstract";
3
- export interface RealTimeCommunicationAdapter {
4
- commitChanges(changes: DataStorageChanges[]): void;
5
- sync(progressCallback: ({ store, size }: {
6
- store: string;
7
- size: number;
8
- }) => void): Promise<void>;
9
- }
10
- export type RealTimeCommunicationAdapterFactory = (storage: MasterDataStorage) => RealTimeCommunicationAdapter;
11
- //# sourceMappingURL=rtc.d.ts.map
@@ -1,43 +0,0 @@
1
- import type { ArcContextAny } from "../context";
2
- import type { AuthContext } from "../context/element";
3
- import type { DataStorage } from "../data-storage";
4
- import { QueryDefinition } from "../strategies";
5
- export declare class QueryHandler<C extends ArcContextAny> {
6
- private model;
7
- constructor(context: C, dataStorage: DataStorage, catchErrorCallback?: (error: any) => void);
8
- /**
9
- * Handle HTTP query requests
10
- */
11
- handleQuery(queryDefinition: QueryDefinition, authContext: AuthContext): Promise<any>;
12
- /**
13
- * Handle HTTP query requests with streaming for real-time updates
14
- */
15
- handleQueryWithStream(queryDefinition: QueryDefinition, authContext: AuthContext, streamCallback: (result: any) => void): Promise<any>;
16
- /**
17
- * Handle query sync requests for cache strategy
18
- */
19
- handleQuerySync(queryDefinition: QueryDefinition, authContext: AuthContext, syncData: {
20
- id: string;
21
- version?: string;
22
- }[]): Promise<{
23
- updates: any[];
24
- }>;
25
- }
26
- /**
27
- * Helper function to create HTTP handlers for different frameworks
28
- */
29
- export declare function createHttpQueryHandlers<C extends ArcContextAny>(context: C, dataStorage: DataStorage, catchErrorCallback?: (error: any) => void): {
30
- /**
31
- * Handle POST /query
32
- */
33
- handleQueryRequest: (req: Request) => Promise<Response>;
34
- /**
35
- * Handle POST /query-stream/:streamId
36
- */
37
- handleQueryStreamRequest: (req: Request, streamId: string) => Promise<Response>;
38
- /**
39
- * Handle POST /query-sync
40
- */
41
- handleQuerySyncRequest: (req: Request) => Promise<Response>;
42
- };
43
- //# sourceMappingURL=query-handler.d.ts.map
@@ -1,2 +0,0 @@
1
- export * from "./state";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=query-builder.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=query.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=state.d.ts.map
@@ -1,20 +0,0 @@
1
- import type { ArcContextAny } from "../context";
2
- import type { AuthContext } from "../context/element";
3
- import type { DataStorage } from "../data-storage";
4
- import type { QueryDefinition } from "../query/query-definition";
5
- import type { CommandDefinition } from "../command/command-definition";
6
- import type { ModelStrategy } from "./model-strategy";
7
- export declare class CacheStrategy<C extends ArcContextAny> implements ModelStrategy {
8
- private readonly dataStorage;
9
- private dataStorageStrategy;
10
- private leaderStrategy;
11
- constructor(context: C, dataStorage: DataStorage, apiBaseUrl: string);
12
- setAuthToken(token: string | null): void;
13
- query<TResult = any>(queryDefinition: QueryDefinition<TResult>, authContext: AuthContext, callback?: (result: TResult) => void): Promise<TResult>;
14
- command(commandDefinition: CommandDefinition, authContext: AuthContext): Promise<any>;
15
- private extractSyncData;
16
- private syncWithLeader;
17
- private updateCache;
18
- private establishLiveUpdates;
19
- }
20
- //# sourceMappingURL=cache-strategy.d.ts.map
@@ -1,15 +0,0 @@
1
- import type { ArcContextAny } from "../context";
2
- import type { AuthContext } from "../context/element";
3
- import type { DataStorage } from "../data-storage";
4
- import type { QueryDefinition } from "../query/query-definition";
5
- import type { CommandDefinition } from "../command/command-definition";
6
- import type { ModelStrategy } from "./model-strategy";
7
- export declare class DataStorageStrategy<C extends ArcContextAny> implements ModelStrategy {
8
- private readonly context;
9
- readonly dataStorage: DataStorage;
10
- private readonly catchErrorCallback?;
11
- constructor(context: C, dataStorage: DataStorage, catchErrorCallback?: ((error: any) => void) | undefined);
12
- query<TResult = any>(queryDefinition: QueryDefinition<TResult>, authContext: AuthContext, callback?: (result: TResult) => void): Promise<TResult>;
13
- command(commandDefinition: CommandDefinition, authContext: AuthContext): Promise<any>;
14
- }
15
- //# sourceMappingURL=datastorage-strategy.d.ts.map
@@ -1,7 +0,0 @@
1
- export * from "./model-strategy";
2
- export * from "./datastorage-strategy";
3
- export * from "./leader-strategy";
4
- export * from "./cache-strategy";
5
- export type { QueryDefinition } from "../query/query-definition";
6
- export type { CommandDefinition } from "../command/command-definition";
7
- //# sourceMappingURL=index.d.ts.map
@@ -1,16 +0,0 @@
1
- import type { AuthContext } from "../context/element";
2
- import type { QueryDefinition } from "../query/query-definition";
3
- import type { CommandDefinition } from "../command/command-definition";
4
- import type { ModelStrategy } from "./model-strategy";
5
- export declare class LeaderStrategy implements ModelStrategy {
6
- private readonly apiBaseUrl;
7
- private token;
8
- constructor(apiBaseUrl: string);
9
- setAuthToken(token: string | null): void;
10
- query<TResult = any>(queryDefinition: QueryDefinition<TResult>, authContext: AuthContext, callback?: (result: TResult) => void): Promise<TResult>;
11
- private queryWithStream;
12
- private readStream;
13
- command(commandDefinition: CommandDefinition, authContext: AuthContext): Promise<any>;
14
- private getAuthHeaders;
15
- }
16
- //# sourceMappingURL=leader-strategy.d.ts.map
@@ -1,9 +0,0 @@
1
- import type { AuthContext } from "../context/element";
2
- import type { QueryDefinition } from "../query/query-definition";
3
- import type { CommandDefinition } from "../command/command-definition";
4
- export interface ModelStrategy {
5
- query<TResult = any>(queryDefinition: QueryDefinition<TResult>, authContext: AuthContext, callback?: (result: TResult) => void): Promise<TResult>;
6
- command(commandDefinition: CommandDefinition, authContext: AuthContext): Promise<any>;
7
- setAuthToken?(token: string | null): void;
8
- }
9
- //# sourceMappingURL=model-strategy.d.ts.map
@@ -1,20 +0,0 @@
1
- import type { AuthContext } from "../context/element";
2
- export interface QueryDefinition {
3
- contextElementName: string;
4
- queryAlias: string;
5
- parameters: any[];
6
- restrictions?: any;
7
- }
8
- export interface CommandDefinition {
9
- contextElementName: string;
10
- parameters: any;
11
- }
12
- export interface ModelStrategy {
13
- query(queryDefinition: QueryDefinition, authContext: AuthContext, callback?: (result: any) => void): Promise<any>;
14
- command(commandDefinition: CommandDefinition, authContext: AuthContext): Promise<any>;
15
- setAuthToken?(token: string | null): void;
16
- }
17
- export interface QueryStrategy extends ModelStrategy {
18
- execute(queryDefinition: QueryDefinition, authContext: AuthContext, callback?: (result: any) => void): Promise<any>;
19
- }
20
- //# sourceMappingURL=query-strategy.d.ts.map
@@ -1,65 +0,0 @@
1
- import type { Span } from '@opentelemetry/api';
2
- import type { AuthContext } from '../context/element';
3
- import { ArcLogger } from './logger';
4
- /**
5
- * Extended context that includes telemetry capabilities
6
- */
7
- export interface ArcTelemetryContext {
8
- /**
9
- * Log a message with automatic trace context
10
- */
11
- log: ArcLogger;
12
- /**
13
- * Create a child span for a specific operation
14
- */
15
- startSpan(name: string, attributes?: Record<string, string | number | boolean>): Span;
16
- /**
17
- * Execute a function within a new span
18
- */
19
- withSpan<T>(name: string, fn: (span: Span) => Promise<T> | T, attributes?: Record<string, string | number | boolean>): Promise<T>;
20
- /**
21
- * Add attributes to the current span
22
- */
23
- addSpanAttributes(attributes: Record<string, string | number | boolean>): void;
24
- /**
25
- * Add an event to the current span
26
- */
27
- addSpanEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
28
- /**
29
- * Record an exception in the current span
30
- */
31
- recordException(error: Error | string): void;
32
- /**
33
- * Get the current trace ID
34
- */
35
- getTraceId(): string | undefined;
36
- /**
37
- * Get the current span ID
38
- */
39
- getSpanId(): string | undefined;
40
- }
41
- /**
42
- * Create telemetry context for command/event handlers
43
- */
44
- export declare function createTelemetryContext(authContext: AuthContext, operationType: 'command' | 'event' | 'listener' | 'view', operationName: string): ArcTelemetryContext;
45
- /**
46
- * Extract trace context from headers (for HTTP requests)
47
- */
48
- export declare function extractTraceContext(headers: Record<string, string | string[] | undefined>): import("@opentelemetry/api").Context;
49
- /**
50
- * Inject trace context into headers (for outgoing HTTP requests)
51
- */
52
- export declare function injectTraceContext(headers?: Record<string, string>): Record<string, string>;
53
- /**
54
- * Run a function with extracted trace context
55
- */
56
- export declare function withExtractedContext<T>(headers: Record<string, string | string[] | undefined>, fn: () => T): T;
57
- /**
58
- * Get telemetry information from current context
59
- */
60
- export declare function getCurrentTelemetryInfo(): {
61
- traceId: string | undefined;
62
- spanId: string | undefined;
63
- isRecording: boolean;
64
- };
65
- //# sourceMappingURL=context.d.ts.map
@@ -1,47 +0,0 @@
1
- export type { TelemetryProvider, TelemetryContext, Logger, SpanOptions, DatabaseTelemetry } from './interfaces';
2
- export { NoOpLogger, NoOpTelemetryContext, NoOpTelemetryProvider, NoOpDatabaseTelemetry, noOpTelemetryProvider, noOpDatabaseTelemetry, } from './no-op';
3
- export declare const initializeTelemetry: (...args: any[]) => never;
4
- export declare const getTelemetry: () => null;
5
- export declare const startSpan: (...args: any[]) => never;
6
- export declare const withSpan: (...args: any[]) => never;
7
- export declare const ArcTelemetry: {
8
- new (): {};
9
- };
10
- export declare const initializeLogger: (...args: any[]) => never;
11
- export declare const getLogger: () => never;
12
- export declare const ArcLogger: {
13
- new (): {};
14
- };
15
- export declare const createTelemetryContext: (...args: any[]) => never;
16
- export declare const extractTraceContext: (...args: any[]) => never;
17
- export declare const injectTraceContext: (...args: any[]) => never;
18
- export declare const withExtractedContext: (...args: any[]) => never;
19
- export declare const getCurrentTelemetryInfo: () => {
20
- traceId: undefined;
21
- spanId: undefined;
22
- isRecording: boolean;
23
- };
24
- export type TelemetryConfig = any;
25
- export type LogContext = Record<string, any>;
26
- export type LogEntry = any;
27
- export type ArcTelemetryContext = any;
28
- export declare const SpanKind: {
29
- readonly INTERNAL: "internal";
30
- readonly SERVER: "server";
31
- readonly CLIENT: "client";
32
- readonly PRODUCER: "producer";
33
- readonly CONSUMER: "consumer";
34
- };
35
- export declare const SpanStatusCode: {
36
- readonly UNSET: 0;
37
- readonly OK: 1;
38
- readonly ERROR: 2;
39
- };
40
- export declare const LogLevel: {
41
- readonly ERROR: "error";
42
- readonly WARN: "warn";
43
- readonly INFO: "info";
44
- readonly DEBUG: "debug";
45
- readonly TRACE: "trace";
46
- };
47
- //# sourceMappingURL=index.d.ts.map
@@ -1,84 +0,0 @@
1
- import type { AuthContext } from '../context/element';
2
- /**
3
- * Environment-agnostic telemetry context that handlers receive
4
- * Automatically correlates logs with trace IDs
5
- */
6
- export interface TelemetryContext {
7
- /**
8
- * Logging methods that auto-correlate with trace ID
9
- */
10
- log: {
11
- info(message: string, context?: Record<string, any>): void;
12
- error(message: string, context?: Record<string, any>, error?: Error): void;
13
- debug(message: string, context?: Record<string, any>): void;
14
- warn(message: string, context?: Record<string, any>): void;
15
- command(name: string, message: string, context?: Record<string, any>): void;
16
- event(type: string, message: string, context?: Record<string, any>): void;
17
- database(operation: string, message: string, context?: Record<string, any>): void;
18
- http(method: string, path: string, statusCode: number, duration: number, context?: Record<string, any>): void;
19
- };
20
- /**
21
- * Span management (automatically correlates logs with traces)
22
- */
23
- startSpan(name: string, attributes?: Record<string, string | number | boolean>): void;
24
- addAttributes(attributes: Record<string, string | number | boolean>): void;
25
- addEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
26
- recordException(error: Error | string): void;
27
- /**
28
- * Trace correlation info
29
- */
30
- getTraceId(): string | undefined;
31
- getSpanId(): string | undefined;
32
- }
33
- /**
34
- * Span options for creating new spans
35
- */
36
- export interface SpanOptions {
37
- kind?: 'client' | 'server' | 'internal' | 'producer' | 'consumer';
38
- attributes?: Record<string, string | number | boolean>;
39
- }
40
- /**
41
- * Main telemetry provider interface that environments must implement
42
- */
43
- export interface TelemetryProvider {
44
- /**
45
- * Create a logger instance
46
- */
47
- createLogger(name: string): Logger;
48
- /**
49
- * Execute function within a span context
50
- */
51
- withSpan<T>(name: string, fn: (context: TelemetryContext) => Promise<T> | T, options?: SpanOptions): Promise<T>;
52
- /**
53
- * Create telemetry context for command/route handlers
54
- */
55
- createTelemetryContext(authContext: AuthContext, operationType: 'command' | 'event' | 'listener' | 'view' | 'route', operationName: string): TelemetryContext;
56
- /**
57
- * Check if telemetry is enabled
58
- */
59
- isEnabled(): boolean;
60
- }
61
- /**
62
- * Basic logger interface
63
- */
64
- export interface Logger {
65
- info(message: string, context?: Record<string, any>): void;
66
- error(message: string, context?: Record<string, any>, error?: Error): void;
67
- debug(message: string, context?: Record<string, any>): void;
68
- warn(message: string, context?: Record<string, any>): void;
69
- command(name: string, message: string, context?: Record<string, any>): void;
70
- event(type: string, message: string, context?: Record<string, any>): void;
71
- database(operation: string, message: string, context?: Record<string, any>): void;
72
- http(method: string, path: string, statusCode: number, duration: number, context?: Record<string, any>): void;
73
- child(context: Record<string, any>): Logger;
74
- }
75
- /**
76
- * Database telemetry interface for adapters
77
- */
78
- export interface DatabaseTelemetry {
79
- /**
80
- * Execute a database operation with telemetry
81
- */
82
- withDatabaseOperation<T>(operation: string, sql: string, params: any[] | undefined, tableName: string | undefined, fn: () => Promise<T>): Promise<T>;
83
- }
84
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1,67 +0,0 @@
1
- export declare enum LogLevel {
2
- ERROR = "error",
3
- WARN = "warn",
4
- INFO = "info",
5
- DEBUG = "debug",
6
- TRACE = "trace"
7
- }
8
- interface LogContext {
9
- [key: string]: any;
10
- }
11
- interface LogEntry {
12
- level: LogLevel;
13
- message: string;
14
- context?: LogContext;
15
- timestamp?: string;
16
- traceId?: string;
17
- spanId?: string;
18
- userId?: string;
19
- requestId?: string;
20
- command?: string;
21
- event?: string;
22
- error?: Error;
23
- }
24
- declare class ArcLogger {
25
- private serviceName;
26
- constructor(serviceName?: string);
27
- private createLogEntry;
28
- private formatForConsole;
29
- private output;
30
- private getSeverityNumber;
31
- error(message: string, context?: LogContext, error?: Error): void;
32
- warn(message: string, context?: LogContext): void;
33
- info(message: string, context?: LogContext): void;
34
- debug(message: string, context?: LogContext): void;
35
- trace(message: string, context?: LogContext): void;
36
- /**
37
- * Log command execution
38
- */
39
- command(commandName: string, message: string, context?: LogContext): void;
40
- /**
41
- * Log event processing
42
- */
43
- event(eventType: string, message: string, context?: LogContext): void;
44
- /**
45
- * Log database operations
46
- */
47
- database(operation: string, message: string, context?: LogContext): void;
48
- /**
49
- * Log HTTP requests
50
- */
51
- http(method: string, path: string, statusCode: number, duration: number, context?: LogContext): void;
52
- /**
53
- * Create a child logger with additional context
54
- */
55
- child(context: LogContext): ArcLogger;
56
- }
57
- /**
58
- * Initialize global logger
59
- */
60
- export declare function initializeLogger(serviceName?: string): ArcLogger;
61
- /**
62
- * Get the global logger instance
63
- */
64
- export declare function getLogger(): ArcLogger;
65
- export { ArcLogger };
66
- export type { LogContext, LogEntry };
67
- //# sourceMappingURL=logger.d.ts.map
@@ -1,54 +0,0 @@
1
- import type { TelemetryProvider, TelemetryContext, Logger, DatabaseTelemetry } from './interfaces';
2
- /**
3
- * No-op logger implementation for when telemetry is disabled
4
- */
5
- export declare class NoOpLogger implements Logger {
6
- info(): void;
7
- error(): void;
8
- debug(): void;
9
- warn(): void;
10
- command(): void;
11
- event(): void;
12
- database(): void;
13
- http(): void;
14
- child(): Logger;
15
- }
16
- /**
17
- * No-op telemetry context for when telemetry is disabled
18
- */
19
- export declare class NoOpTelemetryContext implements TelemetryContext {
20
- private logger;
21
- log: NoOpLogger;
22
- startSpan(): void;
23
- addAttributes(): void;
24
- addEvent(): void;
25
- recordException(): void;
26
- getTraceId(): undefined;
27
- getSpanId(): undefined;
28
- }
29
- /**
30
- * No-op telemetry provider for when telemetry is disabled
31
- */
32
- export declare class NoOpTelemetryProvider implements TelemetryProvider {
33
- private logger;
34
- private context;
35
- createLogger(): Logger;
36
- withSpan<T>(name: string, fn: (context: TelemetryContext) => Promise<T> | T): Promise<T>;
37
- createTelemetryContext(): TelemetryContext;
38
- isEnabled(): boolean;
39
- }
40
- /**
41
- * No-op database telemetry for when telemetry is disabled
42
- */
43
- export declare class NoOpDatabaseTelemetry implements DatabaseTelemetry {
44
- withDatabaseOperation<T>(operation: string, sql: string, params: any[] | undefined, tableName: string | undefined, fn: () => Promise<T>): Promise<T>;
45
- }
46
- /**
47
- * Default no-op telemetry provider instance
48
- */
49
- export declare const noOpTelemetryProvider: NoOpTelemetryProvider;
50
- /**
51
- * Default no-op database telemetry instance
52
- */
53
- export declare const noOpDatabaseTelemetry: NoOpDatabaseTelemetry;
54
- //# sourceMappingURL=no-op.d.ts.map
@@ -1,85 +0,0 @@
1
- import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
2
- import type { Span } from "@opentelemetry/api";
3
- interface TelemetryConfig {
4
- serviceName: string;
5
- serviceVersion: string;
6
- environment: string;
7
- otlpEndpoint?: string;
8
- enabled?: boolean;
9
- }
10
- declare class ArcTelemetry {
11
- private sdk?;
12
- private tracer;
13
- private logger;
14
- private config;
15
- constructor(config: TelemetryConfig);
16
- private initialize;
17
- /**
18
- * Create a new span for tracing operations
19
- */
20
- startSpan(name: string, options?: {
21
- kind?: SpanKind;
22
- attributes?: Record<string, string | number | boolean>;
23
- parent?: Span;
24
- }): Span;
25
- /**
26
- * Execute a function within a span context
27
- */
28
- withSpan<T>(name: string, fn: (span: Span) => Promise<T> | T, options?: {
29
- kind?: SpanKind;
30
- attributes?: Record<string, string | number | boolean>;
31
- }): Promise<T>;
32
- /**
33
- * Add attributes to the current active span
34
- */
35
- addSpanAttributes(attributes: Record<string, string | number | boolean>): void;
36
- /**
37
- * Add an event to the current active span
38
- */
39
- addSpanEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
40
- /**
41
- * Record an exception in the current span
42
- */
43
- recordException(error: Error | string): void;
44
- /**
45
- * Shutdown telemetry (call on app shutdown)
46
- */
47
- shutdown(): Promise<void>;
48
- /**
49
- * Check if telemetry is enabled
50
- */
51
- get isEnabled(): boolean;
52
- /**
53
- * Get the current tracer instance
54
- */
55
- getTracer(): any;
56
- /**
57
- * Get the current logger instance
58
- */
59
- getLogger(): any;
60
- }
61
- /**
62
- * Initialize global telemetry
63
- */
64
- export declare function initializeTelemetry(config: TelemetryConfig): ArcTelemetry;
65
- /**
66
- * Get the global telemetry instance
67
- */
68
- export declare function getTelemetry(): ArcTelemetry | null;
69
- /**
70
- * Helper function to create a span
71
- */
72
- export declare function startSpan(name: string, options?: {
73
- kind?: SpanKind;
74
- attributes?: Record<string, string | number | boolean>;
75
- }): Span;
76
- /**
77
- * Helper function to execute code within a span
78
- */
79
- export declare function withSpan<T>(name: string, fn: (span: Span) => Promise<T> | T, options?: {
80
- kind?: SpanKind;
81
- attributes?: Record<string, string | number | boolean>;
82
- }): Promise<T>;
83
- export { ArcTelemetry, SpanKind, SpanStatusCode };
84
- export type { TelemetryConfig };
85
- //# sourceMappingURL=tracer.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=context.test.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=pipe.d.ts.map