@middy/service-discovery 7.2.2 → 7.3.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.
Files changed (3) hide show
  1. package/index.d.ts +4 -0
  2. package/index.js +10 -1
  3. package/package.json +3 -6
package/index.d.ts CHANGED
@@ -60,4 +60,8 @@ declare function serviceDiscovery<
60
60
  Internal<TOptions>
61
61
  >;
62
62
 
63
+ export declare function serviceDiscoveryValidateOptions(
64
+ options?: Record<string, unknown>,
65
+ ): void;
66
+
63
67
  export default serviceDiscovery;
package/index.js CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  ServiceDiscoveryClient,
6
6
  } from "@aws-sdk/client-servicediscovery";
7
7
  import {
8
+ awsClientOptionSchema,
8
9
  canPrefetch,
9
10
  catchInvalidSignatureException,
10
11
  createClient,
@@ -13,6 +14,7 @@ import {
13
14
  getInternal,
14
15
  modifyCache,
15
16
  processCache,
17
+ validateOptions,
16
18
  } from "@middy/util";
17
19
 
18
20
  const defaults = {
@@ -28,6 +30,11 @@ const defaults = {
28
30
  setToContext: false,
29
31
  };
30
32
 
33
+ const optionSchema = { ...awsClientOptionSchema };
34
+
35
+ export const serviceDiscoveryValidateOptions = (options) =>
36
+ validateOptions("@middy/service-discovery", optionSchema, options);
37
+
31
38
  const serviceDiscoveryMiddleware = (opts = {}) => {
32
39
  const options = { ...defaults, ...opts };
33
40
 
@@ -57,6 +64,7 @@ const serviceDiscoveryMiddleware = (opts = {}) => {
57
64
  };
58
65
 
59
66
  let client;
67
+ let clientInit;
60
68
  if (canPrefetch(options)) {
61
69
  client = createPrefetchClient(options);
62
70
  processCache(options, fetchRequest);
@@ -64,7 +72,8 @@ const serviceDiscoveryMiddleware = (opts = {}) => {
64
72
 
65
73
  const serviceDiscoveryMiddlewareBefore = async (request) => {
66
74
  if (!client) {
67
- client = await createClient(options, request);
75
+ clientInit ??= createClient(options, request);
76
+ client = await clientInit;
68
77
  }
69
78
 
70
79
  const { value } = processCache(options, fetchRequest, request);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/service-discovery",
3
- "version": "7.2.2",
3
+ "version": "7.3.0",
4
4
  "description": "Service Discovery (Cloud Map) instances middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -17,9 +17,6 @@
17
17
  "import": {
18
18
  "types": "./index.d.ts",
19
19
  "default": "./index.js"
20
- },
21
- "require": {
22
- "default": "./index.js"
23
20
  }
24
21
  }
25
22
  },
@@ -73,11 +70,11 @@
73
70
  }
74
71
  },
75
72
  "dependencies": {
76
- "@middy/util": "7.2.2"
73
+ "@middy/util": "7.3.0"
77
74
  },
78
75
  "devDependencies": {
79
76
  "@aws-sdk/client-servicediscovery": "^3.0.0",
80
- "@middy/core": "7.2.2",
77
+ "@middy/core": "7.3.0",
81
78
  "@types/aws-lambda": "^8.0.0",
82
79
  "@types/node": "^22.0.0",
83
80
  "aws-xray-sdk": "^3.3.3"