@openstax/ts-utils 1.32.1 → 1.32.2

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 (32) hide show
  1. package/dist/cjs/routing/index.d.ts +2 -20
  2. package/dist/cjs/routing/index.js +1 -10
  3. package/dist/cjs/services/apiGateway/index.d.ts +1 -1
  4. package/dist/cjs/services/authProvider/browser.d.ts +6 -38
  5. package/dist/cjs/services/authProvider/browser.js +1 -0
  6. package/dist/cjs/services/authProvider/index.d.ts +1 -0
  7. package/dist/cjs/services/authProvider/index.js +10 -5
  8. package/dist/cjs/services/authProvider/subrequest.js +8 -6
  9. package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.d.ts +2 -2
  10. package/dist/cjs/services/fileServer/index.d.ts +0 -12
  11. package/dist/cjs/services/fileServer/localFileServer.js +1 -52
  12. package/dist/cjs/services/fileServer/s3FileServer.d.ts +0 -1
  13. package/dist/cjs/services/fileServer/s3FileServer.js +0 -78
  14. package/dist/cjs/services/searchProvider/openSearch.js +4 -6
  15. package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
  16. package/dist/esm/routing/index.d.ts +2 -20
  17. package/dist/esm/routing/index.js +0 -8
  18. package/dist/esm/services/apiGateway/index.d.ts +1 -1
  19. package/dist/esm/services/authProvider/browser.d.ts +6 -38
  20. package/dist/esm/services/authProvider/browser.js +1 -0
  21. package/dist/esm/services/authProvider/index.d.ts +1 -0
  22. package/dist/esm/services/authProvider/index.js +10 -5
  23. package/dist/esm/services/authProvider/subrequest.js +8 -6
  24. package/dist/esm/services/authProvider/utils/embeddedAuthProvider.d.ts +2 -2
  25. package/dist/esm/services/fileServer/index.d.ts +0 -12
  26. package/dist/esm/services/fileServer/localFileServer.js +2 -53
  27. package/dist/esm/services/fileServer/s3FileServer.d.ts +0 -1
  28. package/dist/esm/services/fileServer/s3FileServer.js +1 -76
  29. package/dist/esm/services/searchProvider/openSearch.js +4 -6
  30. package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
  31. package/package.json +3 -4
  32. package/script/bin/.init-params-script.bash.swp +0 -0
@@ -25,20 +25,6 @@ export type RouteMatchRecord<R> = R extends AnyRoute<R> ? {
25
25
  route: R;
26
26
  params: ParamsForRoute<R>;
27
27
  } : never;
28
- type Flatten<T> = T extends any ? {
29
- [K in keyof T]: T[K];
30
- } : never;
31
- export type ExternalRoute<R> = R extends Route<infer N, infer P, infer Sa, infer Sr, infer Ri, infer Ro> & infer E ? Route<N, P, Sa, Sr extends {
32
- payload: any;
33
- } ? Flatten<Pick<Sr, 'payload'>> : Record<string, never>, Ri, Ro> & Flatten<Omit<E, 'name' | 'path' | 'handler' | 'requestServiceProvider'>> : never;
34
- /** this utility simplifies the route type to remove stuff that is only
35
- * relevant internal to the route, like the service types, keeping only
36
- * the payload type which is necessary for the apiGateway
37
- *
38
- * this helps avoid the "type too complicated" error that typescript throws
39
- * when there are a lot of routes with complex services
40
- **/
41
- export declare const routesList: <R>(routes: R[]) => ExternalRoute<R>[];
42
28
  /**
43
29
  * The conditional type for the payload for a given route, `R`. This isn't a route structure, its
44
30
  * a convention based on the request middleware
@@ -154,9 +140,7 @@ export declare const makeCreateRoute: <Sa, Ri, Ex = {}>() => CreateRoute<Sa, Ri,
154
140
  */
