@promster/apollo 14.0.0 → 15.0.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 suǝʞǝǝpʇ
3
+ Copyright (c) 2025 suǝʞǝǝpʇ
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- import { type TPromsterOptions, createPlugin, signalIsUp, signalIsNotUp } from "./plugin/index.js";
2
- import { getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers, timing } from '@promster/metrics';
1
+ import { Prometheus, defaultNormalizers, defaultRegister, getContentType, getSummary, timing } from '@promster/metrics';
2
+ import { type TPromsterOptions, createPlugin, signalIsNotUp, signalIsUp } from "./plugin/index.js";
3
3
  export { type TPromsterOptions, createPlugin, signalIsUp, signalIsNotUp, getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers, timing, };
4
4
  export * from '@promster/types';
@@ -1,2 +1,2 @@
1
- import { type TPromsterOptions, createPlugin, signalIsUp, signalIsNotUp } from "./plugin.js";
1
+ import { type TPromsterOptions, createPlugin, signalIsNotUp, signalIsUp } from "./plugin.js";
2
2
  export { type TPromsterOptions, createPlugin, signalIsUp, signalIsNotUp };
@@ -1,6 +1,6 @@
1
- import { type ApolloServerPlugin, type BaseContext, type GraphQLRequestContext, type GraphQLRequest } from '@apollo/server';
2
- import { type TOptionalPromsterOptions, type TLabelValues } from '@promster/types';
3
- import { type TRequestRecorder } from '@promster/metrics';
1
+ import type { ApolloServerPlugin, BaseContext, GraphQLRequest, GraphQLRequestContext } from '@apollo/server';
2
+ import type { TRequestRecorder } from '@promster/metrics';
3
+ import type { TLabelValues, TOptionalPromsterOptions } from '@promster/types';
4
4
  declare const getRequestRecorder: () => TRequestRecorder;
5
5
  declare const signalIsUp: () => void;
6
6
  declare const signalIsNotUp: () => void;
@@ -1,2 +1,2 @@
1
- export * from "./declarations/src/index";
1
+ export * from "./declarations/src/index.js";
2
2
  //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvbXN0ZXItYXBvbGxvLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var merge = require('merge-options');
6
5
  var metrics = require('@promster/metrics');
6
+ var merge = require('merge-options');
7
7
  var types = require('@promster/types');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -15,17 +15,17 @@ const signalIsUp = () => {
15
15
  if (!upMetric) {
16
16
  return;
17
17
  }
18
- upMetric.forEach(upMetricType => {
18
+ for (const upMetricType of upMetric) {
19
19
  upMetricType.set(1);
20
- });
20
+ }
21
21
  };
22
22
  const signalIsNotUp = () => {
23
23
  if (!upMetric) {
24
24
  return;
25
25
  }
26
- upMetric.forEach(upMetricType => {
26
+ for (const upMetricType of upMetric) {
27
27
  upMetricType.set(0);
28
- });
28
+ }
29
29
  };
