@rainbow-o23/n3 1.0.45 → 1.0.47

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
- return Utils.clone(context);
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({ ...request, $context: { ...errorContext, traceId } });
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
- return Utils.clone(context);
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({ ...request, $context: { ...context, traceId } });
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
- return Utils.clone(context);
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({ ...request, $context: { ...errorContext, traceId } });
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
- return Utils.clone(context);
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({ ...request, $context: { ...context, traceId } });
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.45",
3
+ "version": "1.0.47",
4
4
  "description": "o23 pipelines",
5
5
  "main": "index.cjs",
6
6
  "module": "index.js",
@@ -21,9 +21,9 @@
21
21
  "url": "https://github.com/InsureMO/rainbow-o23/issues"
22
22
  },
23
23
  "dependencies": {
24
- "@rainbow-o23/n1": "1.0.45",
24
+ "@rainbow-o23/n1": "1.0.47",
25
25
  "node-fetch": "2.6.7",
26
- "typeorm": "^0.3.17",
26
+ "typeorm": "^0.3.20",
27
27
  "typescript": "5.5.4"
28
28
  },
29
29
  "devDependencies": {
@@ -36,17 +36,17 @@
36
36
  "@types/events": "^3.0.1",
37
37
  "@types/node": "18.16.12",
38
38
  "@types/node-fetch": "2.6.4",
39
- "@typescript-eslint/eslint-plugin": "^7.18.0",
40
- "@typescript-eslint/parser": "^7.18.0",
41
- "better-sqlite3": "^9.0.0",
39
+ "@typescript-eslint/eslint-plugin": "^8.13.0",
40
+ "@typescript-eslint/parser": "^8.13.0",
41
+ "better-sqlite3": "^11.5.0",
42
42
  "eslint": "^9.8.0",
43
- "mssql": "^10.0.1",
44
- "mysql2": "^3.9.8",
45
- "oracledb": "^6.2.0",
46
- "pg": "^8.11.3",
47
- "pg-query-stream": "^4.5.3",
43
+ "mssql": "^11.0.1",
44
+ "mysql2": "^3.11.4",
45
+ "oracledb": "^6.6.0",
46
+ "pg": "^8.13.1",
47
+ "pg-query-stream": "^4.7.1",
48
48
  "reflect-metadata": "^0.2.2",
49
- "rollup": "^3.7.0",
49
+ "rollup": "^3.29.5",
50
50
  "rollup-plugin-tslint": "^0.2.2",
51
51
  "rollup-plugin-typescript2": "^0.34.1",
52
52
  "tslib": "^2.4.1"
@@ -74,7 +74,6 @@
74
74
  "testEnvironment": "node"
75
75
  },
76
76
  "volta": {
77
- "node": "20.17.0",
78
- "yarn": "1.22.21"
77
+ "extends": "../package.json"
79
78
  }
80
79
  }
@@ -213,7 +213,6 @@ export abstract class AbstractFragmentaryPipelineStep<In = PipelineStepPayload,
213
213
  };
214
214
  }
215
215
  } else if (typeof funcOrSnippet === 'string') {
216
- // eslint-disable-next-line @typescript-eslint/ban-types
217
216
  const func = Utils.createAsyncFunction(funcOrSnippet, {
218
217
  createDefault: async () => {
219
218
  throw new UncatchableError(ERR_PIPELINE_STEP_SNIPPET_NOT_EMPTY, 'Cannot create perform func on empty snippet.');
@@ -284,7 +283,8 @@ export abstract class AbstractFragmentaryPipelineStep<In = PipelineStepPayload,
284
283
  if (context == null) {
285
284
  return {};
286
285
  } else {
287
- return Utils.clone(context);
286
+ const {authorization, traceId, ...rest} = context;
287
+ return {authorization, traceId, ...Utils.clone(rest)};
288
288
  }
289
289
  }
290
290
 
@@ -293,7 +293,7 @@ export abstract class AbstractFragmentaryPipelineStep<In = PipelineStepPayload,
293
293
  */
294
294
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
295
295
  protected async handleErrorSteps(fragment: InFragment, errorCode: string, error: any, request: PipelineStepData<In>, builders: Array<PipelineStepBuilder>): Promise<OutFragment> {
296
- const {$context: {traceId} = {}} = request;
296
+ const {$context: {authorization, traceId} = {}} = request;
297
297
  const errorContext = this.createErrorHandleContext(request);
298
298
  const options = this.buildStepOptions();
299
299
  const steps = await Promise.all(builders.map(async builder => await builder.create(options)));
@@ -302,7 +302,9 @@ export abstract class AbstractFragmentaryPipelineStep<In = PipelineStepPayload,
302
302
  return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
303
303
  .execute(async () => {
304
304
  this.traceStepIn(traceId, step, request);
305
- const response = await step.perform({...request, $context: {...errorContext, traceId}});
305
+ const response = await step.perform({
306
+ ...request, $context: {...errorContext, authorization, traceId}
307
+ });
306
308
  this.traceStepOut(traceId, step, response);
307
309
  // if no response returned, keep using request for next
308
310
  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
  }
@@ -8,6 +8,7 @@ import {
8
8
  import {AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions} from './abstract-fragmentary-pipeline-step';
9
9
  import {Utils} from './utils';
10
10
 
11
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
11
12
  export interface PipelineStepSetsContext {
12
13
  }
13
14
 
@@ -50,7 +51,8 @@ export class PipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayloa
50
51
  if (context == null) {
51
52
  return {};
52
53
  } else {
53
- return Utils.clone(context);
54
+ const {authorization, traceId, ...rest} = context;
55
+ return {authorization, traceId, ...Utils.clone(rest)};
54
56
  }
55
57
  }
56
58
 
@@ -79,14 +81,16 @@ export class PipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayloa
79
81
  protected async doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment> {
80
82
  return await this.performWithContext(
81
83
  request, async (request: PipelineStepData<In>, context: PipelineStepSetsContext): Promise<OutFragment> => {
82
- const {$context: {traceId} = {}} = request;
84
+ const {$context: {authorization, traceId} = {}} = request;
83
85
  const steps = await this.createSteps();
84
86
  const response = await steps.reduce(async (promise, step) => {
85
87
  const request = await promise;
86
88
  return await this.measurePerformance(traceId, 'STEP', step.constructor.name)
87
89
  .execute(async () => {
88
90
  this.traceStepIn(traceId, step, request);
89
- const response = await step.perform({...request, $context: {...context, traceId}});
91
+ const response = await step.perform({
92
+ ...request, $context: {...context, authorization, traceId}
93
+ });
90
94
  this.traceStepOut(traceId, step, response);
91
95
  // if no response returned, keep using request for next
92
96
  return this.returnOrContinueOrClear(request, response);
@@ -7,7 +7,7 @@ import {
7
7
  } from '@rainbow-o23/n1';
8
8
 
9
9
  export type ScriptFunctionBody = string;
10
- // eslint-disable-next-line @typescript-eslint/ban-types
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
11
11
  export type ScriptFuncOrBody<F = Function> = F | ScriptFunctionBody;
12
12
 
13
13
  export interface ErrorHandleOptions<In, InFragment, E extends Error = Error> {
@@ -43,7 +43,7 @@ const AvoidProxyObjects = [
43
43
  ];
44
44
 
45
45
  export class Utils {
46
- // eslint-disable-next-line @typescript-eslint/ban-types
46
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
47
47
  public static createFunction<F = Function>(snippet: ScriptFuncOrBody<F>, creators: {
48
48
  createDefault: () => Undefinable<F> | never;
49
49
  getVariableNames: () => Array<string>;
@@ -105,7 +105,7 @@ export class Utils {
105
105
  }
106
106
  }
107
107
 
108
- // eslint-disable-next-line @typescript-eslint/ban-types
108
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
109
109
  public static createSyncFunction<F = Function>(snippet: ScriptFuncOrBody<F>, creators: {
110
110
  createDefault: () => Undefinable<F> | never;
111
111
  getVariableNames: () => Array<string>;
@@ -114,7 +114,7 @@ export class Utils {
114
114
  return Utils.createFunction(snippet, {...creators});
115
115
  }
116
116
 
117
- // eslint-disable-next-line @typescript-eslint/ban-types
117
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
118
118
  public static createAsyncFunction<F = Function>(snippet: ScriptFuncOrBody<F>, creators: {
119
119
  createDefault: () => Undefinable<F> | never;
120
120
  getVariableNames: () => Array<string>;