///
///
///
///
import * as _punks_backend_core from '@punks/backend-core';
import { ExcelParseOptions } from '@punks/backend-core';
import * as _nestjs_common from '@nestjs/common';
import { Type as Type$1, INestApplicationContext, CanActivate, ExecutionContext, NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, OnModuleDestroy, StreamableFile, ExceptionFilter, ArgumentsHost, NestMiddleware } from '@nestjs/common';
import { Repository, EntityTarget, ObjectLiteral, FindOneOptions, FindManyOptions, FindOptionsRelations, ObjectId, FindOptionsWhere, FindOperator, FindOptionsOrder } from 'typeorm';
import { Module } from '@nestjs/core/injector/module';
import { ModulesContainer } from '@nestjs/core/injector/modules-container';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { Reflector, ModulesContainer as ModulesContainer$1 } from '@nestjs/core';
import { JwtService } from '@nestjs/jwt';
import { SchedulerRegistry } from '@nestjs/schedule';
import { CommandBus } from '@nestjs/cqrs';
import * as express from 'express';
import { Response, Request, NextFunction } from 'express';
import { AttributeValue } from '@aws-sdk/client-dynamodb';
import { EventEmitter2 } from '@nestjs/event-emitter';
import * as qs from 'qs';
import * as express_serve_static_core from 'express-serve-static-core';
import { AsyncLocalStorage } from 'async_hooks';
type EntityReference = {
id: TEntityId;
};
type EnumType = string | number | symbol;
type SortingType = EnumType;
interface ClassType {
new (...args: any[]): any;
constructor: {
name: string;
};
}
interface Type extends Function {
new (...args: any[]): T;
}
interface IEntitySearchParameters {
query?: IFullTextQuery;
filters?: ISearchFilters;
traverse?: ITraverseFilters;
sorting?: ISearchSorting;
paging?: ISearchRequestPaging;
options?: ISearchOptions;
relations?: ISearchQueryRelations;
}
interface ISearchFilters {
}
interface ITraverseFilters {
rootOnly?: boolean;
parentIds?: string[];
}
interface ISearchOptions {
includeFacets?: boolean;
includeChildrenMap?: boolean;
facetsFilters?: ISearchFilters;
}
interface ISearchRequestPaging {
cursor?: TCursor;
pageSize: number;
}
interface ISearchSortingField {
field: TSorting;
direction: SortDirection$1;
}
interface ISearchSorting {
fields: ISearchSortingField[];
}
declare enum SortDirection$1 {
Asc = "asc",
Desc = "desc"
}
interface IFullTextQuery {
term: string;
fields: string[];
}
type ISearchQueryRelationsProperty = TProperty extends Promise ? ISearchQueryRelationsProperty> | boolean : TProperty extends Array ? ISearchQueryRelationsProperty> | boolean : TProperty extends string ? never : TProperty extends number ? never : TProperty extends boolean ? never : TProperty extends Function ? never : TProperty extends Buffer ? never : TProperty extends Date ? never : TProperty extends object ? ISearchQueryRelations | boolean : boolean;
type ISearchQueryRelations = {
[P in keyof TEntity]?: P extends "toString" ? unknown : ISearchQueryRelationsProperty>;
};
interface IChildrenMap extends Record {
}
interface IEntitiesSearchResultsPaging {
pageIndex: number;
pageSize: number;
totPageItems: number;
totPages: number;
totItems: number;
nextPageCursor?: TCursor;
currentPageCursor?: TCursor;
prevPageCursor?: TCursor;
}
interface IEntitiesSearchResults, TResult, TSorting extends SortingType, TCursor, TFacets> {
request: TSearchParameters;
items: TResult[];
facets?: TFacets;
paging?: IEntitiesSearchResultsPaging;
childrenMap?: IChildrenMap;
}
interface IEntityVersionsReference {
entityId: string;
}
interface IEntityVersionsFilters {
timestampFrom?: Date;
timestampTo?: Date;
}
interface IEntityVersionsSorting {
direction: SortDirection$1;
}
declare class IEntityVersionsCursor {
cursor?: TCursor;
pageSize: number;
}
interface IEntityVersionsSearchParameters {
entity: IEntityVersionsReference;
filters?: IEntityVersionsFilters;
sorting?: IEntityVersionsSorting;
paging?: IEntityVersionsCursor;
}
interface IEntityVersionsResultsPaging {
pageIndex: number;
pageSize: number;
totPageItems: number;
totPages: number;
totItems: number;
nextPageCursor?: TCursor;
currentPageCursor?: TCursor;
prevPageCursor?: TCursor;
}
interface IEntityVersionsSearchResults {
paging?: IEntityVersionsResultsPaging;
items: TResult[];
}
interface IEntityVersionsSearchRequest {
params: IEntityVersionsSearchParameters;
}
interface IEntityVersionsSearchResponse {
request: IEntityVersionsSearchRequest;
paging?: IEntityVersionsResultsPaging;
items: TResult[];
}
type EntryValidationError = {
errorCode: string;
value?: any;
payload?: any;
};
type EntryValidationResult = {
isValid: boolean;
validationErrors: EntryValidationError[];
};
type ImportEntryValidationError = {
errorCode: string;
column: {
name: string;
key: string;
value?: any;
};
};
type ImportEntryValidationResult = {
isValid: boolean;
validationErrors: ImportEntryValidationError[];
};
type EntitySerializerColumnParser = (value: any) => any;
type EntitySerializerColumnParseAction = (value: any, item: TSheetItem) => void;
type EntitySerializerColumnConverter = (value: any, item: TSheetItem) => any;
type EntitySerializerColumnValidator = {
key: string;
fn: (item: TSheetItem) => EntryValidationResult;
};
type EntitySerializerSheetCustomParser = "date";
type EntitySerializerColumnModifier = "trim" | "lowercase" | "uppercase";
type EntitySerializerColumnDefinition = {
name: string;
aliases?: string[];
key: string;
selector: keyof TSheetItem | ((item: TSheetItem) => any);
colSpan?: number;
sampleValue?: any;
parser?: EntitySerializerColumnParser;
parseAction?: EntitySerializerColumnParseAction;
converter?: EntitySerializerColumnConverter;
validators?: EntitySerializerColumnValidator[];
idColumn?: boolean;
sheetParser?: EntitySerializerSheetCustomParser;
array?: boolean;
arraySeparator?: string | RegExp;
modifiers?: EntitySerializerColumnModifier[];
};
type EntitySerializerSheetOptions = {
name?: string;
useTypeColumn?: boolean;
};
type EntitySerializerSheetDefinition = {
autoColumns?: boolean;
columns: EntitySerializerColumnDefinition[];
sheet?: EntitySerializerSheetOptions;
options?: ExcelParseOptions;
};
type EntityExportFile = {
content: Buffer;
contentType: string;
fileName: string;
};
declare enum EntitySerializationFormat {
Csv = "csv",
Json = "json",
Xlsx = "xlsx"
}
type ImportEntry = {
id?: TEntityId;
item: TSheetItem;
rowIndex: number;
status: ImportEntryValidationResult;
};
interface IEntitySerializer {
export(filters?: TEntitySearchParameters, payload?: TPayload): Promise;
import(items: TSheetItem[], payload?: TPayload): Promise;
serialize(items: TSheetItem[], format: EntitySerializationFormat, payload?: TPayload): Promise;
parse(data: Buffer, format: EntitySerializationFormat, payload?: TPayload): Promise[]>;
createSample(format: EntitySerializationFormat): Promise;
}
type EntitiesExportOptions = {
format: EntitySerializationFormat;
};
type EntitiesExportFile = {
name: string;
content: Buffer;
contentType: string;
};
type EntitiesExportResult = {
file: EntitiesExportFile;
downloadUrl: string;
};
type EntitiesExportInput, TSorting extends SortingType, TCursor, TPayload = unknown> = {
filter?: TEntitySearchParameters;
options: EntitiesExportOptions;
payload?: TPayload;
};
type EntityExportBucketSettings = {
bucket: string;
publicLinksExpirationMinutes: number;
rootFolderPath?: string;
};
type EntitiesImportExportSettings = {
exportBucket: EntityExportBucketSettings;
};
type EntitiesSampleDownloadOptions = {
format: EntitySerializationFormat;
};
type EntitiesSampleDownloadResult = {
file: EntitiesExportFile;
downloadUrl: string;
};
type EntitiesImportInputFile = {
fileName: string;
content: Buffer;
contentType: string;
};
declare enum InvalidEntityHandling {
Skip = "skip",
Fail = "fail"
}
type EntitiesImportInput = {
format: EntitySerializationFormat;
file: EntitiesImportInputFile;
payload?: TPayload;
options?: {
invalidEntitiesHandling: InvalidEntityHandling;
};
};
type EntitiesImportStatistics = {
importedCount: number;
skippedCount: number;
updatedCount: number;
createdCount: number;
unchangedCount: number;
};
type EntitiesImportResult = {
statistics: EntitiesImportStatistics;
};
type EntitiesParseInputFile = {
fileName: string;
content: Buffer;
contentType: string;
};
type EntitiesParseError = {
fieldName: string;
errorType: string;
};
type EntitiesParseResultItem = {
isValid: boolean;
item: TItem;
errors: EntitiesParseError[];
};
type EntitiesParseResult = {
entries: ImportEntry[];
};
type EntitiesParseInput = {
format: EntitySerializationFormat;
file: EntitiesParseInputFile;
payload?: TPayload;
};
declare enum EntityVersionOperation {
Create = "create",
Update = "update",
Upsert = "upsert",
Delete = "delete"
}
type EntityVersionInput = {
operationType: EntityVersionOperation;
entityType: string;
entityId: TEntityId;
data?: TEntity;
modifiedByUserId?: string;
};
interface IEntityVersioningResults {
paging?: IEntityVersionsResultsPaging;
items: TResult[];
}
interface IEntityVersionsSearchInput {
entityType: string;
params: IEntityVersionsSearchParameters;
}
interface IEntityVersioningProvider {
isEnabled(): boolean;
createVersion(input: EntityVersionInput): Promise;
searchVersions(input: IEntityVersionsSearchInput): Promise>;
}
interface IEntityCreateCommand {
execute(input: TEntityCreateData): Promise>;
}
interface IEntityUpdateCommand {
execute(id: TEntityId, data: TEntityUpdateData): Promise>;
}
interface IEntityUpsertCommand {
execute(id: TEntityId, data: TEntityUpdateData): Promise>;
}
interface IEntityDeleteCommand {
execute(id: TEntityId): Promise;
}
type EntityVersionCommandInput = {
operation: EntityVersionOperation;
id: TEntityId;
entity?: TEntity;
};
interface IEntityVersionCommand {
execute(input: EntityVersionCommandInput): Promise;
}
interface IEntitiesDeleteParameters {
filters?: ISearchFilters;
sorting?: ISearchSorting;
}
interface IEntitiesDeleteResult$1 {
deletedCount: number;
}
interface IEntitiesDeleteCommand, TSorting> {
execute(params: TEntitiesDeleteParameters): Promise;
}
interface IEntitiesExportCommand, TSorting extends SortingType, TCursor> {
execute(input: EntitiesExportInput): Promise;
}
interface IEntitiesImportCommand {
execute(input: EntitiesImportInput): Promise;
}
interface IEntitiesParseCommand {
execute(input: EntitiesParseInput): Promise>;
}
interface IEntitiesSampleDownloadCommand {
execute(input: EntitiesSampleDownloadOptions): Promise;
}
interface IEntityUpsertByParameters {
filter: TEntityFilters;
data: Partial;
}
interface IEntityUpsertByResult {
id: string;
}
interface IEntityUpsertByCommand {
execute(params: IEntityUpsertByParameters): Promise;
}
declare class PermissionsChecker {
hasAny(context: IAuthenticationContext, permissions: string[]): boolean;
hasAll(context: IAuthenticationContext, permissions: string[]): boolean;
}
declare abstract class NestEntityAuthorizationMiddleware, TUserContext> implements IEntityAuthorizationMiddleware {
protected permissions: PermissionsChecker;
abstract canSearch(context: TAuthenticationContext): Promise;
abstract canRead(entity: Partial, context: TAuthenticationContext): Promise;
abstract canCreate(entity: Partial, context: TAuthenticationContext): Promise;
abstract canUpdate(entity: Partial, context: TAuthenticationContext): Promise;
abstract canDelete(entity: Partial, context: TAuthenticationContext): Promise;
abstract canDeleteItems(context: TAuthenticationContext): Promise;
}
type DeepPartial = {
[P in keyof T]?: T[P] extends object ? DeepPartial : T[P];
};
type NonNullable$1 = T;
type PipelineStepReference = {
index: number;
key?: string;
name: string;
};
type PipelineStepState = {
reference: PipelineStepReference;
context: TContext;
stepInput: TStepInput;
pipelineInput: TPipelineInput;
previousStep?: PipelineCompletedStepState;
};
type PipelineCompletedStepState = PipelineStepState & {
stepOutput?: TStepOutput;
};
type PipelineCurrentStepState = PipelineStepState & {};
type OperationDefinition = {
key?: string;
name: string;
action: (input: TOperationInput, state: PipelineCurrentStepState) => Promise | TOperationOutput;
precondition?: (input: TOperationInput, state: PipelineCurrentStepState) => Promise | boolean;
skipIf?: (input: TOperationInput, state: PipelineCurrentStepState) => Promise | boolean;
};
type RollbackOperationDefinition = {
name: string;
action: (input: TOperationInput, output: TOperationOutput, state: PipelineCurrentStepState) => Promise | void;
};
type PipelineStepOperation = {
key?: string;
name: string;
operation: OperationDefinition;
rollbackOperations?: RollbackOperationDefinition[];
};
type PipelineStep = {
name: string;
operations: PipelineStepOperation[];
outputsReducer?: (results: unknown[]) => TStepOutput;
};
type PipelineDefinition = {
steps: PipelineStep[];
};
type PipelineOperationError = {
message: string;
stackTrace?: string;
exception?: Error;
};
type PipelineOperationResult = {
key?: string;
name: string;
input: TOperationInput;
} & ({
type: "success";
output: TOperationOutput;
} | {
type: "skipped";
} | {
type: "preconditionFailed";
} | {
type: "error" | "rollbackCompleted";
error: PipelineOperationError;
} | {
type: "rollbackFailed";
rollbackError: PipelineOperationError;
error: PipelineOperationError;
});
type PipelineOperationResultType = PipelineOperationResult["type"];
type PipelineOperationRollbackResult = {
type: "success" | "skipped";
} | {
type: "error";
error: PipelineOperationError;
};
type PipelineOperationRollbackResultType = PipelineOperationRollbackResult["type"];
declare enum PipelineStepErrorType {
FailedPrecondition = "failedPrecondition",
OperationError = "operationError",
RollbackError = "rollbackError",
GenericError = "genericError"
}
type PipelineStepResult = {
input: TStepInput;
operationResults: PipelineOperationResult[];
} & ({
type: "success";
output: TStepOutput;
} | {
type: "error";
errorType: PipelineStepErrorType;
});
type PipelineStepResultType = PipelineStepResult["type"];
type PipelineStepRollbackResult = {} & ({
type: "success";
} | {
type: "error";
});
type PipelineStepRollbackResultType = PipelineStepRollbackResult["type"];
declare enum PipelineErrorType {
FailedPrecondition = "failedPrecondition",
OperationError = "operationError",
RollbackError = "rollbackError",
Unauthorized = "unauthorized",
GenericError = "genericError"
}
type PipelineResult = {
stepResults: PipelineStepResult[];
input: TPipelineInput;
} & ({
type: "success";
output: TPipelineOutput;
} | {
type: "error";
errorType: PipelineErrorType;
exception?: Error;
output?: TPipelineOutput;
});
type PipelineResultType = PipelineResult["type"];
declare enum PipelineStatus {
Initializing = "initializing",
Running = "running",
RollbackInProgress = "rollbackInProgress",
Completed = "completed",
Failed = "failed"
}
interface IEntityCreateCommandAdapter {
createDataToEntity(data: TEntityCreateData, context: IAuthenticationContext): DeepPartial;
}
interface IEntityUpdateCommandAdapter {
updateDataToEntity(data: TEntityUpdateData, context: IAuthenticationContext): DeepPartial;
}
interface IEntityAdapter extends IEntityCreateCommandAdapter, IEntityUpdateCommandAdapter {
}
interface IAuthorizationResult {
isAuthorized: boolean;
}
interface IEntityAuthorizationMiddleware, TUserContext> {
canSearch(context: TAuthenticationContext): Promise;
canRead(entity: DeepPartial, context: TAuthenticationContext): Promise;
canCreate(entity: DeepPartial, context: TAuthenticationContext): Promise;
canUpdate(entity: DeepPartial, context: TAuthenticationContext): Promise;
canDelete(entity: DeepPartial, context: TAuthenticationContext): Promise;
canDeleteItems(context: TAuthenticationContext): Promise;
}
type BucketFolderListInput = {
bucket: string;
maxResults?: number;
path?: string;
};
declare enum BucketItemType {
File = "file",
Folder = "folder"
}
type BucketContentItem = {
type: BucketItemType;
name: string;
path: string;
};
type BucketFolderContentResult = {
items: BucketContentItem[];
};
type BucketFolderListResult = {};
type BucketFolderCreateInput = {
bucket: string;
path: string;
};
type BucketFolderEnsureInput = {
bucket: string;
path: string;
};
type BucketFolderExistsInput = {
bucket: string;
path: string;
};
type BucketFileExistsInput = {
bucket: string;
filePath: string;
};
type BucketFileDownloadInput = {
bucket: string;
filePath: string;
};
type BucketFilePublicUrlCreateInput = {
bucket: string;
filePath: string;
expirationMinutes: number;
};
type BucketFileUploadInput = {
bucket: string;
filePath: string;
content: Buffer;
contentType?: string;
};
type BucketFileDeleteInput = {
bucket: string;
filePath: string;
};
type BucketFileCopyInput = {
bucket: string;
filePath: string;
targetBucket: string;
targetPath: string;
};
type BucketFileMoveInput = {
bucket: string;
filePath: string;
targetBucket: string;
targetPath: string;
};
interface IBucketProvider {
folderList(input: BucketFolderListInput): Promise;
folderEnsure(input: BucketFolderEnsureInput): Promise;
folderExists(input: BucketFolderExistsInput): Promise;
fileExists(input: BucketFileExistsInput): Promise;
fileDownload(input: BucketFileDownloadInput): Promise;
filePublicUrlCreate(input: BucketFilePublicUrlCreateInput): Promise;
fileUpload(input: BucketFileUploadInput): Promise;
fileDelete(input: BucketFileDeleteInput): Promise;
}
type CacheTtl = {
value: number;
unit: "years" | "months" | "days" | "hours" | "minutes" | "seconds";
};
type CacheEntryInfo = {
instanceName: string;
key: string;
expiration: Date;
createdOn: Date;
updatedOn: Date;
};
type CacheEntryDetail = CacheEntryInfo & {
data: any;
};
interface ICacheInstance {
getInstanceName(): string;
getEntries(): Promise;
getEntry(key: string): Promise;
get(key: string): Promise;
set(key: string, input: {
value: T;
ttl: CacheTtl;
}): Promise;
retrieve(key: string, input: {
ttl: CacheTtl;
valueFactory: () => Promise;
}): Promise;
delete(key: string): Promise;
clear(): Promise;
}
interface ICache {
getInstance(instanceName: string): Promise;
}
interface IEntityMapper {
mapEntity(entity: TEntity): Promise;
}
interface IEntityConnector {
syncEntity(entity: TMappedType): Promise;
deleteEntity(id: TEntityId): Promise;
}
interface IConnectorsConfiguration {
configureConnector, TMappedType, TMapper extends IEntityMapper>(name: string, options: ConnectorOptions, connector: TEntityConnector, mapper: TMapper): void;
getConnector(name: string): ConnectorConfiguration;
getConnectors(): ConnectorConfiguration[];
}
declare enum ConnectorMode {
Sync = 0,
Async = 1
}
type ConnectorOptions = {
mode: ConnectorMode;
enabled?: boolean;
};
type ConnectorConfiguration = {
name: string;
options: ConnectorOptions;
connector: IEntityConnector;
mapper: IEntityMapper;
};
interface IEntityConnectorSyncManager {
syncEntity(entity: TEntity): Promise;
}
interface IEntityConnectorDeleteManager {
deleteEntity(entityId: TEntityId): Promise;
}
interface IEntitiesSearchActionConverter {
toListItemDto(entity: TEntity): TListItemDto | Promise;
}
interface IEntityGetActionConverter {
toEntityDto(entity: TEntity): TEntityDto | Promise;
}
interface IEntityCreateActionConverter {
createDtoToEntity(data: TEntityCreateDto, context?: IAuthenticationContext): DeepPartial;
toEntityDto(entity: TEntity): TEntityDto | Promise;
}
interface IEntityUpdateActionConverter {
toEntityDto(entity: TEntity): TEntityDto | Promise;
updateDtoToEntity(data: TEntityUpdateDto, context?: IAuthenticationContext): DeepPartial;
}
interface IEntityConverter extends IEntitiesSearchActionConverter, IEntityGetActionConverter, IEntityCreateActionConverter, IEntityUpdateActionConverter {
}
interface IEmailTemplateMiddleware {
processPayload(payload: unknown): Promise;
processInput(input: TemplatedEmailInput): Promise>;
}
interface IEmailTemplate {
processPayload(payload: TPayload): Promise;
getTemplateData(payload: TAugmentedPayload): Promise;
}
interface IEmailTemplatesCollection {
registerTemplate(id: string, template: IEmailTemplate): void;
getTemplate(id: string): IEmailTemplate;
}
type EmailAttachmentData = {
content: string | Buffer;
filename: string;
type?: string;
disposition?: string;
contentId?: string;
};
type TemplatedEmailInput = {
from?: string;
to?: string[];
cc?: string[];
bcc?: string[];
subjectTemplate?: string;
templateId: string;
languageCode: string;
payload: TPayload;
attachments?: EmailAttachmentData[];
};
interface HtmlEmailInput {
replyTo?: string;
from?: string;
to?: string[];
cc?: string[];
bcc?: string[];
subjectTemplate: string;
bodyTemplate: string;
payload: TPayload;
attachments?: EmailAttachmentData[];
}
type EmailSendOptions = {
sandboxMode?: boolean;
forceDelivery?: boolean;
};
interface IEmailProvider {
sendTemplatedEmail(input: TemplatedEmailInput, template: IEmailTemplate, options?: EmailSendOptions): Promise;
sendHtmlEmail(input: HtmlEmailInput, options?: EmailSendOptions): Promise;
}
interface IEmailLogger {
logTemplatedEmail(input: TemplatedEmailInput): Promise;
logHtmlEmail(input: HtmlEmailInput): Promise;
}
interface IEntityEventsManager {
processEntityCreatedEvent(entity: TEntity): Promise;
processEntityUpdatedEvent(entity: TEntity): Promise;
processEntityDeletedEvent(id: TEntityId): Promise;
}
interface IEventEmitter {
emit(event: string, ...args: any[]): Promise;
}
type FileData = {
fileId?: string;
content: Buffer;
contentType: string;
fileName: string;
folderPath: string;
storageFilePath?: string;
storageBucket?: string;
metadata?: Record