@openstax/ts-utils 1.31.1 → 1.31.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.
- package/dist/cjs/services/fileServer/index.d.ts +1 -0
- package/dist/cjs/services/fileServer/localFileServer.js +4 -0
- package/dist/cjs/services/fileServer/s3FileServer.d.ts +1 -0
- package/dist/cjs/services/fileServer/s3FileServer.js +9 -1
- package/dist/cjs/services/searchProvider/openSearch.js +6 -3
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/fileServer/index.d.ts +1 -0
- package/dist/esm/services/fileServer/localFileServer.js +4 -0
- package/dist/esm/services/fileServer/s3FileServer.d.ts +1 -0
- package/dist/esm/services/fileServer/s3FileServer.js +9 -1
- package/dist/esm/services/searchProvider/openSearch.js +6 -3
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ 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>;
|
|
16
17
|
getFileContent: (source: FileValue) => Promise<Buffer>;
|
|
17
18
|
getSignedFileUploadConfig: () => Promise<{
|
|
18
19
|
url: string;
|
|
@@ -57,6 +57,9 @@ export const localFileServer = (initializer) => (configProvider) => {
|
|
|
57
57
|
const getSignedViewerUrl = async (source) => {
|
|
58
58
|
return `https://${await host}:${await port}/${source.path}`;
|
|
59
59
|
};
|
|
60
|
+
const getPublicViewerUrl = async (source) => {
|
|
61
|
+
return `https://${await host}:${await port}/${source.path}`;
|
|
62
|
+
};
|
|
60
63
|
const getFileContent = async (source) => {
|
|
61
64
|
const filePath = path.join(await fileDir, source.path);
|
|
62
65
|
return fs.promises.readFile(filePath);
|
|
@@ -109,6 +112,7 @@ export const localFileServer = (initializer) => (configProvider) => {
|
|
|
109
112
|
};
|
|
110
113
|
return {
|
|
111
114
|
getSignedViewerUrl,
|
|
115
|
+
getPublicViewerUrl,
|
|
112
116
|
getFileContent,
|
|
113
117
|
putFileContent,
|
|
114
118
|
getSignedFileUploadConfig,
|
|
@@ -12,6 +12,9 @@ export const s3FileServer = (initializer) => (configProvider) => {
|
|
|
12
12
|
const config = configProvider[ifDefined(initializer.configSpace, 'deployed')];
|
|
13
13
|
const bucketName = once(() => resolveConfigValue(config.bucketName));
|
|
14
14
|
const bucketRegion = once(() => resolveConfigValue(config.bucketRegion));
|
|
15
|
+
const publicViewerDomain = once(() => 'publicViewerDomain' in config && config.publicViewerDomain
|
|
16
|
+
? resolveConfigValue(config.publicViewerDomain)
|
|
17
|
+
: undefined);
|
|
15
18
|
const s3Service = once(async () => {
|
|
16
19
|
var _a, _b;
|
|
17
20
|
const args = { apiVersion: '2012-08-10', region: await bucketRegion() };
|
|
@@ -27,6 +30,10 @@ export const s3FileServer = (initializer) => (configProvider) => {
|
|
|
27
30
|
expiresIn: 3600, // 1 hour
|
|
28
31
|
});
|
|
29
32
|
};
|
|
33
|
+
const getPublicViewerUrl = async (source) => {
|
|
34
|
+
const host = assertDefined(await publicViewerDomain(), new Error(`Tried to get public viewer URL for ${source.path} but no publicViewerDomain configured`));
|
|
35
|
+
return `https://${host}/${source.path}`;
|
|
36
|
+
};
|
|
30
37
|
const getFileContent = async (source) => {
|
|
31
38
|
const bucket = await bucketName();
|
|
32
39
|
const command = new GetObjectCommand({ Bucket: bucket, Key: source.path });
|
|
@@ -65,7 +72,7 @@ export const s3FileServer = (initializer) => (configProvider) => {
|
|
|
65
72
|
Key: prefix + '/${filename}',
|
|
66
73
|
Conditions,
|
|
67
74
|
Fields: defaultFields,
|
|
68
|
-
Expires: 3600, // 1 hour
|
|
75
|
+
Expires: 3600, // 1 hour
|
|
69
76
|
});
|
|
70
77
|
return {
|
|
71
78
|
url, payload: fields
|
|
@@ -106,6 +113,7 @@ export const s3FileServer = (initializer) => (configProvider) => {
|
|
|
106
113
|
getFileContent,
|
|
107
114
|
putFileContent,
|
|
108
115
|
getSignedViewerUrl,
|
|
116
|
+
getPublicViewerUrl,
|
|
109
117
|
getSignedFileUploadConfig,
|
|
110
118
|
copyFileTo,
|
|
111
119
|
copyFileToDirectory,
|
|
@@ -26,9 +26,6 @@ export const openSearchService = (initializer = {}) => (configProvider) => {
|
|
|
26
26
|
maxRetries: 4, // default is 3
|
|
27
27
|
requestTimeout: 5000, // default is 30000
|
|
28
28
|
pingTimeout: 2000, // default is 30000
|
|
29
|
-
sniffOnConnectionFault: true,
|
|
30
|
-
sniffOnStart: true,
|
|
31
|
-
resurrectStrategy: 'ping',
|
|
32
29
|
node: await resolveConfigValue(config.node),
|
|
33
30
|
}));
|
|
34
31
|
return (indexConfig) => {
|
|
@@ -64,6 +61,9 @@ export const openSearchService = (initializer = {}) => (configProvider) => {
|
|
|
64
61
|
body: params.body,
|
|
65
62
|
id: params.id,
|
|
66
63
|
refresh: true
|
|
64
|
+
}, {
|
|
65
|
+
requestTimeout: 10000,
|
|
66
|
+
maxRetries: 1,
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
69
|
const bulkIndex = async (items) => {
|
|
@@ -75,6 +75,9 @@ export const openSearchService = (initializer = {}) => (configProvider) => {
|
|
|
75
75
|
item.body
|
|
76
76
|
]),
|
|
77
77
|
refresh: true
|
|
78
|
+
}, {
|
|
79
|
+
requestTimeout: 10000,
|
|
80
|
+
maxRetries: 1,
|
|
78
81
|
});
|
|
79
82
|
};
|
|
80
83
|
const search = async (options) => {
|