@getcronit/pylon 1.2.0-beta.2 → 2.0.0-beta.1
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/dist/app/envelop/use-sentry.d.ts +70 -0
- package/dist/app/handler/graphql-handler.d.ts +9 -0
- package/dist/app/handler/graphql-viewer-handler.d.ts +2 -0
- package/dist/app/index.d.ts +3 -0
- package/dist/context.d.ts +2 -0
- package/dist/define-pylon.d.ts +9 -33
- package/dist/index.d.ts +3 -2
- package/dist/index.js +285 -3030
- package/dist/index.js.map +11 -32
- package/package.json +12 -3
- package/tsconfig.pylon.json +2 -4
- package/dist/logger/index.d.ts +0 -10
- package/dist/logger/winston-sentry-transport.d.ts +0 -23
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { isOriginalGraphQLError, TypedExecutionArgs, type Plugin } from '@envelop/core';
|
|
2
|
+
import * as Sentry from '@sentry/node';
|
|
3
|
+
import type { TraceparentData } from '@sentry/types';
|
|
4
|
+
export type SentryPluginOptions<PluginContext extends Record<string, any>> = {
|
|
5
|
+
/**
|
|
6
|
+
* Starts a new transaction for every GraphQL Operation.
|
|
7
|
+
* When disabled, an already existing Transaction will be used.
|
|
8
|
+
*
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
startTransaction?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Renames Transaction.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
renameTransaction?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Adds result of each resolver and operation to Span's data (available under "result")
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
includeRawResult?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Adds operation's variables to a Scope (only in case of errors)
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
includeExecuteVariables?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The key of the event id in the error's extension. `null` to disable.
|
|
29
|
+
* @default sentryEventId
|
|
30
|
+
*/
|
|
31
|
+
eventIdKey?: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Adds custom tags to every Transaction.
|
|
34
|
+
*/
|
|
35
|
+
appendTags?: (args: TypedExecutionArgs<PluginContext>) => Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* Callback to set context information onto the scope.
|
|
38
|
+
*/
|
|
39
|
+
configureScope?: (args: TypedExecutionArgs<PluginContext>, scope: Sentry.Scope) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Produces a name of Transaction (only when "renameTransaction" or "startTransaction" are enabled) and description of created Span.
|
|
42
|
+
*
|
|
43
|
+
* @default operation's name or "Anonymous Operation" when missing)
|
|
44
|
+
*/
|
|
45
|
+
transactionName?: (args: TypedExecutionArgs<PluginContext>) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Produces tracing data for Transaction
|
|
48
|
+
*
|
|
49
|
+
* @default is empty
|
|
50
|
+
*/
|
|
51
|
+
traceparentData?: (args: TypedExecutionArgs<PluginContext>) => TraceparentData | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Produces a "op" (operation) of created Span.
|
|
54
|
+
*
|
|
55
|
+
* @default execute
|
|
56
|
+
*/
|
|
57
|
+
operationName?: (args: TypedExecutionArgs<PluginContext>) => string;
|
|
58
|
+
/**
|
|
59
|
+
* Indicates whether or not to skip the entire Sentry flow for given GraphQL operation.
|
|
60
|
+
* By default, no operations are skipped.
|
|
61
|
+
*/
|
|
62
|
+
skip?: (args: TypedExecutionArgs<PluginContext>) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Indicates whether or not to skip Sentry exception reporting for a given error.
|
|
65
|
+
* By default, this plugin skips all `GraphQLError` errors and does not report it to Sentry.
|
|
66
|
+
*/
|
|
67
|
+
skipError?: (args: Error) => boolean;
|
|
68
|
+
};
|
|
69
|
+
export declare const defaultSkipError: typeof isOriginalGraphQLError;
|
|
70
|
+
export declare const useSentry: <PluginContext extends Record<string, any> = {}>(options?: SentryPluginOptions<PluginContext>) => Plugin<PluginContext>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Context } from '../../context';
|
|
2
|
+
export interface SchemaOptions {
|
|
3
|
+
typeDefs: string;
|
|
4
|
+
resolvers: {
|
|
5
|
+
Query: Record<string, any>;
|
|
6
|
+
Mutation: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare const graphqlHandler: (c: Context) => ({ typeDefs, resolvers }: SchemaOptions) => import("graphql-yoga").YogaServerInstance<{}, Context>;
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Context as HonoContext } from 'hono';
|
|
3
|
+
import type { Toucan } from 'toucan-js';
|
|
3
4
|
import { AuthState } from './auth';
|
|
4
5
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
5
6
|
export type Env = {
|
|
@@ -8,6 +9,7 @@ export type Env = {
|
|
|
8
9
|
};
|
|
9
10
|
Variables: {
|
|
10
11
|
auth: AuthState;
|
|
12
|
+
sentry: Toucan;
|
|
11
13
|
};
|
|
12
14
|
};
|
|
13
15
|
export type Context = HonoContext<Env, string, {}>;
|
package/dist/define-pylon.d.ts
CHANGED
|
@@ -1,38 +1,15 @@
|
|
|
1
|
-
/// <reference types="bun-types" />
|
|
2
1
|
import { GraphQLError, GraphQLErrorExtensions } from 'graphql';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { Context, Env } from './context';
|
|
6
|
-
export interface Resolvers<Q, M> {
|
|
7
|
-
Query: Q;
|
|
8
|
-
Mutation: M;
|
|
9
|
-
}
|
|
10
|
-
type WebSocketHandlerFunction<T extends Record<string, any>> = (server: Server) => WebSocketHandler<T>;
|
|
11
|
-
type Hono = _Hono<Env>;
|
|
12
|
-
export interface PylonAPI {
|
|
13
|
-
defineService: typeof defineService;
|
|
14
|
-
configureApp: (app: Hono) => Hono | void | Promise<void> | Promise<Hono>;
|
|
15
|
-
configureServer: (server: Server) => void;
|
|
16
|
-
configureWebsocket: WebSocketHandlerFunction<any>;
|
|
17
|
-
}
|
|
18
|
-
type SingleResolver = ((...args: any[]) => any) | object;
|
|
19
|
-
type ReturnTypeOrContext<T> = T extends (...args: any) => any ? ReturnType<T> : Context;
|
|
20
|
-
export declare const defineService: <Q extends Record<string, SingleResolver>, M, Options extends {
|
|
21
|
-
context: (context: Context) => ReturnTypeOrContext<Options["context"]>;
|
|
22
|
-
}>(plainResolvers: {
|
|
23
|
-
Query?: Q | undefined;
|
|
24
|
-
Mutation?: M | undefined;
|
|
25
|
-
}, options?: Options | undefined) => {
|
|
26
|
-
graphqlResolvers: GraphQLResolvers;
|
|
27
|
-
plainResolvers: Resolvers<Q & {
|
|
28
|
-
version: string;
|
|
29
|
-
}, M>;
|
|
30
|
-
getContext: () => ReturnType<Options["context"]>;
|
|
31
|
-
};
|
|
32
|
-
type GraphQLResolvers = {
|
|
2
|
+
import { Context } from './context';
|
|
3
|
+
export interface Resolvers {
|
|
33
4
|
Query: Record<string, any>;
|
|
34
5
|
Mutation: Record<string, any>;
|
|
35
|
-
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Converts a set of resolvers into a corresponding set of GraphQL resolvers.
|
|
9
|
+
* @param resolvers The original resolvers.
|
|
10
|
+
* @returns The converted GraphQL resolvers.
|
|
11
|
+
*/
|
|
12
|
+
export declare const resolversToGraphQLResolvers: (resolvers: Resolvers, configureContext?: ((context: Context) => Context) | undefined) => Resolvers;
|
|
36
13
|
export declare class ServiceError extends GraphQLError {
|
|
37
14
|
extensions: GraphQLErrorExtensions;
|
|
38
15
|
constructor(message: string, extensions: {
|
|
@@ -41,4 +18,3 @@ export declare class ServiceError extends GraphQLError {
|
|
|
41
18
|
details?: Record<string, any>;
|
|
42
19
|
}, error?: Error);
|
|
43
20
|
}
|
|
44
|
-
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { logger, getLogger } from './logger/index.js';
|
|
1
|
+
export { ServiceError } from './define-pylon.js';
|
|
3
2
|
export * from './auth/index.js';
|
|
4
3
|
export { Context, Env, asyncContext, getContext, setContext } from './context.js';
|
|
4
|
+
export { app } from './app/index.js';
|
|
5
|
+
export { graphqlHandler } from './app/handler/graphql-handler.js';
|