bellboy 6.4.0 → 6.5.0
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
|
@@ -340,7 +340,7 @@ For delimited data produces rows described [here](#delimited-produced-row).
|
|
|
340
340
|
If `true`, first row will be processed as a header.
|
|
341
341
|
- **qualifier** `string` `only for delimited`\
|
|
342
342
|
Symbol placed around a field to signify that it is the same field.
|
|
343
|
-
- **jsonPath** `RegExp`\
|
|
343
|
+
- **jsonPath** `RegExp | string`\
|
|
344
344
|
Path to the array to be streamed. This option is described in detail inside [JsonProcessor](#json-processor) section.
|
|
345
345
|
- **authorizationRequest** `object`
|
|
346
346
|
- **connection**\
|
|
@@ -446,10 +446,10 @@ Processes `JSON` files in the directory.
|
|
|
446
446
|
#### Options
|
|
447
447
|
|
|
448
448
|
- [Directory processor options](#directory-processor-options)
|
|
449
|
-
- **jsonPath** `RegExp`\
|
|
449
|
+
- **jsonPath** `RegExp | string`\
|
|
450
450
|
Path to the array to be streamed. Internally when JSON is streamed, current path is joined together using `.` as separator and then tested against provided regular expression. If not specified, a root array will be streamed. As an example, if you have this JSON object:\
|
|
451
451
|
`{ "animals": { "dogs": [ "pug", "bulldog", "poodle" ] } }`\
|
|
452
|
-
And want to stream `dogs` array, path you will need to use is `/animals.dogs.(\d+)
|
|
452
|
+
And want to stream `dogs` array, path you will need to use is `/animals.dogs.(\d+)/` if using RegExp as `jsonPath` and `animals.dogs.(\\d+)` if a string is used.\
|
|
453
453
|
`(\d+)` is used here because each index of the array is a number.
|
|
454
454
|
|
|
455
455
|
### DelimitedProcessor <div id='delimited-processor'/>
|
|
@@ -91,8 +91,13 @@ var HttpProcessor = /** @class */ (function (_super) {
|
|
|
91
91
|
_this.delimiter = config.delimiter;
|
|
92
92
|
_this.qualifier = config.qualifier;
|
|
93
93
|
}
|
|
94
|
-
else if (config.dataFormat === 'json') {
|
|
95
|
-
|
|
94
|
+
else if (config.dataFormat === 'json' && config.jsonPath) {
|
|
95
|
+
if (config.jsonPath instanceof RegExp) {
|
|
96
|
+
_this.jsonPath = config.jsonPath;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
_this.jsonPath = new RegExp(config.jsonPath);
|
|
100
|
+
}
|
|
96
101
|
}
|
|
97
102
|
_this.nextRequest = config.nextRequest;
|
|
98
103
|
_this.authorizationRequest = config.authorizationRequest;
|
|
@@ -64,7 +64,14 @@ var JsonProcessor = /** @class */ (function (_super) {
|
|
|
64
64
|
__extends(JsonProcessor, _super);
|
|
65
65
|
function JsonProcessor(config) {
|
|
66
66
|
var _this = _super.call(this, config) || this;
|
|
67
|
-
|
|
67
|
+
if (config.jsonPath) {
|
|
68
|
+
if (config.jsonPath instanceof RegExp) {
|
|
69
|
+
_this.jsonPath = config.jsonPath;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
_this.jsonPath = new RegExp(config.jsonPath);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
68
75
|
return _this;
|
|
69
76
|
}
|
|
70
77
|
JsonProcessor.prototype.process = function (processStream) {
|
package/lib/types.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export interface IHttpProcessorConfig extends IProcessorConfig {
|
|
|
89
89
|
}
|
|
90
90
|
export interface IJsonHttpProcessorConfig extends IHttpProcessorConfig {
|
|
91
91
|
dataFormat: 'json';
|
|
92
|
-
jsonPath?: RegExp;
|
|
92
|
+
jsonPath?: RegExp | string;
|
|
93
93
|
}
|
|
94
94
|
export interface IDelimitedHttpProcessorConfig extends IHttpProcessorConfig {
|
|
95
95
|
dataFormat: 'delimited';
|
|
@@ -103,7 +103,7 @@ export interface IDatabaseProcessorConfig extends IProcessorConfig {
|
|
|
103
103
|
query: string;
|
|
104
104
|
}
|
|
105
105
|
export interface IJsonProcessorConfig extends IDirectoryProcessorConfig {
|
|
106
|
-
jsonPath?: RegExp;
|
|
106
|
+
jsonPath?: RegExp | string;
|
|
107
107
|
}
|
|
108
108
|
export interface IDelimitedProcessorConfig extends IDirectoryProcessorConfig {
|
|
109
109
|
rowSeparator: string;
|