Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exports types, classes and interfaces #1775

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 35 additions & 40 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export = agent;

declare const agent: Agent;

declare class Agent implements Taggable, StartSpanFn {
export declare class Agent implements Taggable, StartSpanFn {
// Configuration
start (options?: AgentConfigOptions): Agent;
isStarted (): boolean;
Expand Down Expand Up @@ -40,11 +40,6 @@ declare class Agent implements Taggable, StartSpanFn {

// Distributed Tracing
currentTraceparent: string | null;
currentTraceIds: {
'trace.id'?: string;
'transaction.id'?: string;
'span.id'?: string;
}

// Transactions
startTransaction(
Expand Down Expand Up @@ -120,7 +115,7 @@ declare class Agent implements Taggable, StartSpanFn {
registerMetric(name: string, labels: Labels, callback: Function): void;
}

declare class GenericSpan implements Taggable {
export declare class GenericSpan implements Taggable {
// The following properties and methods are currently not documented as their API isn't considered official:
// timestamp, ended, id, traceId, parentId, sampled, duration()

Expand All @@ -134,7 +129,7 @@ declare class GenericSpan implements Taggable {
addLabels (labels: Labels): boolean;
}

declare class Transaction extends GenericSpan implements StartSpanFn {
export declare class Transaction extends GenericSpan implements StartSpanFn {
// The following properties and methods are currently not documented as their API isn't considered official:
// setUserContext(), setCustomContext(), toJSON(), setDefaultName(), setDefaultNameFromRequest()

Expand Down Expand Up @@ -167,7 +162,7 @@ declare class Transaction extends GenericSpan implements StartSpanFn {
end (result?: string | number | null, endTime?: number): void;
}

declare class Span extends GenericSpan {
export declare class Span extends GenericSpan {
// The following properties and methods are currently not documented as their API isn't considered official:
// customStackTrace(), setDbContext()

Expand All @@ -177,7 +172,7 @@ declare class Span extends GenericSpan {
end (endTime?: number): void;
}

interface AgentConfigOptions {
export interface AgentConfigOptions {
abortedErrorThreshold?: string; // Also support `number`, but as we're removing this functionality soon, there's no need to advertise it
active?: boolean;
addPatch?: KeyValueConfig;
Expand Down Expand Up @@ -230,7 +225,7 @@ interface AgentConfigOptions {
verifyServerCert?: boolean;
}

interface CaptureErrorOptions {
export interface CaptureErrorOptions {
request?: IncomingMessage;
response?: ServerResponse;
timestamp?: number;
Expand All @@ -242,22 +237,22 @@ interface CaptureErrorOptions {
message?: string;
}

interface Labels {
export interface Labels {
[key: string]: LabelValue;
}

interface UserObject {
export interface UserObject {
id?: string | number;
username?: string;
email?: string;
}

interface ParameterizedMessageObject {
export interface ParameterizedMessageObject {
message: string;
params: Array<any>;
}

interface Logger {
export interface Logger {
fatal (msg: string, ...args: any[]): void;
fatal (obj: {}, msg?: string, ...args: any[]): void;
error (msg: string, ...args: any[]): void;
Expand All @@ -273,39 +268,39 @@ interface Logger {
[propName: string]: any;
}

interface TransactionOptions {
export interface TransactionOptions {
startTime?: number;
childOf?: Transaction | Span | string;
}

interface SpanOptions {
export interface SpanOptions {
childOf?: Transaction | Span | string;
}

type CaptureBody = 'off' | 'errors' | 'transactions' | 'all';
type CaptureErrorLogStackTraces = 'never' | 'messages' | 'always';
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
export type CaptureBody = 'off' | 'errors' | 'transactions' | 'all';
export type CaptureErrorLogStackTraces = 'never' | 'messages' | 'always';
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';

type CaptureErrorCallback = (err: Error | null, id: string) => void;
type FilterFn = (payload: Payload) => Payload | boolean | void;
type LabelValue = string | number | boolean | null | undefined;
type KeyValueConfig = string | Labels | Array<Array<LabelValue>>
export type CaptureErrorCallback = (err: Error | null, id: string) => void;
export type FilterFn = (payload: Payload) => Payload | boolean | void;
export type LabelValue = string | number | boolean | null | undefined;
export type KeyValueConfig = string | Labels | Array<Array<LabelValue>>

type Payload = { [propName: string]: any }
export type Payload = { [propName: string]: any }

type PatchHandler = (exports: any, agent: Agent, options: PatchOptions) => any;
export type PatchHandler = (exports: any, agent: Agent, options: PatchOptions) => any;

interface PatchOptions {
export interface PatchOptions {
version: string | undefined,
enabled: boolean
}

interface Taggable {
export interface Taggable {
setLabel (name: string, value: LabelValue): boolean;
addLabels (labels: Labels): boolean;
}

interface StartSpanFn {
export interface StartSpanFn {
startSpan(
name?: string | null,
options?: SpanOptions
Expand All @@ -331,37 +326,37 @@ interface StartSpanFn {
}

// Inlined from @types/aws-lambda - start
declare namespace AwsLambda {
interface CognitoIdentity {
export declare namespace AwsLambda {
export interface CognitoIdentity {
cognitoIdentityId: string;
cognitoIdentityPoolId: string;
}

interface ClientContext {
export interface ClientContext {
client: ClientContextClient;
custom?: any;
env: ClientContextEnv;
}

interface ClientContextClient {
export interface ClientContextClient {
installationId: string;
appTitle: string;
appVersionName: string;
appVersionCode: string;
appPackageName: string;
}

interface ClientContextEnv {
export interface ClientContextEnv {
platformVersion: string;
platform: string;
make: string;
model: string;
locale: string;
}

type Callback<TResult = any> = (error?: Error | null | string, result?: TResult) => void;
export type Callback<TResult = any> = (error?: Error | null | string, result?: TResult) => void;

interface Context {
export interface Context {
// Properties
callbackWaitsForEmptyEventLoop: boolean;
functionName: string;
Expand All @@ -385,15 +380,15 @@ declare namespace AwsLambda {
succeed(message: string, object: any): void;
}

type Handler<TEvent = any, TResult = any> = (
export type Handler<TEvent = any, TResult = any> = (
event: TEvent,
context: Context,
callback: Callback<TResult>,
) => void | Promise<TResult>;
}

// Inlined from @types/connect - start
declare namespace Connect {
type NextFunction = (err?: any) => void;
type ErrorHandleFunction = (err: any, req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
export declare namespace Connect {
export type NextFunction = (err?: any) => void;
export type ErrorHandleFunction = (err: any, req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
}