Skip to content

Commit 77184d1

Browse files
committed
chore(entity-archival): rebase
gh-1778
1 parent 0841379 commit 77184d1

File tree

5 files changed

+20
-39
lines changed

5 files changed

+20
-39
lines changed

packages/archival/src/aws-s3/export-archive-data.provider.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ export class ExportArchiveDataProvider
1414
private readonly config: AwsS3Config,
1515
) {}
1616
value(): ExportDataExternalSystem {
17-
return async (seletedEntries: AnyObject[]) => {
18-
return this.exportToCsv(seletedEntries);
19-
};
17+
return async (seletedEntries: AnyObject[]) =>
18+
this.exportToCsv(seletedEntries);
2019
}
2120
async exportToCsv(seletedEntries: AnyObject[]): Promise<string> {
2221
const csvRows = [];

packages/archival/src/aws-s3/import-archive-data.provider.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ export class ImportArchiveDataProvider
1414
implements Provider<ImportDataExternalSystem>
1515
{
1616
value(): ValueOrPromise<ImportDataExternalSystem> {
17-
return async (fileName: string) => {
18-
return this.getFileContent(fileName);
19-
};
17+
return async (fileName: string) => this.getFileContent(fileName);
2018
}
2119

2220
async getFileContent(fileName: string): Promise<AnyObject[]> {
@@ -40,27 +38,25 @@ export class ImportArchiveDataProvider
4038
const csvData = data.Body!.toString('utf-8');
4139

4240
const jsonArray: AnyObject[] = await new Promise((resolve, reject) => {
43-
const results: any[] = [];
41+
const results: AnyObject[] = [];
4442
stream.Readable.from(csvData)
4543
.pipe(csv())
46-
.on('data', (data: any) => results.push(data))
44+
.on('data', (data: AnyObject) => results.push(data))
4745
.on('end', () => resolve(results))
4846
.on('error', reject);
4947
});
5048
const headers = Object.keys(jsonArray[0]);
5149
for (const entry of jsonArray) {
5250
for (const key of headers) {
53-
if (entry.hasOwnProperty(key)) {
54-
const value = entry[key];
55-
if (value === '') {
56-
entry[key] = null;
57-
} else if (
58-
typeof value === 'string' &&
59-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(value)
60-
) {
61-
entry[key] = new Date(value);
62-
} else entry[key] = value;
63-
}
51+
const value = entry[key];
52+
if (value === '') {
53+
entry[key] = null;
54+
} else if (
55+
typeof value === 'string' &&
56+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(value)
57+
) {
58+
entry[key] = new Date(value);
59+
} else entry[key] = value;
6460
}
6561
}
6662
return jsonArray;

packages/archival/src/mixins/archival.mixin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function ArchivalRepositoryMixin<
2828
T extends UserModifiableEntity,
2929
ID,
3030
Relations extends object,
31-
//sonarignore:end
3231
R extends ArchiveMixinBase<T, ID, Relations>,
3332
>(superClass: R, opts: AnyObject): R & AbstractConstructor<IArchiveMixin> {
3433
abstract class MixedRepository extends superClass implements IArchiveMixin {
@@ -103,7 +102,7 @@ export function ArchivalRepositoryMixin<
103102
return (
104103
optionsActorId ??
105104
// eslint-disable-next-line @typescript-eslint/no-explicit-any
106-
(user[this.actorIdKey ?? 'id'] as any)?.toString() ?? //NOSOAR
105+
(user[this.actorIdKey ?? 'id'] as any)?.toString() ?? //NOSONAR
107106
'0'
108107
);
109108
}

packages/archival/src/services/import-archived-data.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828

2929
@injectable({scope: BindingScope.TRANSIENT})
3030
export class ImportArchivedDataService {
31-
repo: any;
31+
repo: AnyObject;
3232
constructor(
3333
@repository(JobDetailsRepository)
3434
public jobDetailsRepo: JobDetailsRepository,
@@ -110,6 +110,7 @@ export class ImportArchivedDataService {
110110

111111
async getFilteredData() {}
112112

113+
// sonarignore:start
113114
private async getRepositoryByModelName<T extends Entity>(
114115
modelName: string,
115116
): Promise<DefaultCrudRepository<T, any> | undefined> {
@@ -126,7 +127,7 @@ export class ImportArchivedDataService {
126127
return repository as DefaultCrudRepository<T, any>;
127128
}
128129
}
129-
130+
// sonarignore:end
130131
return undefined; // Return undefined if no matching repository is found
131132
}
132133
}

packages/archival/src/types.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
AnyObject,
3-
Count,
4-
Entity,
5-
Filter,
6-
Options,
7-
Where,
8-
} from '@loopback/repository';
1+
import {AnyObject, Count, Filter, Options, Where} from '@loopback/repository';
92
import {UserModifiableEntity} from '@sourceloop/core';
103
import {ArchiveMapping} from './models';
114

@@ -25,7 +18,7 @@ export const DEFAULT_ARCHIVAL_OPTIONS: ArchivalComponentOptions = {
2518

2619
export type AbstractConstructor<T> = abstract new (
2720
// eslint-disable-next-line @typescript-eslint/no-explicit-any
28-
...args: any[]
21+
...args: any[] //NOSONAR
2922
) => T;
3023

3124
export type MixinBaseClass<T> = AbstractConstructor<T>;
@@ -101,13 +94,6 @@ export type GetJobDetailsFn = (
10194

10295
export const ArchivalDbSourceName = 'ArchivalDB';
10396

104-
export interface LoopBackModelClass<T extends Entity> {
105-
new (): T;
106-
modelName: string;
107-
definition?: any; // Adjust the type as needed
108-
relations?: any; // Adjust the type as needed
109-
}
110-
11197
export interface IBuildWhereConditionService {
11298
buildConditionForInsert(where: AnyObject | undefined): Promise<AnyObject>;
11399
buildConditionForFetch(

0 commit comments

Comments
 (0)