@aws-sdk/middleware-sdk-sqs 3.496.0 → 3.507.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/dist-cjs/index.js CHANGED
@@ -20,11 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ getQueueUrlPlugin: () => getQueueUrlPlugin,
23
24
  getReceiveMessagePlugin: () => getReceiveMessagePlugin,
24
25
  getSendMessageBatchPlugin: () => getSendMessageBatchPlugin,
25
26
  getSendMessagePlugin: () => getSendMessagePlugin,
27
+ queueUrlMiddleware: () => queueUrlMiddleware,
28
+ queueUrlMiddlewareOptions: () => queueUrlMiddlewareOptions,
26
29
  receiveMessageMiddleware: () => receiveMessageMiddleware,
27
30
  receiveMessageMiddlewareOptions: () => receiveMessageMiddlewareOptions,
31
+ resolveQueueUrlConfig: () => resolveQueueUrlConfig,
28
32
  sendMessageBatchMiddleware: () => sendMessageBatchMiddleware,
29
33
  sendMessageBatchMiddlewareOptions: () => sendMessageBatchMiddlewareOptions,
30
34
  sendMessageMiddleware: () => sendMessageMiddleware,
@@ -32,6 +36,53 @@ __export(src_exports, {
32
36
  });
33
37
  module.exports = __toCommonJS(src_exports);
34
38
 
39
+ // src/queue-url.ts
40
+ var import_smithy_client = require("@smithy/smithy-client");
41
+ var resolveQueueUrlConfig = /* @__PURE__ */ __name((config) => {
42
+ return {
43
+ ...config,
44
+ useQueueUrlAsEndpoint: config.useQueueUrlAsEndpoint ?? true
45
+ };
46
+ }, "resolveQueueUrlConfig");
47
+ function queueUrlMiddleware({ useQueueUrlAsEndpoint, endpoint }) {
48
+ return (next, context) => {
49
+ return async (args) => {
50
+ var _a;
51
+ const { input } = args;
52
+ const resolvedEndpoint = context.endpointV2;
53
+ if (!endpoint && input.QueueUrl && resolvedEndpoint && useQueueUrlAsEndpoint) {
54
+ const logger = context.logger instanceof import_smithy_client.NoOpLogger || !((_a = context.logger) == null ? void 0 : _a.warn) ? console : context.logger;
55
+ try {
56
+ const queueUrl = new URL(input.QueueUrl);
57
+ const queueUrlOrigin = new URL(queueUrl.origin);
58
+ if (resolvedEndpoint.url.origin !== queueUrlOrigin.origin) {
59
+ logger.warn(
60
+ `QueueUrl=${input.QueueUrl} differs from SQSClient resolved endpoint=${resolvedEndpoint.url.toString()}, using QueueUrl host as endpoint.
61
+ Set [endpoint=string] or [useQueueUrlAsEndpoint=false] on the SQSClient.`
62
+ );
63
+ resolvedEndpoint.url = queueUrlOrigin;
64
+ }
65
+ } catch (e) {
66
+ logger.warn(e);
67
+ }
68
+ }
69
+ return next(args);
70
+ };
71
+ };
72
+ }
73
+ __name(queueUrlMiddleware, "queueUrlMiddleware");
74
+ var queueUrlMiddlewareOptions = {
75
+ name: "queueUrlMiddleware",
76
+ relation: "after",
77
+ toMiddleware: "endpointV2Middleware",
78
+ override: true
79
+ };
80
+ var getQueueUrlPlugin = /* @__PURE__ */ __name((config) => ({
81
+ applyToStack: (clientStack) => {
82
+ clientStack.addRelativeTo(queueUrlMiddleware(config), queueUrlMiddlewareOptions);
83
+ }
84
+ }), "getQueueUrlPlugin");
85
+
35
86
  // src/receive-message.ts
36
87
  var import_util_hex_encoding = require("@smithy/util-hex-encoding");
37
88
  var import_util_utf8 = require("@smithy/util-utf8");
