@punks/backend-entity-manager 0.0.469 → 0.0.471

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.
@@ -31,7 +31,7 @@ export declare class EntityNotFoundException<TEntityId> extends EntityManagerExc
31
31
  getEntityType(): string | undefined;
32
32
  }
33
33
  export declare class MultipleEntitiesFoundException extends EntityManagerException {
34
- constructor();
34
+ constructor(params: object, items: any[]);
35
35
  }
36
36
  export declare class EntityManagerConfigurationError extends EntityManagerException {
37
37
  constructor(message: string);
@@ -8,3 +8,4 @@ export interface IPipelinesController {
8
8
  export interface IPipelineOperationExecutor<TPipelineInput, TPipelineOutput, TContext> {
9
9
  execute(input: TPipelineInput, context: TContext): Promise<PipelineOperationResult<TPipelineInput, TPipelineOutput>>;
10
10
  }
11
+ export type PipelineConcurrency = "exclusive" | "sequential";
@@ -1,4 +1,13 @@
1
+ import { PipelineConcurrency } from "../../../abstractions/pipelines";
2
+ export type PipelineTemplateOptions = {
3
+ logging?: {
4
+ enabled?: boolean;
5
+ ignoreMeta?: boolean;
6
+ };
7
+ };
1
8
  export type PipelineTemplateProps = {
2
9
  name: string;
10
+ concurrency?: PipelineConcurrency;
11
+ options?: PipelineTemplateOptions;
3
12
  };
4
13
  export declare const WpPipeline: (name: string, props?: Omit<PipelineTemplateProps, "name">) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
@@ -2,9 +2,12 @@ import { PipelineDefinition, PipelineResult } from "../../../../types";
2
2
  import { IPipelineTemplateBuilder } from "../builder/types";
3
3
  import { PipelineUtils } from "./utils";
4
4
  import { PipelineTemplateProps } from "../../decorators";
5
- export type PipelineConcurrency = "exclusive" | "sequential";
5
+ import { PipelineConcurrency } from "../../../../abstractions/pipelines";
6
6
  export type PipelineTemplateOptions = {
7
7
  concurrency?: PipelineConcurrency;
8
+ logging?: {
9
+ ignoreMeta?: boolean;
10
+ };
8
11
  };
9
12
  export declare abstract class NestPipelineTemplate<TPipelineInput, TPipelineOutput, TContext> {
10
13
  private readonly options?;
@@ -21,9 +24,11 @@ export declare abstract class NestPipelineTemplate<TPipelineInput, TPipelineOutp
21
24
  context: TContext;
22
25
  }): Promise<PipelineResult<TPipelineInput, TPipelineOutput>>;
23
26
  private pipelineExecute;
27
+ private processLogMetadata;
24
28
  private getDefinition;
25
29
  private buildDefinition;
26
30
  private getContext;
31
+ private get concurrency();
27
32
  private get operationsLockService();
28
33
  private get controller();
29
34
  private get registry();
package/dist/esm/index.js CHANGED
@@ -109,8 +109,10 @@ class EntityNotFoundException extends EntityManagerException {
109
109
  }
110
110
  }