155
141
  export declare const makeRenderRouteUrl: <Ru extends {
156
142
  path: string;
157
- }>() => <R>(route: ExternalRoute<R> extends Ru ? R & {
158
- path: string;
159
- } : R extends Ru ? R : never, params: ParamsForRoute<R>, query?: QueryParams) => string;
143
+ }>() => <R extends Ru>(route: R, params: ParamsForRoute<R>, query?: QueryParams) => string;
160
144
  /**
161
145
  * A pre-made result from `makeRenderRouteUrl`, this function interpolates parameter and query
162
146
  * arguments into a route path.
@@ -169,9 +153,7 @@ export declare const makeRenderRouteUrl: <Ru extends {
169
153
  * @param query the query parameters to add to the route path
170
154
  * @returns the interpolated route path
171
155
  */
172
- export declare const renderAnyRouteUrl: <R>(route: ExternalRoute<R> extends any ? R & {
173
- path: string;
174
- } : R extends any ? R : never, params: ParamsForRoute<R>, query?: QueryParams) => string;
156
+ export declare const renderAnyRouteUrl: <R extends any>(route: R, params: ParamsForRoute<R>, query?: QueryParams) => string;
175
157
  type RequestPathExtractor<Ri> = (request: Ri) => string;
176
158
  type RequestLogExtractor<Ri> = (request: Ri) => JsonCompatibleStruct;
177
159
  type RequestRouteMatcher<Ri, R> = (request: Ri, route: R) => boolean;
@@ -39,20 +39,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.METHOD = exports.apiHtmlResponse = exports.apiTextResponse = exports.apiJsonResponse = exports.makeGetRequestResponder = exports.renderAnyRouteUrl = exports.makeRenderRouteUrl = exports.makeCreateRoute = exports.routesList = void 0;
42
+ exports.METHOD = exports.apiHtmlResponse = exports.apiTextResponse = exports.apiJsonResponse = exports.makeGetRequestResponder = exports.renderAnyRouteUrl = exports.makeRenderRouteUrl = exports.makeCreateRoute = void 0;
43
43
  const pathToRegexp = __importStar(require("path-to-regexp"));
44
44
  const query_string_1 = __importDefault(require("query-string"));
45
45
  const helpers_1 = require("../misc/helpers");
46
46
  const console_1 = require("../services/logger/console");
47
- /** this utility simplifies the route type to remove stuff that is only
48
- * relevant internal to the route, like the service types, keeping only
49
- * the payload type which is necessary for the apiGateway
50
- *
51
- * this helps avoid the "type too complicated" error that typescript throws
52
- * when there are a lot of routes with complex services
53
- **/
54
- const routesList = (routes) => routes;
55
- exports.routesList = routesList;
56
47
  /**
57
48
  * Makes a createRoute function that can be used to create routes (this is a factory factory). The
58
49
  * `makeCreateRoute` function is typically called once in the backend and once in the frontend to
@@ -38,7 +38,7 @@ export type ApiClientResponse<Ro> = Ro extends any ? {
38
38
  } : never;
39
39
  export type ExpandRoute<T> = T extends ((...args: infer A) => infer R) & {
40
40
  renderUrl: (...args: infer Ar) => Promise<string>;
41
- } ? ((...args: A) => R) & {
41
+ } ? (...args: A) => R & {
42
42
  renderUrl: (...args: Ar) => Promise<string>;
43
43
  } : never;
44
44
  export type MapRoutesToClient<Ru> = [Ru] extends [AnyRoute<Ru>] ? {
@@ -1,6 +1,7 @@
1
1
  import { ConfigProviderForConfig } from '../../config';
2
- import { FetchConfig, GenericFetch } from '../../fetch';
3
- import { ApiUser, User } from '.';
2
+ import { GenericFetch } from '../../fetch';
3
+ import { UserData } from './utils/embeddedAuthProvider';
4
+ import { ApiUser, AuthProvider } from '.';
4
5
  type Config = {
5
6
  accountsBase: string;
6
7
  };
@@ -27,46 +28,13 @@ export interface Window {
27
28
  removeEventListener: (event: 'message', callback: EventHandler) => void;
28
29
  }
29
30
  export type UpdatableUserFields = Partial<Pick<ApiUser, 'consent_preferences' | 'first_name' | 'last_name'>>;
30
- export declare const browserAuthProvider: <C extends string = "auth">({ window, configSpace }: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => {
31
- /**
32
- * gets the authentication token
33
- */
34
- getAuthToken: () => Promise<string | null>;
35
- /**
36
- * adds auth parameters to the url. this is only safe to use when using javascript to navigate
37
- * within the current window, eg `window.location = 'https://my.otherservice.com';` anchors
38
- * should use getAuthorizedLinkUrl for their href.
39
- *
40
- * result unreliable unless `getUser` is resolved first.
41
- */
31
+ export type BrowserAuthProvider = AuthProvider & {
42
32
  getAuthorizedUrl: (urlString: string) => string;
43
- /**
44
- * all link href-s must be rendered with auth tokens so that they work when opened in a new tab
45
- *
46
- * result unreliable unless `getUser` is resolved first.
47
- */
48
33
  getAuthorizedLinkUrl: (urlString: string) => string;
49
- /**
50
- * gets an authorized url for an iframe src. sets params on the url and saves its
51
- * origin to trust releasing user identity to it
52
- */
53
34
  getAuthorizedEmbedUrl: (urlString: string, extraParams?: {
54
35
  [key: string]: string;
55
36
  }) => string;
56
- /**
57
- * gets second argument for `fetch` that has authentication token or cookie
58
- */
59
- getAuthorizedFetchConfig: () => Promise<FetchConfig>;
60
- /**
61
- * loads current user identity. does not reflect changes in identity after being called the first time.
62
- */
63
- getUser: () => Promise<User | undefined>;
64
- /**
65
- * updates user settings, for example the cookie consent preferences
66
- */
67
- updateUser: (updates: UpdatableUserFields) => Promise<{
68
- user: ApiUser;
69
- token: string | null;
70
- }>;
37
+ updateUser: (updates: UpdatableUserFields) => Promise<UserData<ApiUser>>;
71
38
  };
