@rainbow-o23/n3 1.0.24 → 1.0.26

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/README.md CHANGED
@@ -589,8 +589,8 @@ step set. Additionally, nested transactions are also supported, which means Tran
589
589
  | `endpoints.SYSTEM.ENDPOINT.method` | string | POST | Endpoint http method. |
590
590
  | `endpoints.SYSTEM.ENDPOINT.headers` | string | | Endpoint request headers, use global headers if this parameter doesn't present.<br>Format follows `name=value[;name=value[...]]`. |
591
591
  | `endpoints.SYSTEM.global.headers` | string | | Endpoint system global request headers.<br>Format follows `name=value[;name=value[...]]`. |
592
- | `endpoints.SYSTEM.ENDPOINT.timeout` | string | | Endpoint request timeout, in milliseconds, use global timeout if this parameter doesn't present. |
593
- | `endpoints.SYSTEM.global.timeout` | string | -1 | Endpoint system global timeout, in milliseconds, `-1` represents no timeout. |
592
+ | `endpoints.SYSTEM.ENDPOINT.timeout` | string | | Endpoint request timeout, in seconds, use global timeout if this parameter doesn't present. |
593
+ | `endpoints.SYSTEM.global.timeout` | string | -1 | Endpoint system global timeout, in seconds, `-1` represents no timeout. |
594
594
  | `endpoints.SYSTEM.ENDPOINT.body.used` | boolean | true | Endpoint use request body or not. |
595
595
 
596
596
  `SYSTEM` represents endpoint system, `ENDPOINT` represents endpoint url. For example:
@@ -607,6 +607,8 @@ CFG_ENDPOINTS_ORDER_PAYMENT_URL=https://order.com/payment
607
607
  | endpointSystemCode | string | | Endpoint system code. |
608
608
  | endpointName | string | | Endpoint name. |
609
609
  | urlGenerate | ScriptFuncOrBody\<HttpGenerateUrl> | | Endpoint url generator, `$endpointUrl`. |
610
+ | method | string | | Http method. |
611
+ | timeout | number | | Endpoint timeout, in seconds. |
610
612
  | headersGenerate | ScriptFuncOrBody\<HttpGenerateHeaders> | | Endpoint request headers generator. |
611
613
  | bodyGenerate | ScriptFuncOrBody\<HttpGenerateBody> | | Endpoint request body generator. |
612
614
  | responseGenerate | ScriptFuncOrBody\<HttpGenerateResponse> | | Endpoint response body generator, `$response`. |