@@ -138,14 +189,18 @@ var getSendMessageBatchPlugin = /* @__PURE__ */ __name((config) => ({
138
189
  // Annotate the CommonJS export names for ESM import in node:
139
190
 
140
191
  0 && (module.exports = {
141
- getReceiveMessagePlugin,
142
- getSendMessageBatchPlugin,
143
- getSendMessagePlugin,
192
+ resolveQueueUrlConfig,
193
+ queueUrlMiddleware,
194
+ queueUrlMiddlewareOptions,
195
+ getQueueUrlPlugin,
144
196
  receiveMessageMiddleware,
145
197
  receiveMessageMiddlewareOptions,
198
+ getReceiveMessagePlugin,
199
+ sendMessageMiddleware,
200
+ sendMessageMiddlewareOptions,
201
+ getSendMessagePlugin,
146
202
  sendMessageBatchMiddleware,
147
203
  sendMessageBatchMiddlewareOptions,
148
- sendMessageMiddleware,
149
- sendMessageMiddlewareOptions
204
+ getSendMessageBatchPlugin
150
205
  });
151
206
 
@@ -0,0 +1 @@
1
+ module.exports = require("./index.js");
package/dist-es/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./queue-url";
1
2
  export * from "./receive-message";
2
3
  export * from "./send-message";
3
4
  export * from "./send-message-batch";
@@ -0,0 +1,42 @@
1
+ import { NoOpLogger } from "@smithy/smithy-client";
2
+ export const resolveQueueUrlConfig = (config) => {
3
+ return {
4
+ ...config,
5
+ useQueueUrlAsEndpoint: config.useQueueUrlAsEndpoint ?? true,
6
+ };
7
+ };
8
+ export function queueUrlMiddleware({ useQueueUrlAsEndpoint, endpoint }) {
9
+ return (next, context) => {
10
+ return async (args) => {
11
+ const { input } = args;
12
+ const resolvedEndpoint = context.endpointV2;
13
+ if (!endpoint && input.QueueUrl && resolvedEndpoint && useQueueUrlAsEndpoint) {
14
+ const logger = context.logger instanceof NoOpLogger || !context.logger?.warn ? console : context.logger;
15
+ try {
16
+ const queueUrl = new URL(input.QueueUrl);
17
+ const queueUrlOrigin = new URL(queueUrl.origin);
18
+ if (resolvedEndpoint.url.origin !== queueUrlOrigin.origin) {
19
+ logger.warn(`QueueUrl=${input.QueueUrl} differs from SQSClient resolved endpoint=${resolvedEndpoint.url.toString()}, using QueueUrl host as endpoint.
20
+ Set [endpoint=string] or [useQueueUrlAsEndpoint=false] on the SQSClient.`);
21
+ resolvedEndpoint.url = queueUrlOrigin;
22
+ }
23
+ }
24
+ catch (e) {
25
+ logger.warn(e);
26
+ }
27
+ }
28
+ return next(args);
29
+ };
30
+ };
31
+ }
32
+ export const queueUrlMiddlewareOptions = {
33
+ name: "queueUrlMiddleware",
34
+ relation: "after",
35
+ toMiddleware: "endpointV2Middleware",
36
+ override: true,
37
+ };
38
+ export const getQueueUrlPlugin = (config) => ({
39
+ applyToStack: (clientStack) => {
40
+ clientStack.addRelativeTo(queueUrlMiddleware(config), queueUrlMiddlewareOptions);
41
+ },
42
+ });
@@ -1,3 +1,4 @@
1
+ export * from "./queue-url";
1
2
  export * from "./receive-message";
2
3
  export * from "./send-message";
3
4
  export * from "./send-message-batch";
@@ -0,0 +1,33 @@
1
+ import { Endpoint, EndpointV2, FinalizeHandlerArguments, FinalizeHandlerOutput, HandlerExecutionContext, Pluggable, Provider, RelativeMiddlewareOptions } from "@aws-sdk/types";
2
+ /**
3
+ * @public
4
+ */
5
+ export interface QueueUrlInputConfig {
6
+ /**
7
+ * In cases where a QueueUrl is given as input, that
8
+ * will be preferred as the request endpoint.
9
+ *
10
+ * Set this value to false to ignore the QueueUrl and use the
11
+ * client's resolved endpoint, which may be a custom endpoint.
12
+ */
13
+ useQueueUrlAsEndpoint?: boolean;
14
+ }
15
+ export interface QueueUrlResolvedConfig {
16
+ useQueueUrlAsEndpoint: boolean;
17
+ }
18
+ export interface PreviouslyResolved {
19
+ endpoint?: string | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;
20
+ }
21
+ export declare const resolveQueueUrlConfig: <T>(config: T & PreviouslyResolved & QueueUrlInputConfig) => T & QueueUrlResolvedConfig;
22
+ /**
23
+ * @internal
24
+ */
25
+ export declare function queueUrlMiddleware({ useQueueUrlAsEndpoint, endpoint }: QueueUrlResolvedConfig & PreviouslyResolved): <Output extends object>(next: (args: FinalizeHandlerArguments<any>) => Promise<FinalizeHandlerOutput<Output>>, context: HandlerExecutionContext) => (args: FinalizeHandlerArguments<any>) => Promise<FinalizeHandlerOutput<Output>>;
26
+ /**
27
+ * @internal
28
+ */
29
+ export declare const queueUrlMiddlewareOptions: RelativeMiddlewareOptions;
30
+ /**
31
+ * @internal
32
+ */
33
+ export declare const getQueueUrlPlugin: (config: QueueUrlResolvedConfig) => Pluggable<any, any>;
@@ -1,3 +1,4 @@
1
+ export * from "./queue-url";
1
2
  export * from "./receive-message";
2
3
  export * from "./send-message";
3
4
  export * from "./send-message-batch";
@@ -0,0 +1,42 @@
1
+ import {
2
+ Endpoint,
3
+ EndpointV2,
4
+ FinalizeHandlerArguments,
5
+ FinalizeHandlerOutput,
6
+ HandlerExecutionContext,
7
+ Pluggable,
8
+ Provider,
9
+ RelativeMiddlewareOptions,
10
+ } from "@aws-sdk/types";
11
+ export interface QueueUrlInputConfig {
12
+ useQueueUrlAsEndpoint?: boolean;
13
+ }
14
+ export interface QueueUrlResolvedConfig {
15
+ useQueueUrlAsEndpoint: boolean;
16
+ }
17
+ export interface PreviouslyResolved {
18
+ endpoint?:
19
+ | string
20
+ | Endpoint
21
+ | Provider<Endpoint>
22
+ | EndpointV2
23
+ | Provider<EndpointV2>;
24
+ }
25
+ export declare const resolveQueueUrlConfig: <T>(
26
+ config: T & PreviouslyResolved & QueueUrlInputConfig
27
+ ) => T & QueueUrlResolvedConfig;
28
+ export declare function queueUrlMiddleware({
29
+ useQueueUrlAsEndpoint,
30
+ endpoint,
31
+ }: QueueUrlResolvedConfig & PreviouslyResolved): <Output extends object>(
32
+ next: (
33
+ args: FinalizeHandlerArguments<any>
34
+ ) => Promise<FinalizeHandlerOutput<Output>>,
35
+ context: HandlerExecutionContext
36
+ ) => (
37
+ args: FinalizeHandlerArguments<any>
38
+ ) => Promise<FinalizeHandlerOutput<Output>>;
39
+ export declare const queueUrlMiddlewareOptions: RelativeMiddlewareOptions;
40
+ export declare const getQueueUrlPlugin: (
41
+ config: QueueUrlResolvedConfig
42
+ ) => Pluggable<any, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-sqs",
3
- "version": "3.496.0",
3
+ "version": "3.507.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "node ../../scripts/compilation/inline middleware-sdk-sqs",
@@ -21,7 +21,8 @@
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "@aws-sdk/types": "3.496.0",
24
+ "@aws-sdk/types": "3.502.0",
25
+ "@smithy/smithy-client": "^2.3.1",
25
26
  "@smithy/types": "^2.9.1",
26
27
  "@smithy/util-hex-encoding": "^2.1.1",
27
28
  "@smithy/util-utf8": "^2.1.1",