39
+ export declare const browserAuthProvider: <C extends string = "auth">({ window, configSpace }: Initializer<C>) => (configProvider: { [_key in C]: ConfigProviderForConfig<Config>; }) => BrowserAuthProvider;
72
40
  export {};
@@ -145,6 +145,7 @@ const browserAuthProvider = ({ window, configSpace }) => (configProvider) => {
145
145
  * loads current user identity. does not reflect changes in identity after being called the first time.
146
146
  */
147
147
  getUser,
148
+ loadUserData: getUser,
148
149
  /**
149
150
  * updates user settings, for example the cookie consent preferences
150
151
  */
@@ -43,6 +43,7 @@ export type AuthProvider = {
43
43
  * gets second argument for `fetch` that has authentication token or cookie
44
44
  */
45
45
  getAuthorizedFetchConfig: () => Promise<FetchConfig>;
46
+ loadUserData: () => Promise<ApiUser | undefined>;
46
47
  };
47
48
  export type CookieAuthProviderRequest = {
48
49
  cookies?: string[];
@@ -7,11 +7,16 @@ exports.getAuthTokenOrCookie = exports.stubAuthProvider = void 0;
7
7
  const cookie_1 = __importDefault(require("cookie"));
8
8
  const helpers_1 = require("../../misc/helpers");
9
9
  const helpers_2 = require("../../routing/helpers");
10
- const stubAuthProvider = (user) => ({
11
- getAuthToken: () => Promise.resolve('authToken'),
12
- getUser: () => Promise.resolve(user),
13
- getAuthorizedFetchConfig: () => Promise.resolve(user ? { headers: { Authorization: user.uuid } } : {})
14
- });
10
+ const stubAuthProvider = (user) => {
11
+ const getUser = () => Promise.resolve(user);
12
+ return {
13
+ getAuthToken: () => Promise.resolve('authToken'),
14
+ getUser,
15
+ getAuthorizedFetchConfig: () => Promise.resolve(user ? { headers: { Authorization: user.uuid } } : {}),
16
+ // This is not technically correct, but most tests won't care
17
+ loadUserData: getUser
18
+ };
19
+ };
15
20
  exports.stubAuthProvider = stubAuthProvider;
16
21
  const getAuthTokenOrCookie = (request, cookieName, queryKey = 'auth') => {
17
22
  var _a, _b;
@@ -32,15 +32,17 @@ const subrequestAuthProvider = (initializer) => (configProvider) => {
32
32
  }
33
33
  return user;
34
34
  };
35
+ const getUser = async () => {
36
+ if (!user) {
37
+ user = await loadUser();
38
+ }
39
+ return user;
40
+ };
35
41
  return {
36
42
  getAuthToken,
37
43
  getAuthorizedFetchConfig,
38
- getUser: async () => {
39
- if (!user) {
40
- user = await loadUser();
41
- }
42
- return user;
43
- }
44
+ getUser,
45
+ loadUserData: getUser
44
46
  };
45
47
  };
46
48
  };
