@rainbow-o23/n3 1.0.45 → 1.0.46
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/index.cjs
CHANGED
|
@@ -660,11 +660,12 @@ class AbstractFragmentaryPipelineStep extends n1.AbstractPipelineStep {
|
|
|
660
660
|
return {};
|
|
661
661
|
}
|
|
662
662
|
else {
|
|
663
|
-
|
|
663
|
+
const { authorization, traceId, ...rest } = context;
|
|
664
|
+
return { authorization, traceId, ...Utils.clone(rest) };
|
|
664
665
|
}
|
|
665
666
|
}
|
|
666
667
|
async handleErrorSteps(fragment, errorCode, error, request, builders) {
|
|
667
|
-
const { $context: { traceId } = {} } = request;
|
|
668
|
+
const { $context: { authorization, traceId } = {} } = request;
|
|
668
669
|
const errorContext = this.createErrorHandleContext(request);
|
|
669
670
|
const options = this.buildStepOptions();
|
|
670
671
|
const steps = await Promise.all(builders.map(async (builder) => await builder.create(options)));
|
|
@@ -673,7 +674,9 @@ class AbstractFragmentaryPipelineStep extends n1.AbstractPipelineStep {
|
|
|
673
674
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
674
675
|
.execute(async () => {
|
|
675
676
|
this.traceStepIn(traceId, step, request);
|
|
676
|
-
const response = await step.perform({
|
|
677
|
+
const response = await step.perform({
|
|
678
|
+
...request, $context: { ...errorContext, authorization, traceId }
|
|
679
|
+
});
|
|
677
680
|
this.traceStepOut(traceId, step, response);
|
|
678
681
|
return this.returnOrContinueOrClear(request, response);
|
|
679
682
|
});
|
|
@@ -773,7 +776,8 @@ class PipelineStepSets extends AbstractFragmentaryPipelineStep {
|
|
|
773
776
|
return {};
|
|
774
777
|
}
|
|
775
778
|
else {
|
|
776
|
-
|
|
779
|
+
const { authorization, traceId, ...rest } = context;
|
|
780
|
+
return { authorization, traceId, ...Utils.clone(rest) };
|
|
777
781
|
}
|
|
778
782
|
}
|
|
779
783
|
async attachMineToInternalContext(inheritedContext, _request) {
|
|
@@ -788,14 +792,16 @@ class PipelineStepSets extends AbstractFragmentaryPipelineStep {
|
|
|
788
792
|
}
|
|
789
793
|
async doPerform(data, request) {
|
|
790
794
|
return await this.performWithContext(request, async (request, context) => {
|
|
791
|
-
const { $context: { traceId } = {} } = request;
|
|
795
|
+
const { $context: { authorization, traceId } = {} } = request;
|
|
792
796
|
const steps = await this.createSteps();
|
|
793
797
|
const response = await steps.reduce(async (promise, step) => {
|
|
794
798
|
const request = await promise;
|
|
795
799
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
796
800
|
.execute(async () => {
|
|
797
801
|
this.traceStepIn(traceId, step, request);
|
|
798
|
-
const response = await step.perform({
|
|
802
|
+
const response = await step.perform({
|
|
803
|
+
...request, $context: { ...context, authorization, traceId }
|
|
804
|
+
});
|
|
799
805
|
this.traceStepOut(traceId, step, response);
|
|
800
806
|
return this.returnOrContinueOrClear(request, response);
|
|
801
807
|
});
|
|
@@ -846,14 +852,14 @@ class ParallelPipelineStepSets extends PipelineStepSets {
|
|
|
846
852
|
}
|
|
847
853
|
async doPerform(data, request) {
|
|
848
854
|
return await this.performWithContext(request, async (request, context) => {
|
|
849
|
-
const { $context: { traceId } = {} } = request;
|
|
855
|
+
const { $context: { authorization, traceId } = {} } = request;
|
|
850
856
|
const steps = await this.createSteps();
|
|
851
857
|
const execute = () => {
|
|
852
858
|
return steps.map(async (step) => {
|
|
853
859
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
854
860
|
.execute(async () => {
|
|
855
861
|
const eachData = await this.cloneDataForEach(data, request);
|
|
856
|
-
const eachRequest = { content: eachData, $context: { ...context, traceId } };
|
|
862
|
+
const eachRequest = { content: eachData, $context: { ...context, authorization, traceId } };
|
|
857
863
|
this.traceStepIn(traceId, step, request);
|
|
858
864
|
const response = await step.perform(eachRequest);
|
|
859
865
|
this.traceStepOut(traceId, step, response);
|
|
@@ -1218,9 +1224,9 @@ class RefPipelinePipelineStep extends AbstractFragmentaryPipelineStep {
|
|
|
1218
1224
|
return { config: this.getConfig(), logger: this.getLogger() };
|
|
1219
1225
|
}
|
|
1220
1226
|
async doPerform(data, request) {
|
|
1221
|
-
const { $context: { traceId } = {} } = request;
|
|
1227
|
+
const { $context: { authorization, traceId } = {} } = request;
|
|
1222
1228
|
const pipeline = await this.getPipelineBuilder().create(this.buildPipelineOptions());
|
|
1223
|
-
const result = await pipeline.perform({ payload: data, traceId });
|
|
1229
|
+
const result = await pipeline.perform({ payload: data, authorization, traceId });
|
|
1224
1230
|
return result.payload;
|
|
1225
1231
|
}
|
|
1226
1232
|
}
|
package/index.js
CHANGED
|
@@ -658,11 +658,12 @@ class AbstractFragmentaryPipelineStep extends AbstractPipelineStep {
|
|
|
658
658
|
return {};
|
|
659
659
|
}
|
|
660
660
|
else {
|
|
661
|
-
|
|
661
|
+
const { authorization, traceId, ...rest } = context;
|
|
662
|
+
return { authorization, traceId, ...Utils.clone(rest) };
|
|
662
663
|
}
|
|
663
664
|
}
|
|
664
665
|
async handleErrorSteps(fragment, errorCode, error, request, builders) {
|
|
665
|
-
const { $context: { traceId } = {} } = request;
|
|
666
|
+
const { $context: { authorization, traceId } = {} } = request;
|
|
666
667
|
const errorContext = this.createErrorHandleContext(request);
|
|
667
668
|
const options = this.buildStepOptions();
|
|
668
669
|
const steps = await Promise.all(builders.map(async (builder) => await builder.create(options)));
|
|
@@ -671,7 +672,9 @@ class AbstractFragmentaryPipelineStep extends AbstractPipelineStep {
|
|
|
671
672
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
672
673
|
.execute(async () => {
|
|
673
674
|
this.traceStepIn(traceId, step, request);
|
|
674
|
-
const response = await step.perform({
|
|
675
|
+
const response = await step.perform({
|
|
676
|
+
...request, $context: { ...errorContext, authorization, traceId }
|
|
677
|
+
});
|
|
675
678
|
this.traceStepOut(traceId, step, response);
|
|
676
679
|
return this.returnOrContinueOrClear(request, response);
|
|
677
680
|
});
|
|
@@ -771,7 +774,8 @@ class PipelineStepSets extends AbstractFragmentaryPipelineStep {
|
|
|
771
774
|
return {};
|
|
772
775
|
}
|
|
773
776
|
else {
|
|
774
|
-
|
|
777
|
+
const { authorization, traceId, ...rest } = context;
|
|
778
|
+
return { authorization, traceId, ...Utils.clone(rest) };
|
|
775
779
|
}
|
|
776
780
|
}
|
|
777
781
|
async attachMineToInternalContext(inheritedContext, _request) {
|
|
@@ -786,14 +790,16 @@ class PipelineStepSets extends AbstractFragmentaryPipelineStep {
|
|
|
786
790
|
}
|
|
787
791
|
async doPerform(data, request) {
|
|
788
792
|
return await this.performWithContext(request, async (request, context) => {
|
|
789
|
-
const { $context: { traceId } = {} } = request;
|
|
793
|
+
const { $context: { authorization, traceId } = {} } = request;
|
|
790
794
|
const steps = await this.createSteps();
|
|
791
795
|
const response = await steps.reduce(async (promise, step) => {
|
|
792
796
|
const request = await promise;
|
|
793
797
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
794
798
|
.execute(async () => {
|
|
795
799
|
this.traceStepIn(traceId, step, request);
|
|
796
|
-
const response = await step.perform({
|
|
800
|
+
const response = await step.perform({
|
|
801
|
+
...request, $context: { ...context, authorization, traceId }
|
|
802
|
+
});
|
|
797
803
|
this.traceStepOut(traceId, step, response);
|
|
798
804
|
return this.returnOrContinueOrClear(request, response);
|
|
799
805
|
});
|
|
@@ -844,14 +850,14 @@ class ParallelPipelineStepSets extends PipelineStepSets {
|
|
|
844
850
|
}
|
|
845
851
|
async doPerform(data, request) {
|
|
846
852
|
return await this.performWithContext(request, async (request, context) => {
|
|
847
|
-
const { $context: { traceId } = {} } = request;
|
|
853
|
+
const { $context: { authorization, traceId } = {} } = request;
|
|
848
854
|
const steps = await this.createSteps();
|
|
849
855
|
const execute = () => {
|
|
850
856
|
return steps.map(async (step) => {
|
|
851
857
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
852
858
|
.execute(async () => {
|
|
853
859
|
const eachData = await this.cloneDataForEach(data, request);
|
|
854
|
-
const eachRequest = { content: eachData, $context: { ...context, traceId } };
|
|
860
|
+
const eachRequest = { content: eachData, $context: { ...context, authorization, traceId } };
|
|
855
861
|
this.traceStepIn(traceId, step, request);
|
|
856
862
|
const response = await step.perform(eachRequest);
|
|
857
863
|
this.traceStepOut(traceId, step, response);
|
|
@@ -1216,9 +1222,9 @@ class RefPipelinePipelineStep extends AbstractFragmentaryPipelineStep {
|
|
|
1216
1222
|
return { config: this.getConfig(), logger: this.getLogger() };
|
|
1217
1223
|
}
|
|
1218
1224
|
async doPerform(data, request) {
|
|
1219
|
-
const { $context: { traceId } = {} } = request;
|
|
1225
|
+
const { $context: { authorization, traceId } = {} } = request;
|
|
1220
1226
|
const pipeline = await this.getPipelineBuilder().create(this.buildPipelineOptions());
|
|
1221
|
-
const result = await pipeline.perform({ payload: data, traceId });
|
|
1227
|
+
const result = await pipeline.perform({ payload: data, authorization, traceId });
|
|
1222
1228
|
return result.payload;
|
|
1223
1229
|
}
|
|
1224
1230
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rainbow-o23/n3",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"description": "o23 pipelines",
|
|
5
5
|
"main": "index.cjs",
|
|
6
6
|
"module": "index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://github.com/InsureMO/rainbow-o23/issues"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@rainbow-o23/n1": "1.0.
|
|
24
|
+
"@rainbow-o23/n1": "1.0.46",
|
|
25
25
|
"node-fetch": "2.6.7",
|
|
26
26
|
"typeorm": "^0.3.17",
|
|
27
27
|
"typescript": "5.5.4"
|
|
@@ -284,7 +284,8 @@ export abstract class AbstractFragmentaryPipelineStep<In = PipelineStepPayload,
|
|
|
284
284
|
if (context == null) {
|
|
285
285
|
return {};
|
|
286
286
|
} else {
|
|
287
|
-
|
|
287
|
+
const {authorization, traceId, ...rest} = context;
|
|
288
|
+
return {authorization, traceId, ...Utils.clone(rest)};
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
291
|
|
|
@@ -293,7 +294,7 @@ export abstract class AbstractFragmentaryPipelineStep<In = PipelineStepPayload,
|
|
|
293
294
|
*/
|
|
294
295
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
295
296
|
protected async handleErrorSteps(fragment: InFragment, errorCode: string, error: any, request: PipelineStepData<In>, builders: Array<PipelineStepBuilder>): Promise<OutFragment> {
|
|
296
|
-
const {$context: {traceId} = {}} = request;
|
|
297
|
+
const {$context: {authorization, traceId} = {}} = request;
|
|
297
298
|
const errorContext = this.createErrorHandleContext(request);
|
|
298
299
|
const options = this.buildStepOptions();
|
|
299
300
|
const steps = await Promise.all(builders.map(async builder => await builder.create(options)));
|
|
@@ -302,7 +303,9 @@ export abstract class AbstractFragmentaryPipelineStep<In = PipelineStepPayload,
|
|
|
302
303
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
303
304
|
.execute(async () => {
|
|
304
305
|
this.traceStepIn(traceId, step, request);
|
|
305
|
-
const response = await step.perform({
|
|
306
|
+
const response = await step.perform({
|
|
307
|
+
...request, $context: {...errorContext, authorization, traceId}
|
|
308
|
+
});
|
|
306
309
|
this.traceStepOut(traceId, step, response);
|
|
307
310
|
// if no response returned, keep using request for next
|
|
308
311
|
return this.returnOrContinueOrClear(request, response);
|
|
@@ -62,14 +62,14 @@ export class ParallelPipelineStepSets<In = PipelineStepPayload, Out = PipelineSt
|
|
|
62
62
|
protected async doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment> {
|
|
63
63
|
return await this.performWithContext(
|
|
64
64
|
request, async (request: PipelineStepData<In>, context: PipelineStepSetsContext): Promise<OutFragment> => {
|
|
65
|
-
const {$context: {traceId} = {}} = request;
|
|
65
|
+
const {$context: {authorization, traceId} = {}} = request;
|
|
66
66
|
const steps = await this.createSteps();
|
|
67
67
|
const execute = () => {
|
|
68
68
|
return steps.map(async step => {
|
|
69
69
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
70
70
|
.execute(async () => {
|
|
71
71
|
const eachData = await this.cloneDataForEach(data, request);
|
|
72
|
-
const eachRequest = {content: eachData, $context: {...context, traceId}};
|
|
72
|
+
const eachRequest = {content: eachData, $context: {...context, authorization, traceId}};
|
|
73
73
|
this.traceStepIn(traceId, step, request);
|
|
74
74
|
const response = await step.perform(eachRequest);
|
|
75
75
|
this.traceStepOut(traceId, step, response);
|
|
@@ -56,10 +56,9 @@ export class RefPipelinePipelineStep<In = PipelineStepPayload, Out = PipelineSte
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
protected async doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment> {
|
|
59
|
-
const {$context: {traceId} = {}} = request;
|
|
59
|
+
const {$context: {authorization, traceId} = {}} = request;
|
|
60
60
|
const pipeline = await this.getPipelineBuilder().create(this.buildPipelineOptions());
|
|
61
|
-
const result = await pipeline.perform({payload: data, traceId});
|
|
62
|
-
// const result = await step.perform({content: data, $context: request.$context});
|
|
61
|
+
const result = await pipeline.perform({payload: data, authorization, traceId});
|
|
63
62
|
return result.payload;
|
|
64
63
|
}
|
|
65
64
|
}
|
|
@@ -50,7 +50,8 @@ export class PipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayloa
|
|
|
50
50
|
if (context == null) {
|
|
51
51
|
return {};
|
|
52
52
|
} else {
|
|
53
|
-
|
|
53
|
+
const {authorization, traceId, ...rest} = context;
|
|
54
|
+
return {authorization, traceId, ...Utils.clone(rest)};
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -79,14 +80,16 @@ export class PipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayloa
|
|
|
79
80
|
protected async doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment> {
|
|
80
81
|
return await this.performWithContext(
|
|
81
82
|
request, async (request: PipelineStepData<In>, context: PipelineStepSetsContext): Promise<OutFragment> => {
|
|
82
|
-
const {$context: {traceId} = {}} = request;
|
|
83
|
+
const {$context: {authorization, traceId} = {}} = request;
|
|
83
84
|
const steps = await this.createSteps();
|
|
84
85
|
const response = await steps.reduce(async (promise, step) => {
|
|
85
86
|
const request = await promise;
|
|
86
87
|
return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
|
|
87
88
|
.execute(async () => {
|
|
88
89
|
this.traceStepIn(traceId, step, request);
|
|
89
|
-
const response = await step.perform({
|
|
90
|
+
const response = await step.perform({
|
|
91
|
+
...request, $context: {...context, authorization, traceId}
|
|
92
|
+
});
|
|
90
93
|
this.traceStepOut(traceId, step, response);
|
|
91
94
|
// if no response returned, keep using request for next
|
|
92
95
|
return this.returnOrContinueOrClear(request, response);
|