package/index.cjs CHANGED
@@ -1150,9 +1150,10 @@ class FetchPipelineStep extends AbstractFragmentaryPipelineStep {
1150
1150
  this._endpointName = options.endpointName;
1151
1151
  const endpointKey = this.getEndpointKey();
1152
1152
  this._endpointUrl = config.getString(`endpoints.${endpointKey}.url`);
1153
- this._endpointMethod = config.getString(`endpoints.${endpointKey}.method`, 'POST').toLowerCase();
1153
+ this._endpointMethod = ((options.method ?? '').trim() || config.getString(`endpoints.${endpointKey}.method`, 'POST')).toLowerCase();
1154
1154
  this._endpointHeaders = this.generateEndpointHeaders(config.getString(`endpoints.${endpointKey}.headers`), this.generateEndpointHeaders(config.getString(`endpoints.${this.getEndpointSystemCode()}.global.headers`)));
1155
- this._endpointTimeout = config.getNumber(`endpoints.${endpointKey}.timeout`)
1155
+ this._endpointTimeout = options.timeout
1156
+ ?? config.getNumber(`endpoints.${endpointKey}.timeout`)
1156
1157
  ?? config.getNumber(`endpoints.${this.getEndpointSystemCode()}.global.timeout`, -1);
1157
1158
  this._endpointTimeout = this._endpointTimeout > 0 ? this._endpointTimeout * 1000 : -1;
1158
1159
  this._urlGenerateSnippet = options.urlGenerate;
package/index.js CHANGED
@@ -1148,9 +1148,10 @@ class FetchPipelineStep extends AbstractFragmentaryPipelineStep {
1148
1148
  this._endpointName = options.endpointName;
1149
1149
  const endpointKey = this.getEndpointKey();
1150
1150
  this._endpointUrl = config.getString(`endpoints.${endpointKey}.url`);
1151
- this._endpointMethod = config.getString(`endpoints.${endpointKey}.method`, 'POST').toLowerCase();
1151
+ this._endpointMethod = ((options.method ?? '').trim() || config.getString(`endpoints.${endpointKey}.method`, 'POST')).toLowerCase();
1152
1152
  this._endpointHeaders = this.generateEndpointHeaders(config.getString(`endpoints.${endpointKey}.headers`), this.generateEndpointHeaders(config.getString(`endpoints.${this.getEndpointSystemCode()}.global.headers`)));
1153
- this._endpointTimeout = config.getNumber(`endpoints.${endpointKey}.timeout`)
1153
+ this._endpointTimeout = options.timeout
1154
+ ?? config.getNumber(`endpoints.${endpointKey}.timeout`)
1154
1155
  ?? config.getNumber(`endpoints.${this.getEndpointSystemCode()}.global.timeout`, -1);
1155
1156
  this._endpointTimeout = this._endpointTimeout > 0 ? this._endpointTimeout * 1000 : -1;
1156
1157
  this._urlGenerateSnippet = options.urlGenerate;
@@ -5,6 +5,8 @@ export interface FetchPipelineStepOptions<In = PipelineStepPayload, Out = Pipeli
5
5
  endpointSystemCode: string;
6
6
  endpointName: string;
7
7
  urlGenerate?: ScriptFuncOrBody<HttpGenerateUrl<In, InFragment>>;
8
+ method?: string;
9
+ timeout?: number;
8
10
  headersGenerate?: ScriptFuncOrBody<HttpGenerateHeaders<In, InFragment>>;
9
11
  bodyGenerate?: ScriptFuncOrBody<HttpGenerateBody<In, InFragment>>;
10
12
  responseGenerate?: ScriptFuncOrBody<HttpGenerateResponse<In, InFragment>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainbow-o23/n3",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
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",
24
+ "@rainbow-o23/n1": "1.0.26",
25
25
  "@theinternetfolks/snowflake": "^1.3.0",
26
26
  "node-fetch": "2.6.7",
27
27
  "typeorm": "^0.3.17"
@@ -19,6 +19,9 @@ export interface FetchPipelineStepOptions<In = PipelineStepPayload, Out = Pipeli
19
19
  endpointSystemCode: string;
20
20
  endpointName: string;
21
21
  urlGenerate?: ScriptFuncOrBody<HttpGenerateUrl<In, InFragment>>;
22
+ method?: string;
23
+ /** on seconds */
24
+ timeout?: number;
22
25
  headersGenerate?: ScriptFuncOrBody<HttpGenerateHeaders<In, InFragment>>;
23
26
  bodyGenerate?: ScriptFuncOrBody<HttpGenerateBody<In, InFragment>>;
24
27
  responseGenerate?: ScriptFuncOrBody<HttpGenerateResponse<In, InFragment>>;
@@ -53,12 +56,13 @@ export class FetchPipelineStep<In = PipelineStepPayload, Out = PipelineStepPaylo
53
56
  this._endpointName = options.endpointName;
54
57
  const endpointKey = this.getEndpointKey();
55
58
  this._endpointUrl = config.getString(`endpoints.${endpointKey}.url`);
56
- this._endpointMethod = config.getString(`endpoints.${endpointKey}.method`, 'POST').toLowerCase();
59
+ this._endpointMethod = ((options.method ?? '').trim() || config.getString(`endpoints.${endpointKey}.method`, 'POST')).toLowerCase();
57
60
  this._endpointHeaders = this.generateEndpointHeaders(
58
61
  config.getString(`endpoints.${endpointKey}.headers`),
59
62
  this.generateEndpointHeaders(config.getString(`endpoints.${this.getEndpointSystemCode()}.global.headers`)));
60
63
  // in second
61
- this._endpointTimeout = config.getNumber(`endpoints.${endpointKey}.timeout`)
64
+ this._endpointTimeout = options.timeout
65
+ ?? config.getNumber(`endpoints.${endpointKey}.timeout`)
62
66
  ?? config.getNumber(`endpoints.${this.getEndpointSystemCode()}.global.timeout`, -1);
63
67
  // to millisecond
64
68
  this._endpointTimeout = this._endpointTimeout > 0 ? this._endpointTimeout * 1000 : -1;