@@ -1,7 +1,7 @@
1
1
  import { User } from '..';
2
2
  import { Window } from '../browser';
3
- export type UserData = {
4
- user?: User;
3
+ export type UserData<T = User> = {
4
+ user?: T;
5
5
  token: string | null;
6
6
  };
7
7
  type UserDataLoader = () => Promise<UserData>;
@@ -13,18 +13,6 @@ export declare const isFolderValue: (thing: any) => thing is FolderValue;
13
13
  export interface FileServerAdapter {
14
14
  putFileContent: (source: FileValue, content: string) => Promise<FileValue>;
15
15
  getSignedViewerUrl: (source: FileValue) => Promise<string>;
16
- getPublicViewerUrl: (source: FileValue) => Promise<string>;
17
16
  getFileContent: (source: FileValue) => Promise<Buffer>;
18
- getSignedFileUploadConfig: () => Promise<{
19
- url: string;
20
- payload: {
21
- [key: string]: string;
22
- };
23
- }>;
24
- copyFileTo: (source: FileValue, destinationPath: string) => Promise<FileValue>;
25
- copyFileToDirectory: (source: FileValue, destinationDirectory: string) => Promise<FileValue>;
26
- isTemporaryUpload: (source: FileValue) => boolean;
27
- getFileChecksum: (source: FileValue) => Promise<string>;
28
- filesEqual: (sourceA: FileValue, sourceB: FileValue) => Promise<boolean>;
29
17
  }
30
18
  export declare const isFileOrFolder: (thing: any) => thing is FileValue | FolderValue;
@@ -5,20 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.localFileServer = void 0;
7
7
  /* cspell:ignore originalname */
8
- const crypto_1 = __importDefault(require("crypto"));
9
8
  const fs_1 = __importDefault(require("fs"));
10
9
  const https_1 = __importDefault(require("https"));
11
10
  const path_1 = __importDefault(require("path"));
12
11
  const cors_1 = __importDefault(require("cors"));
13
12
  const express_1 = __importDefault(require("express"));
14
13
  const multer_1 = __importDefault(require("multer"));
15
- const uuid_1 = require("uuid");
16
14
  const assertions_1 = require("../../assertions");
17
15
  const config_1 = require("../../config");
18
16
  const guards_1 = require("../../guards");
19
17
  const helpers_1 = require("../../misc/helpers");
20
18
  /* istanbul ignore next */
21
- const startServer = (0, helpers_1.memoize)((port, uploadDir) => {
19
+ const startServer = (0, helpers_1.once)((port, uploadDir) => {
22
20
  // TODO - re-evaluate the `preservePath` behavior to match whatever s3 does
23
21
  const upload = (0, multer_1.default)({ dest: uploadDir, preservePath: true });
24
22
  const fileServerApp = (0, express_1.default)();
@@ -63,9 +61,6 @@ const localFileServer = (initializer) => (configProvider) => {
63
61
  const getSignedViewerUrl = async (source) => {
64
62
  return `https://${await host}:${await port}/${source.path}`;
65
63
  };
66
- const getPublicViewerUrl = async (source) => {
67
- return `https://${await host}:${await port}/${source.path}`;
68
- };
69
64
  const getFileContent = async (source) => {
70
65
  const filePath = path_1.default.join(await fileDir, source.path);
71
66
  return fs_1.default.promises.readFile(filePath);
@@ -77,56 +72,10 @@ const localFileServer = (initializer) => (configProvider) => {
77
72
  await fs_1.default.promises.writeFile(filePath, content);
78
73
  return source;
79
74
  };
80
- const getSignedFileUploadConfig = async () => {
81
- const prefix = 'uploads/' + (0, uuid_1.v4)();
82
- return {
83
- url: `https://${await host}:${await port}/`,
84
- payload: {
85
- key: prefix + '/${filename}',
86
- }
87
- };
88
- };
89
- const copyFileTo = async (source, destinationPath) => {
90
- const sourcePath = path_1.default.join(await fileDir, source.path);
91
- const destPath = path_1.default.join(await fileDir, destinationPath);
92
- const destDirectory = path_1.default.dirname(destPath);
93
- await fs_1.default.promises.mkdir(destDirectory, { recursive: true });
94
- await fs_1.default.promises.copyFile(sourcePath, destPath);
95
- return {
96
- ...source,
97
- path: destinationPath
98
- };
99
- };
100
- const copyFileToDirectory = async (source, destination) => {
101
- const destinationPath = path_1.default.join(destination, source.label);
102
- return copyFileTo(source, destinationPath);
103
- };
104
- const isTemporaryUpload = (source) => {
105
- return source.path.indexOf('uploads/') === 0;
106
- };
107
- const getFileChecksum = async (source) => {
108
- const filePath = path_1.default.join(await fileDir, source.path);
109
- const fileContent = await fs_1.default.promises.readFile(filePath);
110
- return crypto_1.default.createHash('md5').update(fileContent).digest('hex');
111
- };
112
- const filesEqual = async (sourceA, sourceB) => {
113
- const [aSum, bSum] = await Promise.all([
114
- getFileChecksum(sourceA),
115
- getFileChecksum(sourceB)
116
- ]);
117
- return aSum === bSum;
118
- };
119
75
  return {
120
76
  getSignedViewerUrl,
121
- getPublicViewerUrl,
122
77
  getFileContent,
123
78
  putFileContent,
124
- getSignedFileUploadConfig,
125
- copyFileTo,
126
- copyFileToDirectory,
127
- isTemporaryUpload,
128
- getFileChecksum,
129
- filesEqual,
130
79
  };
131
80
  };
132
81
  exports.localFileServer = localFileServer;
@@ -4,7 +4,6 @@ import { FileServerAdapter } from '.';
4
4
  export type Config = {
5
5
  bucketName: string;
6
6
  bucketRegion: string;
7
- publicViewerDomain?: string;
8
7
  };
9
8
  interface Initializer<C> {
10
9
  configSpace?: C;
@@ -1,15 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.s3FileServer = void 0;
7
4
  /* cspell:ignore presigner */
8
- const path_1 = __importDefault(require("path"));
9
5
  const client_s3_1 = require("@aws-sdk/client-s3");
10
- const s3_presigned_post_1 = require("@aws-sdk/s3-presigned-post");
11
6
  const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
12
- const uuid_1 = require("uuid");
13
7
  const __1 = require("../..");
14
8
  const assertions_1 = require("../../assertions");
15
9
  const config_1 = require("../../config");
@@ -18,9 +12,6 @@ const s3FileServer = (initializer) => (configProvider) => {
18
12
  const config = configProvider[(0, guards_1.ifDefined)(initializer.configSpace, 'deployed')];
19
13
  const bucketName = (0, __1.once)(() => (0, config_1.resolveConfigValue)(config.bucketName));
20
14
  const bucketRegion = (0, __1.once)(() => (0, config_1.resolveConfigValue)(config.bucketRegion));
21
- const publicViewerDomain = (0, __1.once)(() => 'publicViewerDomain' in config && config.publicViewerDomain
22
- ? (0, config_1.resolveConfigValue)(config.publicViewerDomain)
23
- : undefined);
24
15
  const s3Service = (0, __1.once)(async () => {
25
16
  var _a, _b;
26
17
  const args = { apiVersion: '2012-08-10', region: await bucketRegion() };
@@ -36,10 +27,6 @@ const s3FileServer = (initializer) => (configProvider) => {
36
27
  expiresIn: 3600, // 1 hour
37
28
  });
38
29
  };
39
- const getPublicViewerUrl = async (source) => {
40
- const host = (0, assertions_1.assertDefined)(await publicViewerDomain(), new Error(`Tried to get public viewer URL for ${source.path} but no publicViewerDomain configured`));
41
- return `https://${host}/${source.path}`;
42
- };
43
30
  const getFileContent = async (source) => {
44
31
  const bucket = await bucketName();
45
32
  const command = new client_s3_1.GetObjectCommand({ Bucket: bucket, Key: source.path });
@@ -57,75 +44,10 @@ const s3FileServer = (initializer) => (configProvider) => {
57
44
  await (await s3Service()).send(command);
58
45
  return source;
59
46
  };
60
- /*
61
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_s3_presigned_post.html
62
- * https://docs.aws.amazon.com/AmazonS3/latest/userguide/HTTPPOSTExamples.html
63
- * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
64
- */
65
- const getSignedFileUploadConfig = async () => {
66
- const prefix = 'uploads/' + (0, uuid_1.v4)();
67
- const bucket = (await bucketName());
68
- const Conditions = [
69
- { acl: 'private' },
70
- { bucket },
71
- ['starts-with', '$key', prefix]
72
- ];
73
- const defaultFields = {
74
- acl: 'private',
75
- };
76
- const { url, fields } = await (0, s3_presigned_post_1.createPresignedPost)(await s3Service(), {
77
- Bucket: bucket,
78
- Key: prefix + '/${filename}',
79
- Conditions,
80
- Fields: defaultFields,
81
- Expires: 3600, // 1 hour
82
- });
83
- return {
84
- url, payload: fields
85
- };
86
- };
87
- const copyFileTo = async (source, destinationPath) => {
88
- const bucket = (await bucketName());
89
- const destinationPathWithoutLeadingSlash = destinationPath.replace(/^\//, '');
90
- const command = new client_s3_1.CopyObjectCommand({
91
- Bucket: bucket,
92
- Key: destinationPathWithoutLeadingSlash,
93
- CopySource: path_1.default.join(bucket, source.path),
94
- });
95
- await (await s3Service()).send(command);
96
- return {
97
- ...source,
98
- path: destinationPathWithoutLeadingSlash
99
- };
100
- };
101
- const copyFileToDirectory = async (source, destination) => {
102
- const destinationPath = path_1.default.join(destination, source.label);
103
- return copyFileTo(source, destinationPath);
104
- };
105
- const isTemporaryUpload = (source) => {
106
- return source.path.indexOf('uploads/') === 0;
107
- };
108
- const getFileChecksum = async (source) => {
109
- const bucket = (await bucketName());
110
- const command = new client_s3_1.HeadObjectCommand({ Bucket: bucket, Key: source.path });
111
- const response = await (await s3Service()).send(command);
112
- return (0, assertions_1.assertDefined)(response.ETag);
113
- };
114
- const filesEqual = async (sourceA, sourceB) => {
115
- const [aSum, bSum] = await Promise.all([getFileChecksum(sourceA), getFileChecksum(sourceB)]);
116
- return aSum === bSum;
117
- };
118
47
  return {
119
48
  getFileContent,
120
49
  putFileContent,
121
50
  getSignedViewerUrl,
122
- getPublicViewerUrl,
123
- getSignedFileUploadConfig,
124
- copyFileTo,
125
- copyFileToDirectory,
126
- isTemporaryUpload,
127
- getFileChecksum,
128
- filesEqual,
129
51
  };
130
52
  };
131
53
  exports.s3FileServer = s3FileServer;
@@ -29,6 +29,10 @@ const openSearchService = (initializer = {}) => (configProvider) => {
29
29
  maxRetries: 4, // default is 3
30
30
  requestTimeout: 5000, // default is 30000
31
31
  pingTimeout: 2000, // default is 30000
32
+ sniffOnConnectionFault: true,
33
+ sniffOnStart: true,
34
+ resurrectStrategy: 'ping',
35
+ agent: { keepAlive: false },
32
36
  node: await (0, config_1.resolveConfigValue)(config.node),
33
37
  }));
34
38
  return (indexConfig) => {
@@ -64,9 +68,6 @@ const openSearchService = (initializer = {}) => (configProvider) => {
64
68
  body: params.body,
65
69
  id: params.id,
66
70
  refresh: true
67
- }, {
68
- requestTimeout: 10000,
69
- maxRetries: 1,
70
71
  });
71
72
  };
72
73
  const bulkIndex = async (items) => {
@@ -78,9 +79,6 @@ const openSearchService = (initializer = {}) => (configProvider) => {
78
79
  item.body
79
80
  ]),
80
81
  refresh: true
81
- }, {
82
- requestTimeout: 10000,
83
- maxRetries: 1,
84
82
  });
85
83
  };
86
84
  const search = async (options) => {