@envelop/prometheus 4.2.0 → 4.2.2-alpha-63e92f8.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.
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from '@envelop/types';
1
+ import { Plugin } from '@envelop/core';
2
2
  import { createHistogram, createCounter, FillLabelsFnParams, createSummary } from './utils';
3
3
  import { PrometheusTracingPluginConfig } from './config';
4
4
  export { PrometheusTracingPluginConfig, createCounter, createHistogram, createSummary, FillLabelsFnParams };
package/index.js CHANGED
@@ -2,20 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const promClient = require('prom-client');
5
+ const core = require('@envelop/core');
6
6
  const graphql = require('graphql');
7
-
8
- /**
9
- * Returns true if the provided object implements the AsyncIterator protocol via
10
- * implementing a `Symbol.asyncIterator` method.
11
- *
12
- * Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts
13
- */
14
- function isAsyncIterable(maybeAsyncIterable) {
15
- return (maybeAsyncIterable != null &&
16
- typeof maybeAsyncIterable === 'object' &&
17
- typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function');
18
- }
7
+ const promClient = require('prom-client');
19
8
 
20
9
  function shouldTraceFieldResolver(info, whitelist) {
21
10
  if (!whitelist) {
@@ -89,17 +78,6 @@ function extractDeprecatedFields(node, typeInfo) {
89
78
  return found;
90
79
  }
91
80
 
92
- /**
93
- * This enum is used only internally in order to create nominal type for the disabled plugin
94
- */
95
- var EnableIfBranded;
96
- (function (EnableIfBranded) {
97
- EnableIfBranded[EnableIfBranded["DisabledPlugin"] = 0] = "DisabledPlugin";
98
- })(EnableIfBranded || (EnableIfBranded = {}));
99
- function isIntrospectionOperationString(operation) {
100
- return (typeof operation === 'string' ? operation : operation.body).indexOf('__schema') !== -1;
101
- }
102
-
103
81
  /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
104
82
  const promPluginContext = Symbol('promPluginContext');
105
83
  const promPluginExecutionStartTimeSymbol = Symbol('promPluginExecutionStartTimeSymbol');
@@ -222,7 +200,7 @@ const usePrometheus = (config = {}) => {
222
200
  })
223
201
  : undefined;
224
202
  const onParse = ({ context, extendContext, params }) => {
225
- if (config.skipIntrospection && isIntrospectionOperationString(params.source)) {
203
+ if (config.skipIntrospection && core.isIntrospectionOperationString(params.source)) {
226
204
  return;
227
205
  }
228
206
  const startTime = Date.now();
@@ -303,7 +281,7 @@ const usePrometheus = (config = {}) => {
303
281
  const summaryTime = (Date.now() - args.contextValue[promPluginExecutionStartTimeSymbol]) / 1000;
304
282
  requestSummary.summary.observe(requestSummary.fillLabelsFn(args.contextValue[promPluginContext], args.contextValue), summaryTime);
305
283
  }
306
- if (errorsCounter && !isAsyncIterable(result) && result.errors && result.errors.length > 0) {
284
+ if (errorsCounter && !core.isAsyncIterable(result) && result.errors && result.errors.length > 0) {
307
285
  for (const error of result.errors) {
308
286
  errorsCounter.counter
309
287
  .labels(errorsCounter.fillLabelsFn({
package/index.mjs CHANGED
@@ -1,17 +1,6 @@
1
- import { Histogram, register, Summary, Counter } from 'prom-client';
1
+ import { isIntrospectionOperationString, isAsyncIterable } from '@envelop/core';
2
2
  import { visit, visitWithTypeInfo, TypeInfo } from 'graphql';
3
-
4
- /**
5
- * Returns true if the provided object implements the AsyncIterator protocol via
6
- * implementing a `Symbol.asyncIterator` method.
7
- *
8
- * Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts
9
- */
10
- function isAsyncIterable(maybeAsyncIterable) {
11
- return (maybeAsyncIterable != null &&
12
- typeof maybeAsyncIterable === 'object' &&
13
- typeof maybeAsyncIterable[Symbol.asyncIterator] === 'function');
14
- }
3
+ import { Histogram, register, Summary, Counter } from 'prom-client';
15
4
 
16
5
  function shouldTraceFieldResolver(info, whitelist) {
17
6
  if (!whitelist) {
@@ -85,17 +74,6 @@ function extractDeprecatedFields(node, typeInfo) {
85
74
  return found;
86
75
  }
87
76
 
88
- /**
89
- * This enum is used only internally in order to create nominal type for the disabled plugin
90
- */
91
- var EnableIfBranded;
92
- (function (EnableIfBranded) {
93
- EnableIfBranded[EnableIfBranded["DisabledPlugin"] = 0] = "DisabledPlugin";
94
- })(EnableIfBranded || (EnableIfBranded = {}));
95
- function isIntrospectionOperationString(operation) {
96
- return (typeof operation === 'string' ? operation : operation.body).indexOf('__schema') !== -1;
97
- }
98
-
99
77
  /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
100
78
  const promPluginContext = Symbol('promPluginContext');
101
79
  const promPluginExecutionStartTimeSymbol = Symbol('promPluginExecutionStartTimeSymbol');
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/prometheus",
3
- "version": "4.2.0",
3
+ "version": "4.2.2-alpha-63e92f8.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
+ "@envelop/core": "1.6.6-alpha-63e92f8.0",
6
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
7
8
  "prom-client": "^13 || ^14.0.0"
8
9
  },
@@ -27,6 +28,7 @@
27
28
  "./*": {
28
29
  "require": "./*.js",
29
30
  "import": "./*.mjs"
30
- }
31
+ },
32
+ "./package.json": "./package.json"
31
33
  }
32
34
  }
package/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { GraphQLError, DocumentNode, OperationDefinitionNode, GraphQLResolveInfo, TypeInfo, ASTNode } from 'graphql';
2
- import { AfterParseEventPayload } from '@envelop/types';
2
+ import { AfterParseEventPayload } from '@envelop/core';
3
3
  import { PrometheusTracingPluginConfig } from './config';
4
4
  import { Counter, Histogram, Summary } from 'prom-client';
5
5
  export declare type DeprecatedFieldInfo = {