@graphql-hive/plugin-aws-sigv4 1.0.9 → 1.0.10-alpha-cd2e85546d0c2bef716fc44935bc37a496a3ba57

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @graphql-hive/plugin-aws-sigv4
2
2
 
3
+ ## 1.0.10-alpha-cd2e85546d0c2bef716fc44935bc37a496a3ba57
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`42269ef`](https://github.com/graphql-hive/gateway/commit/42269ef0b3b958d60960ace64487745c2ac97942)]:
8
+ - @graphql-mesh/fusion-runtime@0.11.13-alpha-cd2e85546d0c2bef716fc44935bc37a496a3ba57
9
+
3
10
  ## 1.0.9
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.cts CHANGED
@@ -1,12 +1,98 @@
1
1
  import { DisposableSymbols } from '@whatwg-node/disposablestack';
2
2
  import { UnifiedGraphPlugin, Instrumentation as Instrumentation$2 } from '@graphql-mesh/fusion-runtime';
3
3
  import { Plugin, YogaInitialContext, Instrumentation as Instrumentation$1 } from 'graphql-yoga';
4
- import { MeshFetch, Logger, KeyValueCache, OnFetchHook } from '@graphql-mesh/types';
4
+ import { MeshFetch, KeyValueCache, MeshFetchRequestInit, Logger as Logger$1 } from '@graphql-mesh/types';
5
5
  import { FetchInstrumentation } from '@graphql-mesh/utils';
6
- import { MaybePromise } from '@graphql-tools/utils';
6
+ import { ExecutionRequest, MaybePromise } from '@graphql-tools/utils';
7
+ import { GraphQLResolveInfo } from 'graphql/type';
7
8
  import { MaybePromise as MaybePromise$1 } from '@whatwg-node/promise-helpers';
8
9
  import { ServerAdapterInitialContext } from '@whatwg-node/server';
9
10
 
11
+ type MaybeLazy<T> = T | (() => T);
12
+ type AttributeValue = any;
13
+ type Attributes = AttributeValue[] | {
14
+ [key: string | number]: AttributeValue;
15
+ };
16
+
17
+ interface LogWriter {
18
+ write(level: LogLevel, attrs: Attributes | null | undefined, msg: string | null | undefined): void | Promise<void>;
19
+ }
20
+
21
+ type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
22
+ interface LoggerOptions {
23
+ /**
24
+ * The minimum log level to log.
25
+ *
26
+ * Providing `false` will disable all logging.
27
+ *
28
+ * Provided function will always be invoked to get the current log level.
29
+ *
30
+ * @default env.LOG_LEVEL || env.DEBUG ? 'debug' : 'info'
31
+ */
32
+ level?: MaybeLazy<LogLevel | false>;
33
+ /** A prefix to include in every log's message. */
34
+ prefix?: string;
35
+ /**
36
+ * The attributes to include in all logs. Is mainly used to pass the parent
37
+ * attributes when creating {@link Logger.child child loggers}.
38
+ */
39
+ attrs?: Attributes;
40
+ /**
41
+ * The log writers to use when writing logs.
42
+ *
43
+ * @default env.LOG_JSON ? [new JSONLogWriter()] : [new ConsoleLogWriter()]
44
+ */
45
+ writers?: [LogWriter, ...LogWriter[]];
46
+ }
47
+ declare class Logger implements AsyncDisposable {
48
+ #private;
49
+ constructor(opts?: LoggerOptions);
50
+ /** The prefix that's prepended to each log message. */
51
+ get prefix(): string | undefined;
52
+ /**
53
+ * The attributes that are added to each log. If the log itself contains
54
+ * attributes with keys existing in {@link attrs}, the log's attributes will
55
+ * override.
56
+ */
57
+ get attrs(): Attributes | undefined;
58
+ /** The current {@link LogLevel} of the logger. You can change the level using the {@link setLevel} method. */
59
+ get level(): false | LogLevel;
60
+ /**
61
+ * Sets the new {@link LogLevel} of the logger. All subsequent logs, and {@link child child loggers} whose
62
+ * level did not change, will respect the new level.
63
+ */
64
+ setLevel(level: MaybeLazy<LogLevel | false>): void;
65
+ write(level: LogLevel, attrs: Attributes | null | undefined, msg: string | null | undefined): void;
66
+ flush(): Promise<void> | undefined;
67
+ [DisposableSymbols.asyncDispose](): Promise<void | undefined>;
68
+ child(prefix: string): Logger;
69
+ child(attrs: Attributes, prefix?: string): Logger;
70
+ log(level: LogLevel): void;
71
+ log(level: LogLevel, attrs: MaybeLazy<Attributes>): void;
72
+ log(level: LogLevel, msg: string, ...interpol: unknown[]): void;
73
+ log(level: LogLevel, attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
74
+ trace(): void;
75
+ trace(attrs: MaybeLazy<Attributes>): void;
76
+ trace(msg: string, ...interpol: unknown[]): void;
77
+ trace(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
78
+ debug(): void;
79
+ debug(attrs: MaybeLazy<Attributes>): void;
80
+ debug(msg: string, ...interpol: unknown[]): void;
81
+ debug(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
82
+ info(): void;
83
+ info(attrs: MaybeLazy<Attributes>): void;
84
+ info(msg: string, ...interpol: unknown[]): void;
85
+ info(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
86
+ warn(): void;
87
+ warn(attrs: MaybeLazy<Attributes>): void;
88
+ warn(msg: string, ...interpol: unknown[]): void;
89
+ warn(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
90
+ error(): void;
91
+ error(attrs: MaybeLazy<Attributes>): void;
92
+ error(msg: string, ...interpol: unknown[]): void;
93
+ error(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
94
+ }
95
+
10
96
  type TopicDataMap = Record<string, any>;
11
97
  interface HivePubSub<Data extends TopicDataMap = TopicDataMap> {
12
98
  /** @deprecated Please use {@link subscribedTopics} if implemented instead. This method will be removed in next major release. */
@@ -30,9 +116,9 @@ interface GatewayConfigContext {
30
116
  */
31
117
  fetch: MeshFetch;
32
118
  /**
33
- * The logger to use throught Mesh and it's plugins.
119
+ * The logger to use throught Hive and its plugins.
34
120
  */
35
- logger: Logger;
121
+ log: Logger;
36
122
  /**
37
123
  * Current working directory.
38
124
  */
@@ -57,7 +143,7 @@ interface GatewayContext extends GatewayConfigContext, YogaInitialContext {
57
143
  connectionParams: Record<string, string>;
58
144
  }
59
145
  type GatewayPlugin<TPluginContext extends Record<string, any> = Record<string, any>, TContext extends Record<string, any> = Record<string, any>> = Plugin<Partial<TPluginContext> & GatewayContext & TContext> & UnifiedGraphPlugin<Partial<TPluginContext> & GatewayContext & TContext> & {
60
- onFetch?: OnFetchHook<Partial<TPluginContext> & GatewayContext & TContext>;
146
+ onFetch?: OnFetchHook<Partial<TPluginContext> & TContext>;
61
147
  onCacheGet?: OnCacheGetHook;
62
148
  onCacheSet?: OnCacheSetHook;
63
149
  onCacheDelete?: OnCacheDeleteHook;
@@ -70,6 +156,34 @@ type GatewayPlugin<TPluginContext extends Record<string, any> = Record<string, a
70
156
  */
71
157
  instrumentation?: Instrumentation<TPluginContext & TContext & GatewayContext>;
72
158
  };
159
+ interface OnFetchHookPayload<TContext> {
160
+ url: string;
161
+ setURL(url: URL | string): void;
162
+ options: MeshFetchRequestInit;
163
+ setOptions(options: MeshFetchRequestInit): void;
164
+ /**
165
+ * The context is not available in cases where "fetch" is done in
166
+ * order to pull a supergraph or do some internal work.
167
+ *
168
+ * The logger will be available in all cases.
169
+ */
170
+ context: (GatewayContext & TContext) | {
171
+ log: Logger;
172
+ };
173
+ /** @deprecated Please use `log` from the {@link context} instead. */
174
+ logger: Logger$1;
175
+ info: GraphQLResolveInfo;
176
+ fetchFn: MeshFetch;
177
+ setFetchFn: (fetchFn: MeshFetch) => void;
178
+ executionRequest?: ExecutionRequest;
179
+ endResponse: (response$: MaybePromise<Response>) => void;
180
+ }
181
+ interface OnFetchHookDonePayload {
182
+ response: Response;
183
+ setResponse: (response: Response) => void;
184
+ }
185
+ type OnFetchHookDone = (payload: OnFetchHookDonePayload) => MaybePromise<void>;
186
+ type OnFetchHook<TContext> = (payload: OnFetchHookPayload<TContext>) => MaybePromise<void | OnFetchHookDone>;
73
187
  type OnCacheGetHook = (payload: OnCacheGetHookEventPayload) => MaybePromise<OnCacheGetHookResult | void>;
74
188
  interface OnCacheGetHookEventPayload {
75
189
  cache: KeyValueCache;
@@ -112,10 +226,6 @@ interface OnCacheDeleteHookEventPayload {
112
226
  }
113
227
  type Instrumentation<TContext extends Record<string, any>> = Instrumentation$1<TContext> & Instrumentation$2 & FetchInstrumentation;
114
228
 
115
- declare global {
116
- var DEBUG: string;
117
- }
118
-
119
229
  interface AWSSignv4PluginOptions {
120
230
  /**
121
231
  * Outgoing options for signing outgoing requests.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,98 @@
1
1
  import { DisposableSymbols } from '@whatwg-node/disposablestack';
2
2
  import { UnifiedGraphPlugin, Instrumentation as Instrumentation$2 } from '@graphql-mesh/fusion-runtime';
3
3
  import { Plugin, YogaInitialContext, Instrumentation as Instrumentation$1 } from 'graphql-yoga';
4
- import { MeshFetch, Logger, KeyValueCache, OnFetchHook } from '@graphql-mesh/types';
4
+ import { MeshFetch, KeyValueCache, MeshFetchRequestInit, Logger as Logger$1 } from '@graphql-mesh/types';
5
5
  import { FetchInstrumentation } from '@graphql-mesh/utils';
6
- import { MaybePromise } from '@graphql-tools/utils';
6
+ import { ExecutionRequest, MaybePromise } from '@graphql-tools/utils';
7
+ import { GraphQLResolveInfo } from 'graphql/type';
7
8
  import { MaybePromise as MaybePromise$1 } from '@whatwg-node/promise-helpers';
8
9
  import { ServerAdapterInitialContext } from '@whatwg-node/server';
9
10
 
11
+ type MaybeLazy<T> = T | (() => T);
12
+ type AttributeValue = any;
13
+ type Attributes = AttributeValue[] | {
14
+ [key: string | number]: AttributeValue;
15
+ };
16
+
17
+ interface LogWriter {
18
+ write(level: LogLevel, attrs: Attributes | null | undefined, msg: string | null | undefined): void | Promise<void>;
19
+ }
20
+
21
+ type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
22
+ interface LoggerOptions {
23
+ /**
24
+ * The minimum log level to log.
25
+ *
26
+ * Providing `false` will disable all logging.
27
+ *
28
+ * Provided function will always be invoked to get the current log level.
29
+ *
30
+ * @default env.LOG_LEVEL || env.DEBUG ? 'debug' : 'info'
31
+ */
32
+ level?: MaybeLazy<LogLevel | false>;
33
+ /** A prefix to include in every log's message. */
34
+ prefix?: string;
35
+ /**
36
+ * The attributes to include in all logs. Is mainly used to pass the parent
37
+ * attributes when creating {@link Logger.child child loggers}.
38
+ */
39
+ attrs?: Attributes;
40
+ /**
41
+ * The log writers to use when writing logs.
42
+ *
43
+ * @default env.LOG_JSON ? [new JSONLogWriter()] : [new ConsoleLogWriter()]
44
+ */
45
+ writers?: [LogWriter, ...LogWriter[]];
46
+ }
47
+ declare class Logger implements AsyncDisposable {
48
+ #private;
49
+ constructor(opts?: LoggerOptions);
50
+ /** The prefix that's prepended to each log message. */
51
+ get prefix(): string | undefined;
52
+ /**
53
+ * The attributes that are added to each log. If the log itself contains
54
+ * attributes with keys existing in {@link attrs}, the log's attributes will
55
+ * override.
56
+ */
57
+ get attrs(): Attributes | undefined;
58
+ /** The current {@link LogLevel} of the logger. You can change the level using the {@link setLevel} method. */
59
+ get level(): false | LogLevel;
60
+ /**
61
+ * Sets the new {@link LogLevel} of the logger. All subsequent logs, and {@link child child loggers} whose
62
+ * level did not change, will respect the new level.
63
+ */
64
+ setLevel(level: MaybeLazy<LogLevel | false>): void;
65
+ write(level: LogLevel, attrs: Attributes | null | undefined, msg: string | null | undefined): void;
66
+ flush(): Promise<void> | undefined;
67
+ [DisposableSymbols.asyncDispose](): Promise<void | undefined>;
68
+ child(prefix: string): Logger;
69
+ child(attrs: Attributes, prefix?: string): Logger;
70
+ log(level: LogLevel): void;
71
+ log(level: LogLevel, attrs: MaybeLazy<Attributes>): void;
72
+ log(level: LogLevel, msg: string, ...interpol: unknown[]): void;
73
+ log(level: LogLevel, attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
74
+ trace(): void;
75
+ trace(attrs: MaybeLazy<Attributes>): void;
76
+ trace(msg: string, ...interpol: unknown[]): void;
77
+ trace(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
78
+ debug(): void;
79
+ debug(attrs: MaybeLazy<Attributes>): void;
80
+ debug(msg: string, ...interpol: unknown[]): void;
81
+ debug(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
82
+ info(): void;
83
+ info(attrs: MaybeLazy<Attributes>): void;
84
+ info(msg: string, ...interpol: unknown[]): void;
85
+ info(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
86
+ warn(): void;
87
+ warn(attrs: MaybeLazy<Attributes>): void;
88
+ warn(msg: string, ...interpol: unknown[]): void;
89
+ warn(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
90
+ error(): void;
91
+ error(attrs: MaybeLazy<Attributes>): void;
92
+ error(msg: string, ...interpol: unknown[]): void;
93
+ error(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
94
+ }
95
+
10
96
  type TopicDataMap = Record<string, any>;
11
97
  interface HivePubSub<Data extends TopicDataMap = TopicDataMap> {
12
98
  /** @deprecated Please use {@link subscribedTopics} if implemented instead. This method will be removed in next major release. */
@@ -30,9 +116,9 @@ interface GatewayConfigContext {
30
116
  */
31
117
  fetch: MeshFetch;
32
118
  /**
33
- * The logger to use throught Mesh and it's plugins.
119
+ * The logger to use throught Hive and its plugins.
34
120
  */
35
- logger: Logger;
121
+ log: Logger;
36
122
  /**
37
123
  * Current working directory.
38
124
  */
@@ -57,7 +143,7 @@ interface GatewayContext extends GatewayConfigContext, YogaInitialContext {
57
143
  connectionParams: Record<string, string>;
58
144
  }
59
145
  type GatewayPlugin<TPluginContext extends Record<string, any> = Record<string, any>, TContext extends Record<string, any> = Record<string, any>> = Plugin<Partial<TPluginContext> & GatewayContext & TContext> & UnifiedGraphPlugin<Partial<TPluginContext> & GatewayContext & TContext> & {
60
- onFetch?: OnFetchHook<Partial<TPluginContext> & GatewayContext & TContext>;
146
+ onFetch?: OnFetchHook<Partial<TPluginContext> & TContext>;
61
147
  onCacheGet?: OnCacheGetHook;
62
148
  onCacheSet?: OnCacheSetHook;
63
149
  onCacheDelete?: OnCacheDeleteHook;
@@ -70,6 +156,34 @@ type GatewayPlugin<TPluginContext extends Record<string, any> = Record<string, a
70
156
  */
71
157
  instrumentation?: Instrumentation<TPluginContext & TContext & GatewayContext>;
72
158
  };
159
+ interface OnFetchHookPayload<TContext> {
160
+ url: string;
161
+ setURL(url: URL | string): void;
162
+ options: MeshFetchRequestInit;
163
+ setOptions(options: MeshFetchRequestInit): void;
164
+ /**
165
+ * The context is not available in cases where "fetch" is done in
166
+ * order to pull a supergraph or do some internal work.
167
+ *
168
+ * The logger will be available in all cases.
169
+ */
170
+ context: (GatewayContext & TContext) | {
171
+ log: Logger;
172
+ };
173
+ /** @deprecated Please use `log` from the {@link context} instead. */
174
+ logger: Logger$1;
175
+ info: GraphQLResolveInfo;
176
+ fetchFn: MeshFetch;
177
+ setFetchFn: (fetchFn: MeshFetch) => void;
178
+ executionRequest?: ExecutionRequest;
179
+ endResponse: (response$: MaybePromise<Response>) => void;
180
+ }
181
+ interface OnFetchHookDonePayload {
182
+ response: Response;
183
+ setResponse: (response: Response) => void;
184
+ }
185
+ type OnFetchHookDone = (payload: OnFetchHookDonePayload) => MaybePromise<void>;
186
+ type OnFetchHook<TContext> = (payload: OnFetchHookPayload<TContext>) => MaybePromise<void | OnFetchHookDone>;
73
187
  type OnCacheGetHook = (payload: OnCacheGetHookEventPayload) => MaybePromise<OnCacheGetHookResult | void>;
74
188
  interface OnCacheGetHookEventPayload {
75
189
  cache: KeyValueCache;
@@ -112,10 +226,6 @@ interface OnCacheDeleteHookEventPayload {
112
226
  }
113
227
  type Instrumentation<TContext extends Record<string, any>> = Instrumentation$1<TContext> & Instrumentation$2 & FetchInstrumentation;
114
228
 
115
- declare global {
116
- var DEBUG: string;
117
- }
118
-
119
229
  interface AWSSignv4PluginOptions {
120
230
  /**
121
231
  * Outgoing options for signing outgoing requests.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/plugin-aws-sigv4",
3
- "version": "1.0.9",
3
+ "version": "1.0.10-alpha-cd2e85546d0c2bef716fc44935bc37a496a3ba57",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,14 +43,14 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@aws-sdk/client-sts": "^3.758.0",
46
- "@graphql-mesh/fusion-runtime": "^0.11.12",
46
+ "@graphql-mesh/fusion-runtime": "0.11.13-alpha-cd2e85546d0c2bef716fc44935bc37a496a3ba57",
47
47
  "@whatwg-node/promise-helpers": "^1.3.0",
48
48
  "aws4": "1.13.2",
49
49
  "tslib": "^2.8.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@apollo/subgraph": "^2.7.2",
53
- "@graphql-hive/gateway-runtime": "1.8.2",
53
+ "@graphql-hive/gateway-runtime": "1.8.3-alpha-cd2e85546d0c2bef716fc44935bc37a496a3ba57",
54
54
  "@types/aws4": "^1.11.6",
55
55
  "graphql": "^16.9.0",
56
56
  "graphql-yoga": "^5.13.4",