@punks/backend-entity-manager 0.0.470 → 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.
@@ -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
@@ -35581,7 +35581,7 @@ class NestPipelineTemplate {
35581
35581
  return result.output;
35582
35582
  }
35583
35583
  async execute(data) {
35584
- if (this.options?.concurrency === "sequential") {
35584
+ if (this.concurrency === "sequential") {
35585
35585
  return await this.operationsLockService.executeSequential({
35586
35586
  lockUid: this.getConcurrencyKey(data.input),
35587
35587
  operation: async () => {
@@ -35589,7 +35589,7 @@ class NestPipelineTemplate {
35589
35589
  },
35590
35590
  });
35591
35591
  }
35592
- if (this.options?.concurrency === "exclusive") {
35592
+ if (this.concurrency === "exclusive") {
35593
35593
  const result = await this.operationsLockService.executeExclusive({
35594
35594
  lockUid: this.getConcurrencyKey(data.input),
35595
35595
  operation: async () => {
@@ -35607,9 +35607,9 @@ class NestPipelineTemplate {
35607
35607
  context: data.context,
35608
35608
  instanceId,
35609
35609
  };
35610
- this.logger.debug(`[START] | ${this.metadata.name}`, logMetadata);
35610
+ this.logger.debug(`[START] | ${this.metadata.name}`, this.processLogMetadata(logMetadata));
35611
35611
  if (!this.isAuthorized(data.context)) {
35612
- this.logger.debug(`[ERROR] | ${this.metadata.name} -> Unauthorized`, logMetadata);
35612
+ this.logger.debug(`[ERROR] | ${this.metadata.name} -> Unauthorized`, this.processLogMetadata(logMetadata));
35613
35613
  return {
35614
35614
  type: "error",
35615
35615
  errorType: PipelineErrorType.Unauthorized,
@@ -35622,19 +35622,25 @@ class NestPipelineTemplate {
35622
35622
  if (result.type === "error") {
35623
35623
  this.logger.error(`[ERROR] | ${this.metadata.name} -> ${result.exception
35624
35624
  ? `exception: ${result.exception.name}\n${result.exception.stack}`
35625
- : ""}`, {
35625
+ : ""}`, this.processLogMetadata({
35626
35626
  ...logMetadata,
35627
35627
  result,
35628
- });
35628
+ }));
35629
35629
  }
35630
35630
  else {
35631
- this.logger.debug(`[COMPLETED] | ${this.metadata.name}`, {
35631
+ this.logger.debug(`[COMPLETED] | ${this.metadata.name}`, this.processLogMetadata({
35632
35632
  ...logMetadata,
35633
35633
  result,
35634
- });
35634
+ }));
35635
35635
  }
35636
35636
  return result;
35637
35637
  }
35638
+ processLogMetadata(meta) {
35639
+ if (this.metadata.options?.logging?.ignoreMeta) {
35640
+ return undefined;
35641
+ }
35642
+ return meta;
35643
+ }
35638
35644
  getDefinition() {
35639
35645
  if (!this.cachedDefinition) {
35640
35646
  this.cachedDefinition = this.buildDefinition();
@@ -35651,6 +35657,9 @@ class NestPipelineTemplate {
35651
35657
  .resolveAuthenticationContextProvider();
35652
35658
  return (await contextService?.getContext());
35653
35659
  }
35660
+ get concurrency() {
35661
+ return this.options?.concurrency ?? this.metadata.concurrency;
35662
+ }
35654
35663
  get operationsLockService() {
35655
35664
  return this.registry
35656
35665
  .getContainer()