@punks/backend-entity-manager 0.0.402 → 0.0.405
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/index.js +160 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/files.d.ts +1 -0
- package/dist/cjs/types/abstractions/repository.d.ts +5 -0
- package/dist/cjs/types/integrations/repository/typeorm/repository.d.ts +5 -0
- package/dist/cjs/types/platforms/nest/plugins/buckets/aws-s3/provider/files.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/plugins/buckets/testing/mock.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/services/export/index.d.ts +2 -0
- package/dist/cjs/types/platforms/nest/services/export/serializer.d.ts +13 -0
- package/dist/cjs/types/platforms/nest/services/export/service.d.ts +15 -0
- package/dist/cjs/types/platforms/nest/services/export/types.d.ts +23 -0
- package/dist/cjs/types/platforms/nest/services/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/services/providers.d.ts +2 -1
- package/dist/cjs/types/testing/mocks/repository.d.ts +5 -0
- package/dist/esm/index.js +162 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/files.d.ts +1 -0
- package/dist/esm/types/abstractions/repository.d.ts +5 -0
- package/dist/esm/types/integrations/repository/typeorm/repository.d.ts +5 -0
- package/dist/esm/types/platforms/nest/plugins/buckets/aws-s3/provider/files.d.ts +1 -0
- package/dist/esm/types/platforms/nest/plugins/buckets/testing/mock.d.ts +1 -0
- package/dist/esm/types/platforms/nest/services/export/index.d.ts +2 -0
- package/dist/esm/types/platforms/nest/services/export/serializer.d.ts +13 -0
- package/dist/esm/types/platforms/nest/services/export/service.d.ts +15 -0
- package/dist/esm/types/platforms/nest/services/export/types.d.ts +23 -0
- package/dist/esm/types/platforms/nest/services/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/services/providers.d.ts +2 -1
- package/dist/esm/types/testing/mocks/repository.d.ts +5 -0
- package/dist/index.d.ts +48 -1
- package/package.json +1 -1
|
@@ -68,4 +68,5 @@ export interface IFileProvider {
|
|
|
68
68
|
deleteFile(reference: FileProviderReference): Promise<void>;
|
|
69
69
|
downloadFile(reference: FileProviderReference): Promise<FileProviderDownloadData>;
|
|
70
70
|
getFileProviderDownloadUrl(reference: FileProviderReference): Promise<FileProviderDownloadUrl>;
|
|
71
|
+
get defaultBucket(): string;
|
|
71
72
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EntityReference } from "../models";
|
|
1
2
|
import { DeepPartial } from "../types";
|
|
2
3
|
export interface IEntitiesDeleteResult {
|
|
3
4
|
deletedCount: number;
|
|
@@ -19,4 +20,8 @@ export interface IEntityRepository<TEntity, TEntityId, TGetConditions, TFindCond
|
|
|
19
20
|
update(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
20
21
|
updateBy(entity: DeepPartial<TEntity>, condition: TUpdateCondition): Promise<TEntity[]>;
|
|
21
22
|
upsert(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
23
|
+
upsertBy({ data, filter, }: {
|
|
24
|
+
data: Partial<TEntity>;
|
|
25
|
+
filter: TFindCondition;
|
|
26
|
+
}): Promise<EntityReference<string>>;
|
|
22
27
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FindManyOptions, FindOneOptions, FindOptionsRelations, FindOptionsWhere, ObjectId, ObjectLiteral, Repository } from "typeorm";
|
|
2
2
|
import { IEntityRepository } from "../../../abstractions";
|
|
3
3
|
import { IEntitiesDeleteResult } from "../../../abstractions/repository";
|
|
4
|
+
import { EntityReference } from "../../../models";
|
|
4
5
|
export type UpdateCriteria<TEntity extends ObjectLiteral> = string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<TEntity>;
|
|
5
6
|
export type DeleteCriteria<TEntity extends ObjectLiteral> = string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<TEntity>;
|
|
6
7
|
export declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId> implements IEntityRepository<TEntity, TEntityId, FindOneOptions<TEntity>, FindManyOptions<TEntity>, UpdateCriteria<TEntity>, DeleteCriteria<TEntity>> {
|
|
@@ -27,4 +28,8 @@ export declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId>
|
|
|
27
28
|
update(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
28
29
|
updateBy(entity: Partial<TEntity>, condition: UpdateCriteria<TEntity>): Promise<TEntity[]>;
|
|
29
30
|
upsert(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
31
|
+
upsertBy({ data, filter, }: {
|
|
32
|
+
data: Partial<TEntity>;
|
|
33
|
+
filter: FindManyOptions<TEntity>;
|
|
34
|
+
}): Promise<EntityReference<string>>;
|
|
30
35
|
}
|
|
@@ -9,4 +9,5 @@ export declare class AwsS3FileProvider implements IFileProvider {
|
|
|
9
9
|
downloadFile(reference: FileProviderReference): Promise<FileProviderDownloadData>;
|
|
10
10
|
getFileProviderDownloadUrl(reference: FileProviderReference): Promise<FileProviderDownloadUrl>;
|
|
11
11
|
private getBucketFileUploadPath;
|
|
12
|
+
get defaultBucket(): string;
|
|
12
13
|
}
|
|
@@ -9,6 +9,7 @@ export declare class InMemoryFileProvider implements IFileProvider {
|
|
|
9
9
|
deleteFile(reference: FileProviderReference): Promise<void>;
|
|
10
10
|
downloadFile(reference: FileProviderReference): Promise<FileProviderDownloadData>;
|
|
11
11
|
getFileProviderDownloadUrl(reference: FileProviderReference): Promise<FileProviderDownloadUrl>;
|
|
12
|
+
get defaultBucket(): string;
|
|
12
13
|
}
|
|
13
14
|
export declare class InMemoryBucketProvider implements IBucketProvider {
|
|
14
15
|
private inMemoryStorage;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { DataSerializationFormat, DataSerializerColumnDefinition } from "./types";
|
|
3
|
+
export declare class DataExportSerializer<TExportItem> {
|
|
4
|
+
serialize(items: TExportItem[], exportParams: {
|
|
5
|
+
name: string;
|
|
6
|
+
format: DataSerializationFormat;
|
|
7
|
+
columns: DataSerializerColumnDefinition<TExportItem>[];
|
|
8
|
+
}): {
|
|
9
|
+
contentType: string;
|
|
10
|
+
content: Buffer;
|
|
11
|
+
};
|
|
12
|
+
private getColumnValue;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DataExportFile, DataExportInput } from "./types";
|
|
2
|
+
import { EntityManagerRegistry } from "../../ioc/registry";
|
|
3
|
+
export declare class DataExportService {
|
|
4
|
+
private readonly registry;
|
|
5
|
+
constructor(registry: EntityManagerRegistry);
|
|
6
|
+
exportData<TSheetItem>(data: TSheetItem[], input: DataExportInput<TSheetItem>): Promise<{
|
|
7
|
+
downloadUrl: import("../../../../abstractions/files").FileProviderDownloadUrl;
|
|
8
|
+
file: DataExportFile;
|
|
9
|
+
}>;
|
|
10
|
+
extractData<TSheetItem>(data: TSheetItem[], input: DataExportInput<TSheetItem>): Promise<DataExportFile>;
|
|
11
|
+
private uploadExportFile;
|
|
12
|
+
private buildExportFilePath;
|
|
13
|
+
private get defaultFileProvider();
|
|
14
|
+
private get defaultBucketProvider();
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export type DataExportInput<TSheetItem> = {
|
|
3
|
+
name: string;
|
|
4
|
+
columns: DataSerializerColumnDefinition<TSheetItem>[];
|
|
5
|
+
format: DataSerializationFormat;
|
|
6
|
+
};
|
|
7
|
+
export type DataSerializerColumnDefinition<TSheetItem> = {
|
|
8
|
+
name: string;
|
|
9
|
+
key: string;
|
|
10
|
+
selector: keyof TSheetItem | ((item: TSheetItem) => any);
|
|
11
|
+
colSpan?: number;
|
|
12
|
+
array?: boolean;
|
|
13
|
+
arraySeparator?: string;
|
|
14
|
+
};
|
|
15
|
+
export type DataExportFile = {
|
|
16
|
+
content: Buffer;
|
|
17
|
+
contentType: string;
|
|
18
|
+
};
|
|
19
|
+
export declare enum DataSerializationFormat {
|
|
20
|
+
Csv = "csv",
|
|
21
|
+
Json = "json",
|
|
22
|
+
Xlsx = "xlsx"
|
|
23
|
+
}
|
|
@@ -4,6 +4,7 @@ export { EntityManagerService } from "./manager";
|
|
|
4
4
|
export { MediaLibraryService } from "./media";
|
|
5
5
|
export * from "./operations";
|
|
6
6
|
export { EmailService } from "./email";
|
|
7
|
+
export * from "./export";
|
|
7
8
|
export { CacheService } from "./cache";
|
|
8
9
|
export { FilesManager } from "./files";
|
|
9
10
|
export { EventsService } from "./events";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CacheService } from "./cache";
|
|
2
2
|
import { EmailService } from "./email";
|
|
3
3
|
import { EventsService } from "./events";
|
|
4
|
+
import { DataExportService } from "./export";
|
|
4
5
|
import { FilesManager } from "./files";
|
|
5
6
|
import { AppHashingService } from "./hashing";
|
|
6
7
|
import { EntityManagerService } from "./manager";
|
|
@@ -9,4 +10,4 @@ import { OperationLockService } from "./operations/operation-lock.service";
|
|
|
9
10
|
import { SecretsService } from "./secrets";
|
|
10
11
|
import { AppSessionService } from "./session";
|
|
11
12
|
import { TrackingService } from "./tracking";
|
|
12
|
-
export declare const Services: (typeof AppSessionService | typeof AppHashingService | typeof EntityManagerService | typeof MediaLibraryService | typeof OperationLockService | typeof EmailService | typeof CacheService | typeof FilesManager | typeof EventsService | typeof TrackingService | typeof SecretsService)[];
|
|
13
|
+
export declare const Services: (typeof AppSessionService | typeof AppHashingService | typeof EntityManagerService | typeof MediaLibraryService | typeof OperationLockService | typeof EmailService | typeof DataExportService | typeof CacheService | typeof FilesManager | typeof EventsService | typeof TrackingService | typeof SecretsService)[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FilterExpression } from "../../abstractions/filters";
|
|
2
2
|
import { IEntitiesDeleteResult, IEntityRepository } from "../../abstractions/repository";
|
|
3
|
+
import { EntityReference } from "../../models";
|
|
3
4
|
export declare class InMemoryRepository<TEntity> implements IEntityRepository<TEntity, string, FilterExpression<TEntity>, FilterExpression<TEntity>, FilterExpression<TEntity>, FilterExpression<TEntity>> {
|
|
4
5
|
private entities;
|
|
5
6
|
exists(id: string): Promise<boolean>;
|
|
@@ -18,6 +19,10 @@ export declare class InMemoryRepository<TEntity> implements IEntityRepository<TE
|
|
|
18
19
|
update(id: string, entity: Partial<TEntity>): Promise<TEntity>;
|
|
19
20
|
updateBy(entity: Partial<TEntity>, condition: FilterExpression<TEntity>): Promise<TEntity[]>;
|
|
20
21
|
upsert(id: string, entity: TEntity): Promise<TEntity>;
|
|
22
|
+
upsertBy({ data, filter, }: {
|
|
23
|
+
data: Partial<TEntity>;
|
|
24
|
+
filter: FilterExpression<TEntity>;
|
|
25
|
+
}): Promise<EntityReference<string>>;
|
|
21
26
|
private getId;
|
|
22
27
|
private filterEntities;
|
|
23
28
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Log, csvParse, excelParse, ExcelKeyTransform, excelBuild, csvBuild, mapAsync, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, toDict, sleep, distinct, sort, byField, toArrayDict, toItemsDict, floorDateToSecond, ensureTailingSlash, ensureStartSlash, removeUndefinedProps } from '@punks/backend-core';
|
|
1
|
+
import { Log, csvParse, excelParse, ExcelKeyTransform, excelBuild, csvBuild, mapAsync, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, toDict, sleep, distinct, createDayPath as createDayPath$2, sort, byField, toArrayDict, toItemsDict, floorDateToSecond, ensureTailingSlash, ensureStartSlash, removeUndefinedProps } from '@punks/backend-core';
|
|
2
2
|
import { QueryCommand, ScanCommand, GetItemCommand, PutItemCommand, DeleteItemCommand, DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
3
3
|
import { unmarshall, marshall } from '@aws-sdk/util-dynamodb';
|
|
4
4
|
import { Module, applyDecorators, Injectable, SetMetadata, createParamDecorator, Global, Scope, Inject, Logger, StreamableFile, HttpException, HttpStatus } from '@nestjs/common';
|
|
@@ -184,16 +184,16 @@ class EntitySeeder {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
const normalizeSheetColumn = (column) => column.replace(/ /g, "").toLowerCase();
|
|
187
|
-
const DEFAULT_DELIMITER = ";";
|
|
188
|
-
const DEFAULT_ARRAY_SEPARATOR = "|";
|
|
187
|
+
const DEFAULT_DELIMITER$1 = ";";
|
|
188
|
+
const DEFAULT_ARRAY_SEPARATOR$1 = "|";
|
|
189
189
|
const splitArrayColumn = (value, separator) => value
|
|
190
190
|
?.toString()
|
|
191
|
-
.split(separator ?? DEFAULT_ARRAY_SEPARATOR)
|
|
191
|
+
.split(separator ?? DEFAULT_ARRAY_SEPARATOR$1)
|
|
192
192
|
.filter((x) => x.trim()) ?? [];
|
|
193
|
-
const joinArrayColumn = (value, separator) => value
|
|
193
|
+
const joinArrayColumn$1 = (value, separator) => value
|
|
194
194
|
?.map((x) => x.toString().trim())
|
|
195
195
|
.filter((x) => x)
|
|
196
|
-
.join(separator ?? DEFAULT_ARRAY_SEPARATOR);
|
|
196
|
+
.join(separator ?? DEFAULT_ARRAY_SEPARATOR$1);
|
|
197
197
|
class EntitySerializer {
|
|
198
198
|
constructor(services, options) {
|
|
199
199
|
this.services = services;
|
|
@@ -227,7 +227,7 @@ class EntitySerializer {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
parseCsv(data, definition) {
|
|
230
|
-
const records = csvParse(data, DEFAULT_DELIMITER);
|
|
230
|
+
const records = csvParse(data, DEFAULT_DELIMITER$1);
|
|
231
231
|
return records.map((x, i) => this.convertSheetRecord(x, definition, i));
|
|
232
232
|
}
|
|
233
233
|
parseXlsx(data, definition) {
|
|
@@ -323,7 +323,7 @@ class EntitySerializer {
|
|
|
323
323
|
value: () => c.sampleValue ?? "",
|
|
324
324
|
})),
|
|
325
325
|
], {
|
|
326
|
-
delimiter: DEFAULT_DELIMITER,
|
|
326
|
+
delimiter: DEFAULT_DELIMITER$1,
|
|
327
327
|
}), "utf-8"),
|
|
328
328
|
};
|
|
329
329
|
case EntitySerializationFormat.Xlsx:
|
|
@@ -389,12 +389,12 @@ class EntitySerializer {
|
|
|
389
389
|
value: (item) => {
|
|
390
390
|
const value = this.getColumnValue(item, c);
|
|
391
391
|
return c.array
|
|
392
|
-
? joinArrayColumn(value, c.arraySeparator)
|
|
392
|
+
? joinArrayColumn$1(value, c.arraySeparator)
|
|
393
393
|
: value;
|
|
394
394
|
},
|
|
395
395
|
})),
|
|
396
396
|
], {
|
|
397
|
-
delimiter: DEFAULT_DELIMITER,
|
|
397
|
+
delimiter: DEFAULT_DELIMITER$1,
|
|
398
398
|
}), "utf-8"),
|
|
399
399
|
};
|
|
400
400
|
case EntitySerializationFormat.Xlsx:
|
|
@@ -418,7 +418,7 @@ class EntitySerializer {
|
|
|
418
418
|
value: (item) => {
|
|
419
419
|
const value = this.getColumnValue(item, c);
|
|
420
420
|
return c.array
|
|
421
|
-
? joinArrayColumn(value, c.arraySeparator)
|
|
421
|
+
? joinArrayColumn$1(value, c.arraySeparator)
|
|
422
422
|
: value;
|
|
423
423
|
},
|
|
424
424
|
headerSize: c.colSpan,
|
|
@@ -4114,6 +4114,22 @@ class TypeOrmRepository {
|
|
|
4114
4114
|
id,
|
|
4115
4115
|
});
|
|
4116
4116
|
}
|
|
4117
|
+
// todo: fix this
|
|
4118
|
+
async upsertBy({ data, filter, }) {
|
|
4119
|
+
this.logger.debug("Upsert entities by condition", { filter, data });
|
|
4120
|
+
const current = await this.find(filter);
|
|
4121
|
+
if (current) {
|
|
4122
|
+
const id = current.id;
|
|
4123
|
+
await this.update(id, data);
|
|
4124
|
+
return {
|
|
4125
|
+
id,
|
|
4126
|
+
};
|
|
4127
|
+
}
|
|
4128
|
+
const entity = await this.create(data);
|
|
4129
|
+
return {
|
|
4130
|
+
id: entity.id,
|
|
4131
|
+
};
|
|
4132
|
+
}
|
|
4117
4133
|
}
|
|
4118
4134
|
|
|
4119
4135
|
class NestEntityAuthorizationMiddleware {
|
|
@@ -22765,6 +22781,128 @@ EmailService = __decorate([
|
|
|
22765
22781
|
__metadata("design:paramtypes", [EntityManagerRegistry])
|
|
22766
22782
|
], EmailService);
|
|
22767
22783
|
|
|
22784
|
+
var DataSerializationFormat;
|
|
22785
|
+
(function (DataSerializationFormat) {
|
|
22786
|
+
DataSerializationFormat["Csv"] = "csv";
|
|
22787
|
+
DataSerializationFormat["Json"] = "json";
|
|
22788
|
+
DataSerializationFormat["Xlsx"] = "xlsx";
|
|
22789
|
+
})(DataSerializationFormat || (DataSerializationFormat = {}));
|
|
22790
|
+
|
|
22791
|
+
const DEFAULT_DELIMITER = ";";
|
|
22792
|
+
const DEFAULT_ARRAY_SEPARATOR = "|";
|
|
22793
|
+
const joinArrayColumn = (value, separator) => value
|
|
22794
|
+
?.map((x) => x.toString().trim())
|
|
22795
|
+
.filter((x) => x)
|
|
22796
|
+
.join(separator ?? DEFAULT_ARRAY_SEPARATOR);
|
|
22797
|
+
class DataExportSerializer {
|
|
22798
|
+
serialize(items, exportParams) {
|
|
22799
|
+
switch (exportParams.format) {
|
|
22800
|
+
case DataSerializationFormat.Csv:
|
|
22801
|
+
return {
|
|
22802
|
+
contentType: "text/csv",
|
|
22803
|
+
content: Buffer.from(csvBuild(items, exportParams.columns.map((c) => ({
|
|
22804
|
+
name: c.name,
|
|
22805
|
+
value: (item) => {
|
|
22806
|
+
const value = this.getColumnValue(item, c);
|
|
22807
|
+
return c.array
|
|
22808
|
+
? joinArrayColumn(value, c.arraySeparator)
|
|
22809
|
+
: value;
|
|
22810
|
+
},
|
|
22811
|
+
})), {
|
|
22812
|
+
delimiter: DEFAULT_DELIMITER,
|
|
22813
|
+
}), "utf-8"),
|
|
22814
|
+
};
|
|
22815
|
+
case DataSerializationFormat.Xlsx:
|
|
22816
|
+
return {
|
|
22817
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
22818
|
+
content: Buffer.from(excelBuild({
|
|
22819
|
+
data: items,
|
|
22820
|
+
sheetName: exportParams.name,
|
|
22821
|
+
columns: exportParams.columns.map((c) => ({
|
|
22822
|
+
header: c.name,
|
|
22823
|
+
value: (item) => {
|
|
22824
|
+
const value = this.getColumnValue(item, c);
|
|
22825
|
+
return c.array
|
|
22826
|
+
? joinArrayColumn(value, c.arraySeparator)
|
|
22827
|
+
: value;
|
|
22828
|
+
},
|
|
22829
|
+
headerSize: c.colSpan,
|
|
22830
|
+
})),
|
|
22831
|
+
})),
|
|
22832
|
+
};
|
|
22833
|
+
case DataSerializationFormat.Json:
|
|
22834
|
+
return {
|
|
22835
|
+
contentType: "application/json",
|
|
22836
|
+
content: Buffer.from(JSON.stringify(items), "utf-8"),
|
|
22837
|
+
};
|
|
22838
|
+
}
|
|
22839
|
+
}
|
|
22840
|
+
getColumnValue(item, definition) {
|
|
22841
|
+
return typeof definition.selector === "function"
|
|
22842
|
+
? definition.selector(item)
|
|
22843
|
+
: item[definition.selector];
|
|
22844
|
+
}
|
|
22845
|
+
}
|
|
22846
|
+
|
|
22847
|
+
let DataExportService = class DataExportService {
|
|
22848
|
+
constructor(registry) {
|
|
22849
|
+
this.registry = registry;
|
|
22850
|
+
}
|
|
22851
|
+
async exportData(data, input) {
|
|
22852
|
+
const file = await this.extractData(data, input);
|
|
22853
|
+
const downloadUrl = await this.uploadExportFile(file, {
|
|
22854
|
+
dataName: input.name,
|
|
22855
|
+
format: input.format,
|
|
22856
|
+
});
|
|
22857
|
+
return {
|
|
22858
|
+
downloadUrl,
|
|
22859
|
+
file,
|
|
22860
|
+
};
|
|
22861
|
+
}
|
|
22862
|
+
async extractData(data, input) {
|
|
22863
|
+
const content = new DataExportSerializer().serialize(data, {
|
|
22864
|
+
columns: input.columns,
|
|
22865
|
+
format: input.format,
|
|
22866
|
+
name: input.name,
|
|
22867
|
+
});
|
|
22868
|
+
return {
|
|
22869
|
+
content: content.content,
|
|
22870
|
+
contentType: content.contentType,
|
|
22871
|
+
};
|
|
22872
|
+
}
|
|
22873
|
+
async uploadExportFile(file, { dataName, format, }) {
|
|
22874
|
+
const filePath = this.buildExportFilePath(dataName, format);
|
|
22875
|
+
await this.defaultBucketProvider.fileUpload({
|
|
22876
|
+
bucket: this.defaultFileProvider.defaultBucket,
|
|
22877
|
+
filePath,
|
|
22878
|
+
content: file.content,
|
|
22879
|
+
contentType: file.contentType,
|
|
22880
|
+
});
|
|
22881
|
+
return await this.defaultFileProvider.getFileProviderDownloadUrl({
|
|
22882
|
+
reference: filePath,
|
|
22883
|
+
});
|
|
22884
|
+
}
|
|
22885
|
+
buildExportFilePath(dataName, format) {
|
|
22886
|
+
return `/data-export/${dataName}/${createDayPath$2(new Date())}/${newUuid$1()}_${dataName}.${format}`;
|
|
22887
|
+
}
|
|
22888
|
+
get defaultFileProvider() {
|
|
22889
|
+
return this.registry
|
|
22890
|
+
.getContainer()
|
|
22891
|
+
.getEntitiesServicesLocator()
|
|
22892
|
+
.resolveDefaultFilesProvider();
|
|
22893
|
+
}
|
|
22894
|
+
get defaultBucketProvider() {
|
|
22895
|
+
return this.registry
|
|
22896
|
+
.getContainer()
|
|
22897
|
+
.getEntitiesServicesLocator()
|
|
22898
|
+
.resolveDefaultBucketProvider();
|
|
22899
|
+
}
|
|
22900
|
+
};
|
|
22901
|
+
DataExportService = __decorate([
|
|
22902
|
+
Injectable(),
|
|
22903
|
+
__metadata("design:paramtypes", [EntityManagerRegistry])
|
|
22904
|
+
], DataExportService);
|
|
22905
|
+
|
|
22768
22906
|
let CacheService = class CacheService {
|
|
22769
22907
|
constructor(registry) {
|
|
22770
22908
|
this.registry = registry;
|
|
@@ -23735,14 +23873,15 @@ const Services$1 = [
|
|
|
23735
23873
|
AppSessionService,
|
|
23736
23874
|
AppHashingService,
|
|
23737
23875
|
CacheService,
|
|
23876
|
+
DataExportService,
|
|
23738
23877
|
EntityManagerService,
|
|
23739
23878
|
EmailService,
|
|
23740
23879
|
EventsService,
|
|
23741
23880
|
FilesManager,
|
|
23742
23881
|
MediaLibraryService,
|
|
23882
|
+
OperationLockService,
|
|
23743
23883
|
SecretsService,
|
|
23744
23884
|
TrackingService,
|
|
23745
|
-
OperationLockService,
|
|
23746
23885
|
];
|
|
23747
23886
|
|
|
23748
23887
|
const IoC = [EntityManagerRegistry];
|
|
@@ -35618,7 +35757,7 @@ let AwsS3FileProvider = class AwsS3FileProvider {
|
|
|
35618
35757
|
async uploadFile(file) {
|
|
35619
35758
|
const path = this.getBucketFileUploadPath(file.fileName, new Date());
|
|
35620
35759
|
await this.bucket.fileUpload({
|
|
35621
|
-
bucket:
|
|
35760
|
+
bucket: this.defaultBucket,
|
|
35622
35761
|
filePath: path,
|
|
35623
35762
|
content: file.content,
|
|
35624
35763
|
contentType: file.contentType,
|
|
@@ -35629,13 +35768,13 @@ let AwsS3FileProvider = class AwsS3FileProvider {
|
|
|
35629
35768
|
}
|
|
35630
35769
|
async deleteFile(reference) {
|
|
35631
35770
|
await this.bucket.fileDelete({
|
|
35632
|
-
bucket:
|
|
35771
|
+
bucket: this.defaultBucket,
|
|
35633
35772
|
filePath: reference.reference,
|
|
35634
35773
|
});
|
|
35635
35774
|
}
|
|
35636
35775
|
async downloadFile(reference) {
|
|
35637
35776
|
const content = await this.bucket.fileDownload({
|
|
35638
|
-
bucket:
|
|
35777
|
+
bucket: this.defaultBucket,
|
|
35639
35778
|
filePath: reference.reference,
|
|
35640
35779
|
});
|
|
35641
35780
|
return {
|
|
@@ -35644,7 +35783,7 @@ let AwsS3FileProvider = class AwsS3FileProvider {
|
|
|
35644
35783
|
}
|
|
35645
35784
|
async getFileProviderDownloadUrl(reference) {
|
|
35646
35785
|
const url = await this.bucket.filePublicUrlCreate({
|
|
35647
|
-
bucket:
|
|
35786
|
+
bucket: this.defaultBucket,
|
|
35648
35787
|
expirationMinutes: awsBucketSettings.value.publicLinksExpirationMinutes,
|
|
35649
35788
|
filePath: reference.reference,
|
|
35650
35789
|
});
|
|
@@ -35655,6 +35794,9 @@ let AwsS3FileProvider = class AwsS3FileProvider {
|
|
|
35655
35794
|
getBucketFileUploadPath(fileName, date) {
|
|
35656
35795
|
return `${ensureTailingSlash(awsBucketSettings.value.paths.filesUpload)}${createDayPath(date)}${ensureStartSlash(newUuid$1())}_${fileName}`;
|
|
35657
35796
|
}
|
|
35797
|
+
get defaultBucket() {
|
|
35798
|
+
return awsBucketSettings.value.defaultBucket;
|
|
35799
|
+
}
|
|
35658
35800
|
};
|
|
35659
35801
|
AwsS3FileProvider = __decorate([
|
|
35660
35802
|
WpFileProvider("awsS3"),
|
|
@@ -35730,6 +35872,9 @@ let InMemoryFileProvider = class InMemoryFileProvider {
|
|
|
35730
35872
|
}),
|
|
35731
35873
|
};
|
|
35732
35874
|
}
|
|
35875
|
+
get defaultBucket() {
|
|
35876
|
+
return "in-memory-bucket";
|
|
35877
|
+
}
|
|
35733
35878
|
};
|
|
35734
35879
|
InMemoryFileProvider = __decorate([
|
|
35735
35880
|
WpFileProvider("inMemory"),
|
|
@@ -44923,5 +45068,5 @@ class TestingAppSessionService {
|
|
|
44923
45068
|
}
|
|
44924
45069
|
}
|
|
44925
45070
|
|
|
44926
|
-
export { AUTHENTICATION_EVENTS_NAMESPACE, ApiKeyAccess, AppExceptionsFilterBase, AppHashingService, AppInMemorySettings, AppSession, AppSessionMiddleware, AppSessionService, AuthGuard, Authenticated, AuthenticationEmailTemplates, AuthenticationError, AuthenticationEvents, AuthenticationExtensionSymbols, AuthenticationModule, AuthenticationService, AwsBucketModule, AwsDynamoDbModule, AwsEmailModule, AwsJobsModule, AwsS3BucketError, AwsS3BucketProvider, AwsS3MediaError, AwsS3MediaModule, AwsS3MediaProvider, AwsSecretsModule, AwsSecretsProvider, AwsSesEmailTemplate, BucketItemType, CacheService, ConnectorMode, CurrentUser, CustomDiscoveryModule, CustomDiscoveryService, DynamoDbCacheInstance, DynamoDbCollection, EmailService, EntityManagerConfigurationError, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerRegistry, EntityManagerService, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntityParseResult, EntityParseValidationError, EntitySeeder, EntitySerializationFormat, EntitySerializer, EntitySnapshotService, EntityVersionOperation, EventsService, ExclusiveOperationResult, FilesManager, IEntityVersionsCursor, InMemoryBucketProvider, InMemoryEmailProvider, InMemoryFileProvider, InMemoryMediaProvider, InMemorySecretsProvider, InvalidCredentialsError, JobConcurrency, JobInstance, JobProviderState, JobRunType, JobSchedule, JobStatus, JobsModule, JobsService, LockNotFoundError, MediaLibraryService, MemberOf, MissingEntityIdError, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestEntitySerializer, NestEntitySnapshotService, NestPipelineTemplate, NestTypeOrmEntitySeeder, NestTypeOrmQueryBuilder, NestTypeOrmRepository, OperationLockService, OperationTokenMismatchError, PLATFORM_EVENT_NAMESPACE, Permissions, PipelineController, PipelineErrorType, PipelineInvocationError, PipelineStatus, PipelineStepErrorType, PipelinesBuilder, PipelinesRunner, PlatformEvents, Public, QueryBuilderBase, QueryBuilderOperation, ReplicationMode, Roles, SanityMediaError, SanityMediaModule, SanityMediaProvider, SecretsService, SendgridEmailModule, SendgridEmailTemplate, SortDirection, TaskConcurrency, TaskRunType, TasksModule, TasksService, TestingAppSessionService, TrackingService, TypeOrmQueryBuilder, TypeOrmRepository, TypeormCacheInstance, TypeormOperationLockRepository, UserCreationError, UserRegistrationError, WpApiKeysService, WpAppInitializer, WpAwsSesEmailTemplate, WpBucketProvider, WpCacheInstance, WpEmailLogger, WpEmailProvider, WpEmailTemplate, WpEmailTemplateMiddleware, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConnectorMapper, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, WpEntitySeeder, WpEntitySerializer, WpEntitySnapshotService, WpEntityVersioningProvider, WpEventsTracker, WpFileProvider, WpFileReferenceRepository, WpGlobalAuthenticationMiddleware, WpMediaFolderRepository, WpMediaProvider, WpMediaReferenceRepository, WpPermissionsService, WpPipeline, WpRolesService, WpSendgridEmailTemplate, WpTask, WpUserRolesService, WpUserService, awsBatchSettings, buildPermissionsGuard, buildProviderToken, buildRolesGuard, createContainer, createExpressFileResponse, fieldOptionValidator, fieldOptionsValidator, fieldRequiredValidator, fieldTextValidator, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, sessionStorage, toEntitiesImportInput };
|
|
45071
|
+
export { AUTHENTICATION_EVENTS_NAMESPACE, ApiKeyAccess, AppExceptionsFilterBase, AppHashingService, AppInMemorySettings, AppSession, AppSessionMiddleware, AppSessionService, AuthGuard, Authenticated, AuthenticationEmailTemplates, AuthenticationError, AuthenticationEvents, AuthenticationExtensionSymbols, AuthenticationModule, AuthenticationService, AwsBucketModule, AwsDynamoDbModule, AwsEmailModule, AwsJobsModule, AwsS3BucketError, AwsS3BucketProvider, AwsS3MediaError, AwsS3MediaModule, AwsS3MediaProvider, AwsSecretsModule, AwsSecretsProvider, AwsSesEmailTemplate, BucketItemType, CacheService, ConnectorMode, CurrentUser, CustomDiscoveryModule, CustomDiscoveryService, DataExportService, DataSerializationFormat, DynamoDbCacheInstance, DynamoDbCollection, EmailService, EntityManagerConfigurationError, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerRegistry, EntityManagerService, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntityParseResult, EntityParseValidationError, EntitySeeder, EntitySerializationFormat, EntitySerializer, EntitySnapshotService, EntityVersionOperation, EventsService, ExclusiveOperationResult, FilesManager, IEntityVersionsCursor, InMemoryBucketProvider, InMemoryEmailProvider, InMemoryFileProvider, InMemoryMediaProvider, InMemorySecretsProvider, InvalidCredentialsError, JobConcurrency, JobInstance, JobProviderState, JobRunType, JobSchedule, JobStatus, JobsModule, JobsService, LockNotFoundError, MediaLibraryService, MemberOf, MissingEntityIdError, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestEntitySerializer, NestEntitySnapshotService, NestPipelineTemplate, NestTypeOrmEntitySeeder, NestTypeOrmQueryBuilder, NestTypeOrmRepository, OperationLockService, OperationTokenMismatchError, PLATFORM_EVENT_NAMESPACE, Permissions, PipelineController, PipelineErrorType, PipelineInvocationError, PipelineStatus, PipelineStepErrorType, PipelinesBuilder, PipelinesRunner, PlatformEvents, Public, QueryBuilderBase, QueryBuilderOperation, ReplicationMode, Roles, SanityMediaError, SanityMediaModule, SanityMediaProvider, SecretsService, SendgridEmailModule, SendgridEmailTemplate, SortDirection, TaskConcurrency, TaskRunType, TasksModule, TasksService, TestingAppSessionService, TrackingService, TypeOrmQueryBuilder, TypeOrmRepository, TypeormCacheInstance, TypeormOperationLockRepository, UserCreationError, UserRegistrationError, WpApiKeysService, WpAppInitializer, WpAwsSesEmailTemplate, WpBucketProvider, WpCacheInstance, WpEmailLogger, WpEmailProvider, WpEmailTemplate, WpEmailTemplateMiddleware, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConnectorMapper, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, WpEntitySeeder, WpEntitySerializer, WpEntitySnapshotService, WpEntityVersioningProvider, WpEventsTracker, WpFileProvider, WpFileReferenceRepository, WpGlobalAuthenticationMiddleware, WpMediaFolderRepository, WpMediaProvider, WpMediaReferenceRepository, WpPermissionsService, WpPipeline, WpRolesService, WpSendgridEmailTemplate, WpTask, WpUserRolesService, WpUserService, awsBatchSettings, buildPermissionsGuard, buildProviderToken, buildRolesGuard, createContainer, createExpressFileResponse, fieldOptionValidator, fieldOptionsValidator, fieldRequiredValidator, fieldTextValidator, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, sessionStorage, toEntitiesImportInput };
|
|
44927
45072
|
//# sourceMappingURL=index.js.map
|