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

Typescript definition #54

Open
JoHuang opened this issue Jun 9, 2020 · 4 comments
Open

Typescript definition #54

JoHuang opened this issue Jun 9, 2020 · 4 comments

Comments

@JoHuang
Copy link

JoHuang commented Jun 9, 2020

I would like to use this package as module in a Typescript project.
However I can't find typescript definition.
It would be great to have it for integrating into Typescript projects.

@xxzefgh
Copy link

xxzefgh commented Apr 7, 2022

this should be enough

declare module 'pino-elasticsearch' {
  import {DestinationStream} from 'pino';
  import {ConnectionOptions as TlsConnectionOptions} from 'tls';
  import Connection, {AgentOptions} from '@elastic/elasticsearch/lib/Connection';
  import {BasicAuth, ApiKeyAuth, BearerAuth} from '@elastic/elasticsearch/lib/pool';

  type DynamicIndexFunction = (logTime: string) => string;

  interface NodeOptions {
    url: URL;
    id?: string;
    agent?: AgentOptions;
    ssl?: TlsConnectionOptions;
    headers?: Record<string, any>;
    roles?: {
      master: boolean;
      data: boolean;
      ingest: boolean;
      ml: boolean;
    };
  }

  export interface Options {
    index?: string | DynamicIndexFunction;
    op_type?: string;
    'es-version'?: number;
    'flush-bytes'?: number;
    node?: string | string[] | NodeOptions | NodeOptions[];
    auth?: BasicAuth | ApiKeyAuth | BearerAuth;
    cloud?: {
      id: string;
      // TODO: remove username and password here in 8
      username?: string;
      password?: string;
    };
    ssl?: TlsConnectionOptions;
    Connection?: typeof Connection;
  }

  export default function pinoElasticSearch(opts: Options): DestinationStream;
}

@mikemajesty
Copy link

+1

@mcollina
Copy link
Member

Would you like to send a Pull Request to address this issue? Remember to add unit tests, we use tsd for types.

@jongsun112
Copy link

plz help ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants