@rainbow-o23/n3 0.1.14 → 0.1.16

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 InsureMO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
+ ![Static Badge](https://img.shields.io/badge/InsureMO-777AF2.svg)
2
+
3
+ ![TypeORM](https://img.shields.io/badge/TypeORM-E83524.svg)
4
+ ![MySQL](https://img.shields.io/badge/MySQL-white.svg?logo=mysql&logoColor=4479A1&style=social)
5
+ ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-white.svg?logo=postgresql&logoColor=4169E1&style=social)
6
+ ![MSSQL](https://img.shields.io/badge/MSSQL-white.svg?logo=microsoftsqlserver&logoColor=CC2927&style=social)
7
+ ![Oracle](https://img.shields.io/badge/Oracle-white.svg?logo=oracle&logoColor=F80000&style=social)
8
+
9
+ ![Module Formats](https://img.shields.io/badge/module%20formats-cjs-green.svg)
10
+
1
11
  # o23/n3
2
12
 
3
13
  `o23/n3` provides the most basic pipeline steps.
@@ -339,7 +349,7 @@ When `typeorm.DB.type=better-sqlite3`:
339
349
 
340
350
  > SQLite save `DateTime` column as javascript `string`.
341
351
 
342
- > NEVER use it in production.
352
+ > NEVER use it in production.
343
353
 
344
354
  ### Constructor Parameters
345
355
 
@@ -426,8 +436,8 @@ Since different databases have varying degrees of support for dialects, `o23/n3`
426
436
  - For pagination, `$.limit($offset, $limit)` will be translated and executed in the appropriate dialect. For example,
427
437
  - `MySQL` uses `LIMIT $offset, $limit`,
428
438
  - `PostgreSQL` uses `OFFSET $offset LIMIT $limit`.
429
- - `MSSQL` uses `OFFSET $offset ROWS FETCH NEXT $limit ROWS ONLY`,
430
- - SQL Server requires an `ORDER BY` clause for pagination SQL. If there is no `ORDER BY` clause, will
439
+ - `MSSQL` and `Oracle` use `OFFSET $offset ROWS FETCH NEXT $limit ROWS ONLY`,
440
+ - `MSSQL` requires an `ORDER BY` clause for pagination SQL. If there is no `ORDER BY` clause, will
431
441
  use `ORDER BY 1 OFFSET $offset ROWS FETCH NEXT $limit ROWS ONLY`.
432
442
  - For JSON column, because some databases (such as MSSQL) do not have a JSON column type, they cannot automatically replace strings in the
433
443
  result set with JSON objects,
@@ -440,9 +450,9 @@ Since different databases have varying degrees of support for dialects, `o23/n3`
440
450
  - Use `$enabled.@bool` to explicitly indicate that the `enabled` property of given parameters is of boolean in-memory and numeric in
441
451
  database data type.
442
452
  - For datetime (MySQL, MSSQL) / timestamp (Oracle, PostgreSQL) column,
443
- - Use `created_at as "createAt.@ts"` to explicitly indicate that the `createAt` column is of string in-memory and timestamp in database
444
- data type.
445
- - Use `$createAt.@ts` to explicitly indicate that the `createAt` property of given parameters is of string in-memory and timestamp in
453
+ - Use `created_at as "createdAt.@ts"` to explicitly indicate that the `createdAt` column is of string in-memory and timestamp in
454
+ database data type.
455
+ - Use `$createdAt.@ts` to explicitly indicate that the `createdAt` property of given parameters is of string in-memory and timestamp in
446
456
  database data type.
447
457
 
448
458
  > We recommend that if you need to consider support for multiple database dialects, using enhanced syntax will make it easier to write SQL.
package/index.cjs CHANGED
@@ -797,19 +797,11 @@ class ConditionalPipelineStepSets extends PipelineStepSets {
797
797
  return this._otherwiseStepBuilders;
798
798
  }
799
799
  generateVariableNames() {
800
- return [
801
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
802
- ...this.getHelpersVariableNames()
803
- ].filter(x => x != null);
800
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
804
801
  }
805
- async check(data, _request) {
802
+ async check(data, request) {
806
803
  const $helpers = this.getHelpers();
807
- if (this.isInFragmentIgnored()) {
808
- return await this._func($helpers, $helpers);
809
- }
810
- else {
811
- return await this._func(data, $helpers, $helpers);
812
- }
804
+ return await this._func(data, request, $helpers, $helpers);
813
805
  }
814
806
  async perform(request) {
815
807
  return await this.performAndCatch(request, async (fragment) => {
@@ -831,12 +823,12 @@ class ConditionalPipelineStepSets extends PipelineStepSets {
831
823
  }
832
824
  });
833
825
  }
834
- isInFragmentIgnored() {
835
- return false;
836
- }
837
826
  getInFragmentVariableName() {
838
827
  return '$factor';
839
828
  }
829
+ getRequestVariableName() {
830
+ return '$request';
831
+ }
840
832
  }
841
833
 
842
834
  class RoutesPipelineStepSets extends AbstractFragmentaryPipelineStep {
@@ -871,19 +863,11 @@ class RoutesPipelineStepSets extends AbstractFragmentaryPipelineStep {
871
863
  return { config: this.getConfig(), logger: this.getLogger() };
872
864
  }
873
865
  generateVariableNames() {
874
- return [
875
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
876
- ...this.getHelpersVariableNames()
877
- ].filter(x => x != null);
866
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
878
867
  }
879
- async check(func, data, _request) {
868
+ async check(func, data, request) {
880
869
  const $helpers = this.getHelpers();
881
- if (this.isInFragmentIgnored()) {
882
- return await func($helpers, $helpers);
883
- }
884
- else {
885
- return await func(data, $helpers, $helpers);
886
- }
870
+ return await func(data, request, $helpers, $helpers);
887
871
  }
888
872
  async doPerform(data, request) {
889
873
  throw new n1.UncatchableError(ERR_PIPELINE_STEP_METHOD_NOT_SUPPORTED, `Method[${RoutesPipelineStepSets.name}.doPerform] not supported.`);
@@ -917,12 +901,12 @@ class RoutesPipelineStepSets extends AbstractFragmentaryPipelineStep {
917
901
  }
918
902
  });
919
903
  }
920
- isInFragmentIgnored() {
921
- return false;
922
- }
923
904
  getInFragmentVariableName() {
924
905
  return '$factor';
925
906
  }
907
+ getRequestVariableName() {
908
+ return '$request';
909
+ }
926
910
  }
927
911
 
928
912
  class SnippetPipelineStep extends AbstractFragmentaryPipelineStep {
@@ -946,26 +930,18 @@ class SnippetPipelineStep extends AbstractFragmentaryPipelineStep {
946
930
  return this._snippet;
947
931
  }
948
932
  generateVariableNames() {
949
- return [
950
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
951
- ...this.getHelpersVariableNames()
952
- ].filter(x => x != null);
933
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
953
934
  }
954
- async doPerform(data, _request) {
935
+ async doPerform(data, request) {
955
936
  const $helpers = this.getHelpers();
956
- if (this.isInFragmentIgnored()) {
957
- return await this._func($helpers, $helpers);
958
- }
959
- else {
960
- return await this._func(data, $helpers, $helpers);
961
- }
962
- }
963
- isInFragmentIgnored() {
964
- return false;
937
+ return await this._func(data, request, $helpers, $helpers);
965
938
  }
966
939
  getInFragmentVariableName() {
967
940
  return '$factor';
968
941
  }
942
+ getRequestVariableName() {
943
+ return '$request';
944
+ }
969
945
  }
970
946
 
971
947
  class SnowflakePipelineStep extends AbstractFragmentaryPipelineStep {
@@ -1585,30 +1561,26 @@ class TypeOrmBySnippetPipelineStep extends AbstractTypeOrmPipelineStep {
1585
1561
  generateVariableNames() {
1586
1562
  return [
1587
1563
  this.getRunnerVariableName(),
1588
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
1564
+ this.getInFragmentVariableName(),
1565
+ this.getRequestVariableName(),
1589
1566
  ...this.getHelpersVariableNames()
1590
- ].filter(x => x != null);
1567
+ ];
1591
1568
  }
1592
1569
  async doPerform(basis, request) {
1593
1570
  return await this.autoTrans(async (runner) => {
1594
1571
  const $helpers = this.getHelpers();
1595
- if (this.isInFragmentIgnored()) {
1596
- return await this._func(runner, $helpers, $helpers);
1597
- }
1598
- else {
1599
- return await this._func(runner, basis, $helpers, $helpers);
1600
- }
1572
+ return await this._func(runner, basis, request, $helpers, $helpers);
1601
1573
  }, request);
1602
1574
  }
1603
- isInFragmentIgnored() {
1604
- return false;
1605
- }
1606
1575
  getRunnerVariableName() {
1607
1576
  return '$runner';
1608
1577
  }
1609
1578
  getInFragmentVariableName() {
1610
1579
  return '$factor';
1611
1580
  }
1581
+ getRequestVariableName() {
1582
+ return '$request';
1583
+ }
1612
1584
  }
1613
1585
 
1614
1586
  exports.ParsedSqlSegmentType = void 0;
@@ -2065,7 +2037,7 @@ class AbstractTypeOrmBySQLPipelineStep extends AbstractTypeOrmPipelineStep {
2065
2037
  return result.rowCount;
2066
2038
  default:
2067
2039
  if (result.hasOwnProperty('rows')) {
2068
- return result.rows;
2040
+ return (result.rows ?? []).map(item => this.beautify({ data: item, datasourceType }));
2069
2041
  }
2070
2042
  else {
2071
2043
  return result;
@@ -2079,7 +2051,7 @@ class AbstractTypeOrmBySQLPipelineStep extends AbstractTypeOrmPipelineStep {
2079
2051
  return this.beautify({ data: result, datasourceType });
2080
2052
  }
2081
2053
  default:
2082
- return result;
2054
+ return this.beautify({ data: result, datasourceType });
2083
2055
  }
2084
2056
  }
2085
2057
  }
package/index.js CHANGED
@@ -795,19 +795,11 @@ class ConditionalPipelineStepSets extends PipelineStepSets {
795
795
  return this._otherwiseStepBuilders;
796
796
  }
797
797
  generateVariableNames() {
798
- return [
799
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
800
- ...this.getHelpersVariableNames()
801
- ].filter(x => x != null);
798
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
802
799
  }
803
- async check(data, _request) {
800
+ async check(data, request) {
804
801
  const $helpers = this.getHelpers();
805
- if (this.isInFragmentIgnored()) {
806
- return await this._func($helpers, $helpers);
807
- }
808
- else {
809
- return await this._func(data, $helpers, $helpers);
810
- }
802
+ return await this._func(data, request, $helpers, $helpers);
811
803
  }
812
804
  async perform(request) {
813
805
  return await this.performAndCatch(request, async (fragment) => {
@@ -829,12 +821,12 @@ class ConditionalPipelineStepSets extends PipelineStepSets {
829
821
  }
830
822
  });
831
823
  }
832
- isInFragmentIgnored() {
833
- return false;
834
- }
835
824
  getInFragmentVariableName() {
836
825
  return '$factor';
837
826
  }
827
+ getRequestVariableName() {
828
+ return '$request';
829
+ }
838
830
  }
839
831
 
840
832
  class RoutesPipelineStepSets extends AbstractFragmentaryPipelineStep {
@@ -869,19 +861,11 @@ class RoutesPipelineStepSets extends AbstractFragmentaryPipelineStep {
869
861
  return { config: this.getConfig(), logger: this.getLogger() };
870
862
  }
871
863
  generateVariableNames() {
872
- return [
873
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
874
- ...this.getHelpersVariableNames()
875
- ].filter(x => x != null);
864
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
876
865
  }
877
- async check(func, data, _request) {
866
+ async check(func, data, request) {
878
867
  const $helpers = this.getHelpers();
879
- if (this.isInFragmentIgnored()) {
880
- return await func($helpers, $helpers);
881
- }
882
- else {
883
- return await func(data, $helpers, $helpers);
884
- }
868
+ return await func(data, request, $helpers, $helpers);
885
869
  }
886
870
  async doPerform(data, request) {
887
871
  throw new UncatchableError(ERR_PIPELINE_STEP_METHOD_NOT_SUPPORTED, `Method[${RoutesPipelineStepSets.name}.doPerform] not supported.`);
@@ -915,12 +899,12 @@ class RoutesPipelineStepSets extends AbstractFragmentaryPipelineStep {
915
899
  }
916
900
  });
917
901
  }
918
- isInFragmentIgnored() {
919
- return false;
920
- }
921
902
  getInFragmentVariableName() {
922
903
  return '$factor';
923
904
  }
905
+ getRequestVariableName() {
906
+ return '$request';
907
+ }
924
908
  }
925
909
 
926
910
  class SnippetPipelineStep extends AbstractFragmentaryPipelineStep {
@@ -944,26 +928,18 @@ class SnippetPipelineStep extends AbstractFragmentaryPipelineStep {
944
928
  return this._snippet;
945
929
  }
946
930
  generateVariableNames() {
947
- return [
948
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
949
- ...this.getHelpersVariableNames()
950
- ].filter(x => x != null);
931
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
951
932
  }
952
- async doPerform(data, _request) {
933
+ async doPerform(data, request) {
953
934
  const $helpers = this.getHelpers();
954
- if (this.isInFragmentIgnored()) {
955
- return await this._func($helpers, $helpers);
956
- }
957
- else {
958
- return await this._func(data, $helpers, $helpers);
959
- }
960
- }
961
- isInFragmentIgnored() {
962
- return false;
935
+ return await this._func(data, request, $helpers, $helpers);
963
936
  }
964
937
  getInFragmentVariableName() {
965
938
  return '$factor';
966
939
  }
940
+ getRequestVariableName() {
941
+ return '$request';
942
+ }
967
943
  }
968
944
 
969
945
  class SnowflakePipelineStep extends AbstractFragmentaryPipelineStep {
@@ -1583,30 +1559,26 @@ class TypeOrmBySnippetPipelineStep extends AbstractTypeOrmPipelineStep {
1583
1559
  generateVariableNames() {
1584
1560
  return [
1585
1561
  this.getRunnerVariableName(),
1586
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
1562
+ this.getInFragmentVariableName(),
1563
+ this.getRequestVariableName(),
1587
1564
  ...this.getHelpersVariableNames()
1588
- ].filter(x => x != null);
1565
+ ];
1589
1566
  }
1590
1567
  async doPerform(basis, request) {
1591
1568
  return await this.autoTrans(async (runner) => {
1592
1569
  const $helpers = this.getHelpers();
1593
- if (this.isInFragmentIgnored()) {
1594
- return await this._func(runner, $helpers, $helpers);
1595
- }
1596
- else {
1597
- return await this._func(runner, basis, $helpers, $helpers);
1598
- }
1570
+ return await this._func(runner, basis, request, $helpers, $helpers);
1599
1571
  }, request);
1600
1572
  }
1601
- isInFragmentIgnored() {
1602
- return false;
1603
- }
1604
1573
  getRunnerVariableName() {
1605
1574
  return '$runner';
1606
1575
  }
1607
1576
  getInFragmentVariableName() {
1608
1577
  return '$factor';
1609
1578
  }
1579
+ getRequestVariableName() {
1580
+ return '$request';
1581
+ }
1610
1582
  }
1611
1583
 
1612
1584
  var ParsedSqlSegmentType;
@@ -2063,7 +2035,7 @@ class AbstractTypeOrmBySQLPipelineStep extends AbstractTypeOrmPipelineStep {
2063
2035
  return result.rowCount;
2064
2036
  default:
2065
2037
  if (result.hasOwnProperty('rows')) {
2066
- return result.rows;
2038
+ return (result.rows ?? []).map(item => this.beautify({ data: item, datasourceType }));
2067
2039
  }
2068
2040
  else {
2069
2041
  return result;
@@ -2077,7 +2049,7 @@ class AbstractTypeOrmBySQLPipelineStep extends AbstractTypeOrmPipelineStep {
2077
2049
  return this.beautify({ data: result, datasourceType });
2078
2050
  }
2079
2051
  default:
2080
- return result;
2052
+ return this.beautify({ data: result, datasourceType });
2081
2053
  }
2082
2054
  }
2083
2055
  }
@@ -1,11 +1,9 @@
1
1
  import { PipelineStepBuilder, PipelineStepData, PipelineStepHelpers, PipelineStepPayload, Undefinable } from '@rainbow-o23/n1';
2
2
  import { PipelineStepSets, PipelineStepSetsOptions } from './step-sets';
3
3
  import { ScriptFuncOrBody } from './types';
4
- export type ConditionCheckWithInFragment<InFragment> = ($factor: InFragment, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<boolean>;
5
- export type ConditionCheckWithoutInFragment = ($helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<boolean>;
6
- export type ConditionCheckFunc<InFragment> = ConditionCheckWithInFragment<InFragment> | ConditionCheckWithoutInFragment;
4
+ export type ConditionCheckFunc<In, InFragment> = ($factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<boolean>;
7
5
  export interface ConditionalPipelineStepSetsOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends PipelineStepSetsOptions<In, Out, InFragment, OutFragment> {
8
- check: ScriptFuncOrBody<ConditionCheckFunc<InFragment>>;
6
+ check: ScriptFuncOrBody<ConditionCheckFunc<In, InFragment>>;
9
7
  otherwiseSteps: Array<PipelineStepBuilder>;
10
8
  }
11
9
  export declare class ConditionalPipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends PipelineStepSets<In, Out, InFragment, OutFragment> {
@@ -13,11 +11,11 @@ export declare class ConditionalPipelineStepSets<In = PipelineStepPayload, Out =
13
11
  private readonly _func;
14
12
  private readonly _otherwiseStepBuilders;
15
13
  constructor(options: ConditionalPipelineStepSetsOptions<In, Out, InFragment, OutFragment>);
16
- getCheckSnippet(): ScriptFuncOrBody<ConditionCheckFunc<InFragment>>;
14
+ getCheckSnippet(): ScriptFuncOrBody<ConditionCheckFunc<In, InFragment>>;
17
15
  protected getOtherwiseStepBuilders(): Undefinable<Array<PipelineStepBuilder>>;
18
16
  protected generateVariableNames(): Array<string>;
19
- protected check(data: InFragment, _request: PipelineStepData<In>): Promise<boolean>;
17
+ protected check(data: InFragment, request: PipelineStepData<In>): Promise<boolean>;
20
18
  perform(request: PipelineStepData<In>): Promise<PipelineStepData<Out>>;
21
- protected isInFragmentIgnored(): boolean;
22
19
  protected getInFragmentVariableName(): string;
20
+ protected getRequestVariableName(): string;
23
21
  }
@@ -2,29 +2,29 @@ import { PipelineStepBuilder, PipelineStepData, PipelineStepOptions, PipelineSte
2
2
  import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from './abstract-fragmentary-pipeline-step';
3
3
  import { ConditionCheckFunc } from './conditional-step-sets';
4
4
  import { ScriptFuncOrBody } from './types';
5
- export interface RoutesConditionalStepOptions<InFragment> {
6
- check: ScriptFuncOrBody<ConditionCheckFunc<InFragment>>;
5
+ export interface RoutesConditionalStepOptions<In, InFragment> {
6
+ check: ScriptFuncOrBody<ConditionCheckFunc<In, InFragment>>;
7
7
  steps?: Array<PipelineStepBuilder>;
8
8
  }
9
9
  export interface RoutesPipelineStepSetsOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
10
- conditionalSteps: Array<RoutesConditionalStepOptions<InFragment>>;
10
+ conditionalSteps: Array<RoutesConditionalStepOptions<In, InFragment>>;
11
11
  otherwiseSteps?: Array<PipelineStepBuilder>;
12
12
  }
13
- export interface RoutesConditionalStep<InFragment> {
14
- check: ConditionCheckFunc<InFragment>;
13
+ export interface RoutesConditionalStep<In, InFragment> {
14
+ check: ConditionCheckFunc<In, InFragment>;
15
15
  steps: Array<PipelineStepBuilder>;
16
16
  }
17
17
  export declare class RoutesPipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
18
18
  private readonly _conditionalStepBuilders;
19
19
  private readonly _otherwiseStepBuilders;
20
20
  constructor(options: RoutesPipelineStepSetsOptions<In, Out, InFragment, OutFragment>);
21
- protected getConditionalStepBuilders(): Array<RoutesConditionalStep<InFragment>>;
21
+ protected getConditionalStepBuilders(): Array<RoutesConditionalStep<In, InFragment>>;
22
22
  protected getOtherwiseStepBuilders(): Undefinable<Array<PipelineStepBuilder>>;
23
23
  protected buildStepOptions(): Pick<PipelineStepOptions, 'config' | 'logger'>;
24
24
  protected generateVariableNames(): Array<string>;
25
- protected check(func: ConditionCheckFunc<InFragment>, data: InFragment, _request: PipelineStepData<In>): Promise<boolean>;
25
+ protected check(func: ConditionCheckFunc<In, InFragment>, data: InFragment, request: PipelineStepData<In>): Promise<boolean>;
26
26
  protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
27
27
  perform(request: PipelineStepData<In>): Promise<PipelineStepData<Out>>;
28
- protected isInFragmentIgnored(): boolean;
29
28
  protected getInFragmentVariableName(): string;
29
+ protected getRequestVariableName(): string;
30
30
  }
@@ -1,19 +1,17 @@
1
1
  import { PipelineStepData, PipelineStepHelpers, PipelineStepPayload } from '@rainbow-o23/n1';
2
2
  import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from './abstract-fragmentary-pipeline-step';
3
3
  import { ScriptFuncOrBody } from './types';
4
- export type PerformWithInFragment<InFragment, OutFragment> = ($factor: InFragment, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
5
- export type PerformWithoutInFragment<OutFragment> = ($helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
6
- export type PerformFunc<InFragment, OutFragment> = PerformWithInFragment<InFragment, OutFragment> | PerformWithoutInFragment<OutFragment>;
4
+ export type PerformFunc<In, InFragment, OutFragment> = ($factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
7
5
  export interface SnippetPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
8
- snippet: ScriptFuncOrBody<PerformFunc<InFragment, OutFragment>>;
6
+ snippet: ScriptFuncOrBody<PerformFunc<In, InFragment, OutFragment>>;
9
7
  }
10
8
  export declare class SnippetPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
11
9
  private readonly _snippet;
12
10
  private readonly _func;
13
11
  constructor(options: SnippetPipelineStepOptions<In, Out, InFragment, OutFragment>);
14
- getSnippet(): ScriptFuncOrBody<PerformFunc<InFragment, OutFragment>>;
12
+ getSnippet(): ScriptFuncOrBody<PerformFunc<In, InFragment, OutFragment>>;
15
13
  protected generateVariableNames(): Array<string>;
16
- protected doPerform(data: InFragment, _request: PipelineStepData<In>): Promise<OutFragment>;
17
- protected isInFragmentIgnored(): boolean;
14
+ protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
18
15
  protected getInFragmentVariableName(): string;
16
+ protected getRequestVariableName(): string;
19
17
  }
@@ -2,20 +2,18 @@ import { PipelineStepData, PipelineStepHelpers, PipelineStepPayload } from '@rai
2
2
  import { QueryRunner } from 'typeorm';
3
3
  import { ScriptFuncOrBody } from '../step';
4
4
  import { AbstractTypeOrmPipelineStep, TypeOrmPipelineStepOptions } from './abstract-typeorm-step';
5
- export type TypeOrmPerformWithInFragment<InFragment, OutFragment> = ($runner: QueryRunner, $factor: InFragment, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
6
- export type TypeOrmPerformWithoutInFragment<OutFragment> = ($runner: QueryRunner, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
7
- export type TypeOrmPerformFunc<InFragment, OutFragment> = TypeOrmPerformWithInFragment<InFragment, OutFragment> | TypeOrmPerformWithoutInFragment<OutFragment>;
5
+ export type TypeOrmPerformFunc<In, InFragment, OutFragment> = ($runner: QueryRunner, $factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
8
6
  export interface TypeOrmBySnippetPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends TypeOrmPipelineStepOptions<In, Out, InFragment, OutFragment> {
9
- snippet: ScriptFuncOrBody<TypeOrmPerformFunc<InFragment, OutFragment>>;
7
+ snippet: ScriptFuncOrBody<TypeOrmPerformFunc<In, InFragment, OutFragment>>;
10
8
  }
11
9
  export declare class TypeOrmBySnippetPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractTypeOrmPipelineStep<In, Out, InFragment, OutFragment> {
12
10
  private readonly _snippet;
13
11
  private readonly _func;
14
12
  constructor(options: TypeOrmBySnippetPipelineStepOptions<In, Out, InFragment, OutFragment>);
15
- getSnippet(): ScriptFuncOrBody<TypeOrmPerformFunc<InFragment, OutFragment>>;
13
+ getSnippet(): ScriptFuncOrBody<TypeOrmPerformFunc<In, InFragment, OutFragment>>;
16
14
  protected generateVariableNames(): Array<string>;
17
15
  protected doPerform(basis: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
18
- protected isInFragmentIgnored(): boolean;
19
16
  protected getRunnerVariableName(): string;
20
17
  protected getInFragmentVariableName(): string;
18
+ protected getRequestVariableName(): string;
21
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainbow-o23/n3",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "o23 pipelines",
5
5
  "main": "index.cjs",
6
6
  "module": "index.js",
@@ -15,14 +15,15 @@
15
15
  "type": "git",
16
16
  "url": "git+https://github.com/InsureMO/rainbow-o23.git"
17
17
  },
18
+ "author": "Rainbow Team",
18
19
  "license": "MIT",
19
20
  "bugs": {
20
21
  "url": "https://github.com/InsureMO/rainbow-o23/issues"
21
22
  },
22
23
  "dependencies": {
23
- "@rainbow-o23/n1": "0.1.14",
24
+ "@rainbow-o23/n1": "0.1.16",
24
25
  "@theinternetfolks/snowflake": "^1.3.0",
25
- "node-fetch": "2.6.1",
26
+ "node-fetch": "2.6.7",
26
27
  "typeorm": "^0.3.17"
27
28
  },
28
29
  "devDependencies": {
@@ -11,16 +11,11 @@ import {PipelineStepSets, PipelineStepSetsOptions} from './step-sets';
11
11
  import {ScriptFuncOrBody} from './types';
12
12
  import {Utils} from './utils';
13
13
 
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- export type ConditionCheckWithInFragment<InFragment> = ($factor: InFragment, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<boolean>;
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- export type ConditionCheckWithoutInFragment = ($helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<boolean>;
18
- export type ConditionCheckFunc<InFragment> =
19
- ConditionCheckWithInFragment<InFragment> | ConditionCheckWithoutInFragment;
14
+ export type ConditionCheckFunc<In, InFragment> = ($factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<boolean>;
20
15
 
21
16
  export interface ConditionalPipelineStepSetsOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out>
22
17
  extends PipelineStepSetsOptions<In, Out, InFragment, OutFragment> {
23
- check: ScriptFuncOrBody<ConditionCheckFunc<InFragment>>;
18
+ check: ScriptFuncOrBody<ConditionCheckFunc<In, InFragment>>;
24
19
  otherwiseSteps: Array<PipelineStepBuilder>;
25
20
  }
26
21
 
@@ -29,8 +24,8 @@ export interface ConditionalPipelineStepSetsOptions<In = PipelineStepPayload, Ou
29
24
  */
30
25
  export class ConditionalPipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out>
31
26
  extends PipelineStepSets<In, Out, InFragment, OutFragment> {
32
- private readonly _checkSnippet: ScriptFuncOrBody<ConditionCheckFunc<InFragment>>;
33
- private readonly _func: ConditionCheckFunc<InFragment>;
27
+ private readonly _checkSnippet: ScriptFuncOrBody<ConditionCheckFunc<In, InFragment>>;
28
+ private readonly _func: ConditionCheckFunc<In, InFragment>;
34
29
  private readonly _otherwiseStepBuilders: Undefinable<Array<PipelineStepBuilder>>;
35
30
 
36
31
  // noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
@@ -50,7 +45,7 @@ export class ConditionalPipelineStepSets<In = PipelineStepPayload, Out = Pipelin
50
45
  this._otherwiseStepBuilders = options.otherwiseSteps;
51
46
  }
52
47
 
53
- public getCheckSnippet(): ScriptFuncOrBody<ConditionCheckFunc<InFragment>> {
48
+ public getCheckSnippet(): ScriptFuncOrBody<ConditionCheckFunc<In, InFragment>> {
54
49
  return this._checkSnippet;
55
50
  }
56
51
 
@@ -59,20 +54,12 @@ export class ConditionalPipelineStepSets<In = PipelineStepPayload, Out = Pipelin
59
54
  }
60
55
 
61
56
  protected generateVariableNames(): Array<string> {
62
- return [
63
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
64
- ...this.getHelpersVariableNames()
65
- ].filter(x => x != null);
57
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
66
58
  }
67
59
 
68
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
69
- protected async check(data: InFragment, _request: PipelineStepData<In>): Promise<boolean> {
60
+ protected async check(data: InFragment, request: PipelineStepData<In>): Promise<boolean> {
70
61
  const $helpers = this.getHelpers();
71
- if (this.isInFragmentIgnored()) {
72
- return await (this._func as ConditionCheckWithoutInFragment)($helpers, $helpers);
73
- } else {
74
- return await (this._func as ConditionCheckWithInFragment<InFragment>)(data, $helpers, $helpers);
75
- }
62
+ return await this._func(data, request, $helpers, $helpers);
76
63
  }
77
64
 
78
65
  public async perform(request: PipelineStepData<In>): Promise<PipelineStepData<Out>> {
@@ -98,18 +85,14 @@ export class ConditionalPipelineStepSets<In = PipelineStepPayload, Out = Pipelin
98
85
  });
99
86
  }
100
87
 
101
- /**
102
- * is request step data ignored to snippet function.
103
- * default returns false
104
- */
105
- protected isInFragmentIgnored(): boolean {
106
- return false;
107
- }
108
-
109
88
  /**
110
89
  * override this method when want to use another variable name rather than "$factor"
111
90
  */
112
91
  protected getInFragmentVariableName(): string {
113
92
  return '$factor';
114
93
  }
94
+
95
+ protected getRequestVariableName(): string {
96
+ return '$request';
97
+ }
115
98
  }
@@ -8,28 +8,24 @@ import {
8
8
  } from '@rainbow-o23/n1';
9
9
  import {ERR_PIPELINE_STEP_CONDITIONAL_SNIPPET_NOT_EMPTY, ERR_PIPELINE_STEP_METHOD_NOT_SUPPORTED} from '../error-codes';
10
10
  import {AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions} from './abstract-fragmentary-pipeline-step';
11
- import {
12
- ConditionCheckFunc,
13
- ConditionCheckWithInFragment,
14
- ConditionCheckWithoutInFragment
15
- } from './conditional-step-sets';
11
+ import {ConditionCheckFunc} from './conditional-step-sets';
16
12
  import {PipelineStepSets} from './step-sets';
17
13
  import {ScriptFuncOrBody} from './types';
18
14
  import {Utils} from './utils';
19
15
 
20
- export interface RoutesConditionalStepOptions<InFragment> {
21
- check: ScriptFuncOrBody<ConditionCheckFunc<InFragment>>,
16
+ export interface RoutesConditionalStepOptions<In, InFragment> {
17
+ check: ScriptFuncOrBody<ConditionCheckFunc<In, InFragment>>,
22
18
  steps?: Array<PipelineStepBuilder>;
23
19
  }
24
20
 
25
21
  export interface RoutesPipelineStepSetsOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out>
26
22
  extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
27
- conditionalSteps: Array<RoutesConditionalStepOptions<InFragment>>;
23
+ conditionalSteps: Array<RoutesConditionalStepOptions<In, InFragment>>;
28
24
  otherwiseSteps?: Array<PipelineStepBuilder>;
29
25
  }
30
26
 
31
- export interface RoutesConditionalStep<InFragment> {
32
- check: ConditionCheckFunc<InFragment>;
27
+ export interface RoutesConditionalStep<In, InFragment> {
28
+ check: ConditionCheckFunc<In, InFragment>;
33
29
  steps: Array<PipelineStepBuilder>;
34
30
  }
35
31
 
@@ -38,7 +34,7 @@ export interface RoutesConditionalStep<InFragment> {
38
34
  */
39
35
  export class RoutesPipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out>
40
36
  extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
41
- private readonly _conditionalStepBuilders: Array<RoutesConditionalStep<InFragment>>;
37
+ private readonly _conditionalStepBuilders: Array<RoutesConditionalStep<In, InFragment>>;
42
38
  private readonly _otherwiseStepBuilders: Undefinable<Array<PipelineStepBuilder>>;
43
39
 
44
40
  constructor(options: RoutesPipelineStepSetsOptions<In, Out, InFragment, OutFragment>) {
@@ -61,7 +57,7 @@ export class RoutesPipelineStepSets<In = PipelineStepPayload, Out = PipelineStep
61
57
  this._otherwiseStepBuilders = options.otherwiseSteps;
62
58
  }
63
59
 
64
- protected getConditionalStepBuilders(): Array<RoutesConditionalStep<InFragment>> {
60
+ protected getConditionalStepBuilders(): Array<RoutesConditionalStep<In, InFragment>> {
65
61
  return this._conditionalStepBuilders;
66
62
  }
67
63
 
@@ -74,20 +70,12 @@ export class RoutesPipelineStepSets<In = PipelineStepPayload, Out = PipelineStep
74
70
  }
75
71
 
76
72
  protected generateVariableNames(): Array<string> {
77
- return [
78
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
79
- ...this.getHelpersVariableNames()
80
- ].filter(x => x != null);
73
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
81
74
  }
82
75
 
83
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
84
- protected async check(func: ConditionCheckFunc<InFragment>, data: InFragment, _request: PipelineStepData<In>): Promise<boolean> {
76
+ protected async check(func: ConditionCheckFunc<In, InFragment>, data: InFragment, request: PipelineStepData<In>): Promise<boolean> {
85
77
  const $helpers = this.getHelpers();
86
- if (this.isInFragmentIgnored()) {
87
- return await (func as ConditionCheckWithoutInFragment)($helpers, $helpers);
88
- } else {
89
- return await (func as ConditionCheckWithInFragment<InFragment>)(data, $helpers, $helpers);
90
- }
78
+ return await func(data, request, $helpers, $helpers);
91
79
  }
92
80
 
93
81
  /**
@@ -130,18 +118,14 @@ export class RoutesPipelineStepSets<In = PipelineStepPayload, Out = PipelineStep
130
118
  });
131
119
  }
132
120
 
133
- /**
134
- * is request step data ignored to snippet function.
135
- * default returns false
136
- */
137
- protected isInFragmentIgnored(): boolean {
138
- return false;
139
- }
140
-
141
121
  /**
142
122
  * override this method when want to use another variable name rather than "$factor"
143
123
  */
144
124
  protected getInFragmentVariableName(): string {
145
125
  return '$factor';
146
126
  }
127
+
128
+ protected getRequestVariableName(): string {
129
+ return '$request';
130
+ }
147
131
  }
@@ -4,16 +4,12 @@ import {AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions} from '.
4
4
  import {ScriptFuncOrBody} from './types';
5
5
  import {Utils} from './utils';
6
6
 
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- export type PerformWithInFragment<InFragment, OutFragment> = ($factor: InFragment, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- export type PerformWithoutInFragment<OutFragment> = ($helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
11
- export type PerformFunc<InFragment, OutFragment> =
12
- PerformWithInFragment<InFragment, OutFragment> | PerformWithoutInFragment<OutFragment>;
7
+ export type PerformFunc<In, InFragment, OutFragment> =
8
+ ($factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
13
9
 
14
10
  export interface SnippetPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out>
15
11
  extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
16
- snippet: ScriptFuncOrBody<PerformFunc<InFragment, OutFragment>>;
12
+ snippet: ScriptFuncOrBody<PerformFunc<In, InFragment, OutFragment>>;
17
13
  }
18
14
 
19
15
  /**
@@ -24,8 +20,8 @@ export interface SnippetPipelineStepOptions<In = PipelineStepPayload, Out = Pipe
24
20
  */
25
21
  export class SnippetPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out>
26
22
  extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
27
- private readonly _snippet: ScriptFuncOrBody<PerformFunc<InFragment, OutFragment>>;
28
- private readonly _func: PerformFunc<InFragment, OutFragment>;
23
+ private readonly _snippet: ScriptFuncOrBody<PerformFunc<In, InFragment, OutFragment>>;
24
+ private readonly _func: PerformFunc<In, InFragment, OutFragment>;
29
25
 
30
26
  public constructor(options: SnippetPipelineStepOptions<In, Out, InFragment, OutFragment>) {
31
27
  super(options);
@@ -42,33 +38,17 @@ export class SnippetPipelineStep<In = PipelineStepPayload, Out = PipelineStepPay
42
38
  });
43
39
  }
44
40
 
45
- public getSnippet(): ScriptFuncOrBody<PerformFunc<InFragment, OutFragment>> {
41
+ public getSnippet(): ScriptFuncOrBody<PerformFunc<In, InFragment, OutFragment>> {
46
42
  return this._snippet;
47
43
  }
48
44
 
49
45
  protected generateVariableNames(): Array<string> {
50
- return [
51
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
52
- ...this.getHelpersVariableNames()
53
- ].filter(x => x != null);
46
+ return [this.getInFragmentVariableName(), this.getRequestVariableName(), ...this.getHelpersVariableNames()];
54
47
  }
55
48
 
56
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
- protected async doPerform(data: InFragment, _request: PipelineStepData<In>): Promise<OutFragment> {
49
+ protected async doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment> {
58
50
  const $helpers = this.getHelpers();
59
- if (this.isInFragmentIgnored()) {
60
- return await (this._func as PerformWithoutInFragment<OutFragment>)($helpers, $helpers);
61
- } else {
62
- return await (this._func as PerformWithInFragment<InFragment, OutFragment>)(data, $helpers, $helpers);
63
- }
64
- }
65
-
66
- /**
67
- * is request step data ignored to snippet function.
68
- * default returns false
69
- */
70
- protected isInFragmentIgnored(): boolean {
71
- return false;
51
+ return await this._func(data, request, $helpers, $helpers);
72
52
  }
73
53
 
74
54
  /**
@@ -77,4 +57,8 @@ export class SnippetPipelineStep<In = PipelineStepPayload, Out = PipelineStepPay
77
57
  protected getInFragmentVariableName(): string {
78
58
  return '$factor';
79
59
  }
60
+
61
+ protected getRequestVariableName(): string {
62
+ return '$request';
63
+ }
80
64
  }
@@ -536,7 +536,7 @@ export abstract class AbstractTypeOrmBySQLPipelineStep<In = PipelineStepPayload,
536
536
  // eslint-disable-next-line no-prototype-builtins
537
537
  if (result.hasOwnProperty('rows')) {
538
538
  // for SELECT
539
- return result.rows;
539
+ return (result.rows ?? []).map(item => this.beautify({data: item, datasourceType}));
540
540
  } else {
541
541
  // INSERT, an empty array
542
542
  return result;
@@ -550,7 +550,7 @@ export abstract class AbstractTypeOrmBySQLPipelineStep<In = PipelineStepPayload,
550
550
  return this.beautify({data: result, datasourceType});
551
551
  }
552
552
  default:
553
- return result;
553
+ return this.beautify({data: result, datasourceType});
554
554
  }
555
555
  }
556
556
  }
@@ -4,16 +4,11 @@ import {ERR_TYPEORM_STEP_SNIPPET_NOT_EMPTY} from '../error-codes';
4
4
  import {ScriptFuncOrBody, Utils} from '../step';
5
5
  import {AbstractTypeOrmPipelineStep, TypeOrmPipelineStepOptions} from './abstract-typeorm-step';
6
6
 
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- export type TypeOrmPerformWithInFragment<InFragment, OutFragment> = ($runner: QueryRunner, $factor: InFragment, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- export type TypeOrmPerformWithoutInFragment<OutFragment> = ($runner: QueryRunner, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
11
- export type TypeOrmPerformFunc<InFragment, OutFragment> =
12
- TypeOrmPerformWithInFragment<InFragment, OutFragment> | TypeOrmPerformWithoutInFragment<OutFragment>;
7
+ export type TypeOrmPerformFunc<In, InFragment, OutFragment> = ($runner: QueryRunner, $factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
13
8
 
14
9
  export interface TypeOrmBySnippetPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out>
15
10
  extends TypeOrmPipelineStepOptions<In, Out, InFragment, OutFragment> {
16
- snippet: ScriptFuncOrBody<TypeOrmPerformFunc<InFragment, OutFragment>>;
11
+ snippet: ScriptFuncOrBody<TypeOrmPerformFunc<In, InFragment, OutFragment>>;
17
12
  }
18
13
 
19
14
  /**
@@ -21,8 +16,8 @@ export interface TypeOrmBySnippetPipelineStepOptions<In = PipelineStepPayload, O
21
16
  */
22
17
  export class TypeOrmBySnippetPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out>
23
18
  extends AbstractTypeOrmPipelineStep<In, Out, InFragment, OutFragment> {
24
- private readonly _snippet: ScriptFuncOrBody<TypeOrmPerformFunc<InFragment, OutFragment>>;
25
- private readonly _func: TypeOrmPerformFunc<InFragment, OutFragment>;
19
+ private readonly _snippet: ScriptFuncOrBody<TypeOrmPerformFunc<In, InFragment, OutFragment>>;
20
+ private readonly _func: TypeOrmPerformFunc<In, InFragment, OutFragment>;
26
21
 
27
22
  public constructor(options: TypeOrmBySnippetPipelineStepOptions<In, Out, InFragment, OutFragment>) {
28
23
  super(options);
@@ -39,37 +34,26 @@ export class TypeOrmBySnippetPipelineStep<In = PipelineStepPayload, Out = Pipeli
39
34
  });
40
35
  }
41
36
 
42
- public getSnippet(): ScriptFuncOrBody<TypeOrmPerformFunc<InFragment, OutFragment>> {
37
+ public getSnippet(): ScriptFuncOrBody<TypeOrmPerformFunc<In, InFragment, OutFragment>> {
43
38
  return this._snippet;
44
39
  }
45
40
 
46
41
  protected generateVariableNames(): Array<string> {
47
42
  return [
48
43
  this.getRunnerVariableName(),
49
- this.isInFragmentIgnored() ? null : this.getInFragmentVariableName(),
44
+ this.getInFragmentVariableName(),
45
+ this.getRequestVariableName(),
50
46
  ...this.getHelpersVariableNames()
51
- ].filter(x => x != null);
47
+ ];
52
48
  }
53
49
 
54
50
  protected async doPerform(basis: InFragment, request: PipelineStepData<In>): Promise<OutFragment> {
55
51
  return await this.autoTrans<OutFragment>(async (runner) => {
56
52
  const $helpers = this.getHelpers();
57
- if (this.isInFragmentIgnored()) {
58
- return await (this._func as TypeOrmPerformWithoutInFragment<OutFragment>)(runner, $helpers, $helpers);
59
- } else {
60
- return await (this._func as TypeOrmPerformWithInFragment<InFragment, OutFragment>)(runner, basis, $helpers, $helpers);
61
- }
53
+ return await this._func(runner, basis, request, $helpers, $helpers);
62
54
  }, request);
63
55
  }
64
56
 
65
- /**
66
- * is request step data ignored to snippet function.
67
- * default returns false
68
- */
69
- protected isInFragmentIgnored(): boolean {
70
- return false;
71
- }
72
-
73
57
  protected getRunnerVariableName(): string {
74
58
  return '$runner';
75
59
  }
@@ -80,4 +64,8 @@ export class TypeOrmBySnippetPipelineStep<In = PipelineStepPayload, Out = Pipeli
80
64
  protected getInFragmentVariableName(): string {
81
65
  return '$factor';
82
66
  }
67
+
68
+ protected getRequestVariableName(): string {
69
+ return '$request';
70
+ }
83
71
  }