Skip to content

Commit 6f5da79

Browse files
committed
fix: format ts files
1 parent 18c7bf0 commit 6f5da79

File tree

1 file changed

+40
-23
lines changed

1 file changed

+40
-23
lines changed
Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
21
import * as fs from 'fs';
32
import * as path from 'path';
43
import AwsService from './aws.service';
54
import { WorkflowSettings } from './opensearch-domain.service';
65

76
export default class OpenSearchRollupService extends AwsService {
8-
public async createOrUpdateRollupJob(settings: WorkflowSettings): Promise<any> {
7+
public async createOrUpdateRollupJob(
8+
settings: WorkflowSettings,
9+
): Promise<any> {
910
const templateDir = path.resolve(
1011
__dirname,
1112
'../../configuration-opensearch/rollup_index_jobs',
@@ -15,25 +16,38 @@ export default class OpenSearchRollupService extends AwsService {
1516
if (!filePath.endsWith('.json')) {
1617
continue;
1718
}
18-
const rollupJobName = path.basename(filePath, '.json');
19-
let rollupJobPath = `/_plugins/_rollup/jobs/${rollupJobName}`;
19+
const rollupJobName = path.basename(filePath, '.json');
20+
let rollupJobPath = `/_plugins/_rollup/jobs/${rollupJobName}`;
2021
const exists = await this.checkRollupJobExists(settings, rollupJobName);
21-
const rollupConfig = JSON.parse(fs.readFileSync(path.join(templateDir, filePath), 'utf8'));
22+
const rollupConfig = JSON.parse(
23+
fs.readFileSync(path.join(templateDir, filePath), 'utf8'),
24+
);
2225

2326
if (exists) {
2427
rollupJobPath += '?if_seq_no=1&if_primary_term=1';
2528
console.log(`Updating existing rollup job: ${rollupJobName}`);
26-
return this.executeRollupRequest('PUT', settings, rollupJobPath, rollupConfig)
27-
.then((res) => {
28-
console.log(`PUT ${rollupJobPath}\n[${res.statusCode}] Rollup job updated`);
29+
return this.executeRollupRequest(
30+
'PUT',
31+
settings,
32+
rollupJobPath,
33+
rollupConfig,
34+
).then((res) => {
35+
console.log(
36+
`PUT ${rollupJobPath}\n[${res.statusCode}] Rollup job updated`,
37+
);
2938
});
30-
}
31-
else {
39+
} else {
3240
console.log(`Creating new rollup job: ${rollupJobName}`);
33-
return this.executeRollupRequest('PUT', settings, rollupJobPath, rollupConfig)
34-
.then((res) => {
35-
console.log(`PUT ${rollupJobPath}\n[${res.statusCode}] Rollup job created`);
36-
});
41+
return this.executeRollupRequest(
42+
'PUT',
43+
settings,
44+
rollupJobPath,
45+
rollupConfig,
46+
).then((res) => {
47+
console.log(
48+
`PUT ${rollupJobPath}\n[${res.statusCode}] Rollup job created`,
49+
);
50+
});
3751
}
3852
}
3953
}
@@ -42,35 +56,39 @@ export default class OpenSearchRollupService extends AwsService {
4256
method: string,
4357
settings: WorkflowSettings,
4458
path: string,
45-
body?: any
59+
body?: any,
4660
): Promise<any> {
47-
4861
const [pathWithoutQuery, queryString] = path.split('?');
4962
const queryParams = queryString
50-
? Object.fromEntries(new URLSearchParams(queryString).entries())
51-
: undefined;
63+
? Object.fromEntries(new URLSearchParams(queryString).entries())
64+
: undefined;
5265
const requestOptions = {
5366
method,
5467
headers: {
5568
'Content-Type': 'application/json',
5669
host: settings.hostname,
5770
},
5871
hostname: settings.hostname,
59-
path:pathWithoutQuery,
72+
path: pathWithoutQuery,
6073
query: queryParams,
6174
body: body ? JSON.stringify(body) : undefined,
6275
};
63-
76+
6477
return this.executeSignedHttpRequest(requestOptions)
6578
.then((res) => this.waitAndReturnResponseBody(res))
6679
.catch((err) => {
67-
console.error(`Error during ${method} request to ${path}: ${err.message}`);
80+
console.error(
81+
`Error during ${method} request to ${path}: ${err.message}`,
82+
);
6883
throw err;
6984
});
7085
}
7186

7287
// check if the rollup job exists
73-
private async checkRollupJobExists(settings: WorkflowSettings, jobName: string): Promise<boolean> {
88+
private async checkRollupJobExists(
89+
settings: WorkflowSettings,
90+
jobName: string,
91+
): Promise<boolean> {
7492
const rollupJobPath = `/_plugins/_rollup/jobs/${jobName}`;
7593
return this.executeRollupRequest('GET', settings, rollupJobPath)
7694
.then((res) => {
@@ -93,5 +111,4 @@ export default class OpenSearchRollupService extends AwsService {
93111
throw err;
94112
});
95113
}
96-
97114
}

0 commit comments

Comments
 (0)