111
111
  class MultipleEntitiesFoundException extends EntityManagerException {
112
- constructor() {
113
- super("Multiple entities found");
112
+ constructor(params, items) {
113
+ super(`Multiple entities found: ${items
114
+ .map((item) => item.id)
115
+ .join(", ")} - params: ${JSON.stringify(params)}`);
114
116
  }
115
117
  }
116
118
  class EntityManagerConfigurationError extends EntityManagerException {
@@ -1248,7 +1250,7 @@ class EntitiesUpsertByCommand {
1248
1250
  };
1249
1251
  }
1250
1252
  if (items.length > 1) {
1251
- throw new Error("Multiple items found");
1253
+ throw new MultipleEntitiesFoundException(params, items);
1252
1254
  }
1253
1255
  // todo: parametrize id field
1254
1256
  const id = items[0].id;
@@ -35579,7 +35581,7 @@ class NestPipelineTemplate {
35579
35581
  return result.output;
35580
35582
  }
35581
35583
  async execute(data) {
35582
- if (this.options?.concurrency === "sequential") {
35584
+ if (this.concurrency === "sequential") {
35583
35585
  return await this.operationsLockService.executeSequential({
35584
35586
  lockUid: this.getConcurrencyKey(data.input),
35585
35587
  operation: async () => {
@@ -35587,7 +35589,7 @@ class NestPipelineTemplate {
35587
35589
  },
35588
35590
  });
35589
35591
  }
35590
- if (this.options?.concurrency === "exclusive") {
35592
+ if (this.concurrency === "exclusive") {
35591
35593
  const result = await this.operationsLockService.executeExclusive({
35592
35594
  lockUid: this.getConcurrencyKey(data.input),
35593
35595
  operation: async () => {
@@ -35605,9 +35607,9 @@ class NestPipelineTemplate {
35605
35607
  context: data.context,
35606
35608
  instanceId,
35607
35609
  };
35608
- this.logger.debug(`[START] | ${this.metadata.name}`, logMetadata);
35610
+ this.logger.debug(`[START] | ${this.metadata.name}`, this.processLogMetadata(logMetadata));
35609
35611
  if (!this.isAuthorized(data.context)) {
35610
- this.logger.debug(`[ERROR] | ${this.metadata.name} -> Unauthorized`, logMetadata);
35612
+ this.logger.debug(`[ERROR] | ${this.metadata.name} -> Unauthorized`, this.processLogMetadata(logMetadata));
35611
35613
  return {
35612
35614
  type: "error",
35613
35615
  errorType: PipelineErrorType.Unauthorized,
@@ -35620,19 +35622,25 @@ class NestPipelineTemplate {
35620
35622
  if (result.type === "error") {
35621
35623
  this.logger.error(`[ERROR] | ${this.metadata.name} -> ${result.exception
35622
35624
  ? `exception: ${result.exception.name}\n${result.exception.stack}`
35623
- : ""}`, {
35625
+ : ""}`, this.processLogMetadata({
35624
35626
  ...logMetadata,
35625
35627
  result,
35626
- });
35628
+ }));
35627
35629
  }
35628
35630
  else {
35629
- this.logger.debug(`[COMPLETED] | ${this.metadata.name}`, {
35631
+ this.logger.debug(`[COMPLETED] | ${this.metadata.name}`, this.processLogMetadata({
35630
35632
  ...logMetadata,
35631
35633
  result,
35632
- });
35634
+ }));
35633
35635
  }
35634
35636
  return result;
35635
35637
  }
35638
+ processLogMetadata(meta) {
35639
+ if (this.metadata.options?.logging?.ignoreMeta) {
35640
+ return undefined;
35641
+ }
35642
+ return meta;
35643
+ }
35636
35644
  getDefinition() {
35637
35645
  if (!this.cachedDefinition) {
35638
35646
  this.cachedDefinition = this.buildDefinition();
@@ -35649,6 +35657,9 @@ class NestPipelineTemplate {
35649
35657
  .resolveAuthenticationContextProvider();
35650
35658
  return (await contextService?.getContext());
35651
35659
  }
35660
+ get concurrency() {
35661
+ return this.options?.concurrency ?? this.metadata.concurrency;
35662
+ }
35652
35663
  get operationsLockService() {
35653
35664
  return this.registry
35654
35665
  .getContainer()
@@ -41303,9 +41314,6 @@ let SendgridEmailProvider = class SendgridEmailProvider {
41303
41314
  : {}),
41304
41315
  ...(options?.forceDelivery || sendgridSettings.value.forceDelivery
41305
41316
  ? {
41306
- bypassListManagement: {
41307
- enable: true,
41308
- },
41309
41317
  bypassBounceManagement: {
41310
41318
  enable: true,
41311
41319
  },
@@ -41377,9 +41385,6 @@ let SendgridEmailProvider = class SendgridEmailProvider {
41377
41385
  : {}),
41378
41386
  ...(options?.forceDelivery || sendgridSettings.value.forceDelivery
41379
41387
  ? {
41380
- // bypassListManagement: {
41381
- // enable: true,
41382
- // },
41383
41388
  bypassBounceManagement: {
41384
41389
  enable: true,
41385
41390
  },