30
30
  const createPlugin = ({
31
31
  options
@@ -46,7 +46,6 @@ const createPlugin = ({
46
46
  function getDefaultLabelsOrSkipMeasurement(requestContext) {
47
47
  var _allDefaultedOptions$, _allDefaultedOptions$2;
48
48
  const labels = Object.assign({}, {
49
- // eslint-disable-next-line camelcase
50
49
  operation_name: requestContext.request.operationName
51
50
  }, (_allDefaultedOptions$ = allDefaultedOptions.getLabelValues) === null || _allDefaultedOptions$ === void 0 ? void 0 : _allDefaultedOptions$.call(allDefaultedOptions, requestContext.request, requestContext.response));
52
51
  const shouldSkipByRequest = (_allDefaultedOptions$2 = allDefaultedOptions.skip) === null || _allDefaultedOptions$2 === void 0 ? void 0 : _allDefaultedOptions$2.call(allDefaultedOptions, requestContext.request, requestContext.response, labels);
@@ -75,18 +74,20 @@ const createPlugin = ({
75
74
  } = parseTiming.end().value();
76
75
  const labels = getDefaultLabelsOrSkipMeasurement(parsingRequestContext);
77
76
  if (parseDurationSeconds !== undefined) {
78
- var _graphQlMetrics$graph;
79
- (_graphQlMetrics$graph = graphQlMetrics.graphQlParseDuration) === null || _graphQlMetrics$graph === void 0 || _graphQlMetrics$graph.forEach(metric => {
80
- metric.observe(labels, parseDurationSeconds);
81
- });
77
+ if (graphQlMetrics.graphQlParseDuration) {
78
+ for (const metric of graphQlMetrics.graphQlParseDuration) {
79
+ metric.observe(labels, parseDurationSeconds);
80
+ }
81
+ }
82
82
  }
83
83
  if (error) {
84
- var _graphQlMetrics$graph2;
85
- (_graphQlMetrics$graph2 = graphQlMetrics.graphQlErrorsTotal) === null || _graphQlMetrics$graph2 === void 0 || _graphQlMetrics$graph2.forEach(metric => {
86
- metric.inc(Object.assign({}, labels, {
87
- phase: 'parsing'
88
- }));
89
- });
84
+ if (graphQlMetrics.graphQlErrorsTotal) {
85
+ for (const metric of graphQlMetrics.graphQlErrorsTotal) {
86
+ metric.inc(Object.assign({}, labels, {
87
+ phase: 'parsing'
88
+ }));
89
+ }
90
+ }
90
91
  }
91
92
  };
92
93
  },
@@ -98,18 +99,20 @@ const createPlugin = ({
98
99
  } = validationTiming.end().value();
99
100
  const labels = getDefaultLabelsOrSkipMeasurement(validationRequestContext);
100
101
  if (validationDurationSeconds !== undefined) {
101
- var _graphQlMetrics$graph3;
102
- (_graphQlMetrics$graph3 = graphQlMetrics.graphQlValidationDuration) === null || _graphQlMetrics$graph3 === void 0 || _graphQlMetrics$graph3.forEach(metric => {
103
- metric.observe(labels, validationDurationSeconds);
104
- });
102
+ if (graphQlMetrics.graphQlValidationDuration) {
103
+ for (const metric of graphQlMetrics.graphQlValidationDuration) {
104
+ metric.observe(labels, validationDurationSeconds);
105
+ }
106
+ }
105
107
  }
106
108
  if (error) {
107
- var _graphQlMetrics$graph4;
108
- (_graphQlMetrics$graph4 = graphQlMetrics.graphQlErrorsTotal) === null || _graphQlMetrics$graph4 === void 0 || _graphQlMetrics$graph4.forEach(metric => {
109
- metric.inc(Object.assign({}, labels, {
110
- phase: 'validation'
111
- }));
112
- });
109
+ if (graphQlMetrics.graphQlErrorsTotal) {
110
+ for (const metric of graphQlMetrics.graphQlErrorsTotal) {
111
+ metric.inc(Object.assign({}, labels, {
112
+ phase: 'validation'
113
+ }));
114
+ }
115
+ }
113
116
  }
114
117
  };
115
118
  },
@@ -125,22 +128,23 @@ const createPlugin = ({
125
128
  } = fieldResolveTiming.end().value();
126
129
  const defaultLabels = getDefaultLabelsOrSkipMeasurement(executionRequestContext);
127
130
  const labels = Object.assign({}, defaultLabels, {
128
- // eslint-disable-next-line camelcase
129
131
  field_name: info.fieldName
130
132
  });
131
133
  if (fieldResolveDurationSeconds !== undefined) {
132
- var _graphQlMetrics$graph5;
133
- (_graphQlMetrics$graph5 = graphQlMetrics.graphQlResolveFieldDuration) === null || _graphQlMetrics$graph5 === void 0 || _graphQlMetrics$graph5.forEach(metric => {
134
- metric.observe(labels, fieldResolveDurationSeconds);
135
- });
134
+ if (graphQlMetrics.graphQlResolveFieldDuration) {
135
+ for (const metric of graphQlMetrics.graphQlResolveFieldDuration) {
136
+ metric.observe(labels, fieldResolveDurationSeconds);
137
+ }
138
+ }
136
139
  }
137
140
  if (error) {
138
- var _graphQlMetrics$graph6;
139
- (_graphQlMetrics$graph6 = graphQlMetrics.graphQlErrorsTotal) === null || _graphQlMetrics$graph6 === void 0 || _graphQlMetrics$graph6.forEach(metric => {
140
- metric.inc(Object.assign({}, labels, {
141
- phase: 'execution'
142
- }));
143
- });
141
+ if (graphQlMetrics.graphQlErrorsTotal) {
142
+ for (const metric of graphQlMetrics.graphQlErrorsTotal) {
143
+ metric.inc(Object.assign({}, labels, {
144
+ phase: 'execution'
145
+ }));
146
+ }
147
+ }
144
148
  }
145
149
  };
146
150
  }
@@ -152,10 +156,11 @@ const createPlugin = ({
152
156
  } = requestTiming.end().value();
153
157
  const labels = getDefaultLabelsOrSkipMeasurement(responseRequestContext);
154
158
  if (requestDurationSeconds !== undefined) {
155
- var _graphQlMetrics$graph7;
156
- (_graphQlMetrics$graph7 = graphQlMetrics.graphQlRequestDuration) === null || _graphQlMetrics$graph7 === void 0 || _graphQlMetrics$graph7.forEach(metric => {
157
- metric.observe(labels, requestDurationSeconds);
158
- });
159
+ if (graphQlMetrics.graphQlRequestDuration) {
160
+ for (const metric of graphQlMetrics.graphQlRequestDuration) {
161
+ metric.observe(labels, requestDurationSeconds);
162
+ }
163
+ }
159
164
  }
160
165
  }
161
166
  };
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var merge = require('merge-options');
6
5
  var metrics = require('@promster/metrics');
6
+ var merge = require('merge-options');
7
7
  var types = require('@promster/types');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -15,17 +15,17 @@ const signalIsUp = () => {
15
15
  if (!upMetric) {
16
16
  return;
17
17
  }
18
- upMetric.forEach(upMetricType => {
18
+ for (const upMetricType of upMetric) {
19
19
  upMetricType.set(1);
20
- });
20
+ }
21
21
  };
22
22
  const signalIsNotUp = () => {
23
23
  if (!upMetric) {
24
24
  return;
25
25
  }
26
- upMetric.forEach(upMetricType => {
26
+ for (const upMetricType of upMetric) {
27
27
  upMetricType.set(0);
28
- });
28
+ }
29
29
  };
30
30
  const createPlugin = ({
31
31
  options
@@ -46,7 +46,6 @@ const createPlugin = ({
46
46
  function getDefaultLabelsOrSkipMeasurement(requestContext) {
47
47
  var _allDefaultedOptions$, _allDefaultedOptions$2;
48
48
  const labels = Object.assign({}, {
49
- // eslint-disable-next-line camelcase
50
49
  operation_name: requestContext.request.operationName
51
50
  }, (_allDefaultedOptions$ = allDefaultedOptions.getLabelValues) === null || _allDefaultedOptions$ === void 0 ? void 0 : _allDefaultedOptions$.call(allDefaultedOptions, requestContext.request, requestContext.response));
52
51
  const shouldSkipByRequest = (_allDefaultedOptions$2 = allDefaultedOptions.skip) === null || _allDefaultedOptions$2 === void 0 ? void 0 : _allDefaultedOptions$2.call(allDefaultedOptions, requestContext.request, requestContext.response, labels);
@@ -75,18 +74,20 @@ const createPlugin = ({
75
74
  } = parseTiming.end().value();
76
75
  const labels = getDefaultLabelsOrSkipMeasurement(parsingRequestContext);
77
76
  if (parseDurationSeconds !== undefined) {
78
- var _graphQlMetrics$graph;
79
- (_graphQlMetrics$graph = graphQlMetrics.graphQlParseDuration) === null || _graphQlMetrics$graph === void 0 || _graphQlMetrics$graph.forEach(metric => {
80
- metric.observe(labels, parseDurationSeconds);
81
- });
77
+ if (graphQlMetrics.graphQlParseDuration) {
78
+ for (const metric of graphQlMetrics.graphQlParseDuration) {
79
+ metric.observe(labels, parseDurationSeconds);
80
+ }
81
+ }
82
82
  }
83
83
  if (error) {
84
- var _graphQlMetrics$graph2;
85
- (_graphQlMetrics$graph2 = graphQlMetrics.graphQlErrorsTotal) === null || _graphQlMetrics$graph2 === void 0 || _graphQlMetrics$graph2.forEach(metric => {
86
- metric.inc(Object.assign({}, labels, {
87
- phase: 'parsing'
88
- }));
89
- });
84
+ if (graphQlMetrics.graphQlErrorsTotal) {
85
+ for (const metric of graphQlMetrics.graphQlErrorsTotal) {
86
+ metric.inc(Object.assign({}, labels, {
87
+ phase: 'parsing'
88
+ }));
89
+ }
90
+ }
90
91
  }
91
92
  };
92
93
  },
@@ -98,18 +99,20 @@ const createPlugin = ({
98
99
  } = validationTiming.end().value();
99
100
  const labels = getDefaultLabelsOrSkipMeasurement(validationRequestContext);
100
101
  if (validationDurationSeconds !== undefined) {
101
- var _graphQlMetrics$graph3;
102
- (_graphQlMetrics$graph3 = graphQlMetrics.graphQlValidationDuration) === null || _graphQlMetrics$graph3 === void 0 || _graphQlMetrics$graph3.forEach(metric => {
103
- metric.observe(labels, validationDurationSeconds);
104
- });
102
+ if (graphQlMetrics.graphQlValidationDuration) {
103
+ for (const metric of graphQlMetrics.graphQlValidationDuration) {
104
+ metric.observe(labels, validationDurationSeconds);
105
+ }
106
+ }
105
107
  }
106
108
  if (error) {
107
- var _graphQlMetrics$graph4;
108
- (_graphQlMetrics$graph4 = graphQlMetrics.graphQlErrorsTotal) === null || _graphQlMetrics$graph4 === void 0 || _graphQlMetrics$graph4.forEach(metric => {
109
- metric.inc(Object.assign({}, labels, {
110
- phase: 'validation'
111
- }));
112
- });
109
+ if (graphQlMetrics.graphQlErrorsTotal) {
110
+ for (const metric of graphQlMetrics.graphQlErrorsTotal) {
111
+ metric.inc(Object.assign({}, labels, {
112
+ phase: 'validation'
113
+ }));
114
+ }
115
+ }
113
116
  }
114
117
  };
115
118
  },
@@ -125,22 +128,23 @@ const createPlugin = ({
125
128
  } = fieldResolveTiming.end().value();
126
129
  const defaultLabels = getDefaultLabelsOrSkipMeasurement(executionRequestContext);
127
130
  const labels = Object.assign({}, defaultLabels, {
128
- // eslint-disable-next-line camelcase
129
131
  field_name: info.fieldName
130
132
  });
131
133
  if (fieldResolveDurationSeconds !== undefined) {
132
- var _graphQlMetrics$graph5;
133
- (_graphQlMetrics$graph5 = graphQlMetrics.graphQlResolveFieldDuration) === null || _graphQlMetrics$graph5 === void 0 || _graphQlMetrics$graph5.forEach(metric => {
134
- metric.observe(labels, fieldResolveDurationSeconds);
135
- });
134
+ if (graphQlMetrics.graphQlResolveFieldDuration) {
135
+ for (const metric of graphQlMetrics.graphQlResolveFieldDuration) {
136
+ metric.observe(labels, fieldResolveDurationSeconds);
137
+ }
138
+ }
136
139
  }
137
140
  if (error) {
138
- var _graphQlMetrics$graph6;
139
- (_graphQlMetrics$graph6 = graphQlMetrics.graphQlErrorsTotal) === null || _graphQlMetrics$graph6 === void 0 || _graphQlMetrics$graph6.forEach(metric => {
140
- metric.inc(Object.assign({}, labels, {
141
- phase: 'execution'
142
- }));
143
- });
141
+ if (graphQlMetrics.graphQlErrorsTotal) {
142
+ for (const metric of graphQlMetrics.graphQlErrorsTotal) {
143
+ metric.inc(Object.assign({}, labels, {
144
+ phase: 'execution'
145
+ }));
146
+ }
147
+ }
144
148
  }
145
149
  };
146
150
  }
@@ -152,10 +156,11 @@ const createPlugin = ({
152
156
  } = requestTiming.end().value();
153
157
  const labels = getDefaultLabelsOrSkipMeasurement(responseRequestContext);
154
158
  if (requestDurationSeconds !== undefined) {
155
- var _graphQlMetrics$graph7;
156
- (_graphQlMetrics$graph7 = graphQlMetrics.graphQlRequestDuration) === null || _graphQlMetrics$graph7 === void 0 || _graphQlMetrics$graph7.forEach(metric => {
157
- metric.observe(labels, requestDurationSeconds);
158
- });
159
+ if (graphQlMetrics.graphQlRequestDuration) {
160
+ for (const metric of graphQlMetrics.graphQlRequestDuration) {
161
+ metric.observe(labels, requestDurationSeconds);
162
+ }
163
+ }
159
164
  }
160
165
  }
161
166
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promster/apollo",
3
- "version": "14.0.0",
3
+ "version": "15.0.1",
4
4
  "description": "Apollo server integrations of promster",
5
5
  "main": "dist/promster-apollo.cjs.js",
6
6
  "typings": "dist/promster-apollo.cjs.d.ts",
@@ -36,18 +36,18 @@
36
36
  "prometheus"
37
37
  ],
38
38
  "dependencies": {
39
- "@apollo/server": "4.10.2",
40
- "@promster/metrics": "^14.0.0",
41
- "@promster/types": "^14.0.0",
39
+ "@apollo/server": "4.10.5",
42
40
  "merge-options": "3.0.4",
43
- "tslib": "2.6.2"
41
+ "tslib": "2.8.1",
42
+ "@promster/metrics": "15.0.1",
43
+ "@promster/types": "15.0.1"
44
44
  },
45
45
  "devDependencies": {
46
- "@graphql-tools/schema": "10.0.3",
47
- "@graphql-tools/utils": "10.1.2",
46
+ "@graphql-tools/schema": "10.0.23",
47
+ "@graphql-tools/utils": "10.8.6",
48
48
  "apollo-server": "3.13.0",
49
- "graphql": "16.8.1",
49
+ "graphql": "16.10.0",
50
50
  "parse-prometheus-text-format": "1.1.1",
51
- "@promster/server": "14.0.0"
51
+ "@promster/server": "15.0.1"
52
52
  }
53
53
  }