@t4h.framework/transforms 0.0.0-experimental-20260907052843

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.
@@ -0,0 +1,123 @@
1
+ ---
2
+ name: framework-transforms
3
+ description: >-
4
+ Guides correct use of @t4h.framework/transforms in workflows: converting a
5
+ JSON document (an array of records, possibly nested inside an envelope) into
6
+ NDJSON so it can be fanned out with `split` from @t4h.framework/fs. Use
7
+ whenever a workflow receives a JSON batch file that is NOT NDJSON — an API
8
+ response or uploaded file shaped like `{ "a": { "b": [ ...records ] } }` —
9
+ and each record must become its own workflow run, or when the user mentions
10
+ converting JSON to NDJSON, splitting a JSON array, a records envelope, or
11
+ the symbols `json`, `Json`, `toNDJson`, `JsonToNDJsonActivity`. Prefer this
12
+ skill over parsing JSON in workflow code or hand-rolling delimiters over
13
+ JSON text.
14
+ ---
15
+
16
+ # @t4h.framework/transforms
17
+
18
+ Format conversions for workflow files. Package path:
19
+ `framework/packages/transforms`. Peer dependencies: `@t4h.framework/core`,
20
+ `@t4h.framework/fs`.
21
+
22
+ ## Import surface
23
+
24
+ ```typescript
25
+ import { json, Json, JsonToNDJsonActivity } from '@t4h.framework/transforms'
26
+ ```
27
+
28
+ `json(binary, options)` is the entry point: it captures the source document
29
+ and returns a `Json` value whose `.toX()` methods run the actual transform —
30
+ today `toNDJson()`, each future target (`toCsv`, ...) being one more method.
31
+ Only the `.toX()` call does work; `json(...)` itself is synchronous and free.
32
+
33
+ ## Workflow usage
34
+
35
+ The canonical pipeline — download a JSON batch file, normalize it to NDJSON,
36
+ fan it out one workflow per record:
37
+
38
+ ```typescript
39
+ import { split, Split } from '@t4h.framework/fs'
40
+ import { request } from '@t4h.framework/http'
41
+ import { json } from '@t4h.framework/transforms'
42
+
43
+ const main = new Workflow(inputSchema, async ({ url }) => {
44
+ const response = await request({ url })
45
+
46
+ // { "registros": { "registro": [ {...}, {...} ] } }
47
+ const ndjson = await json(response.body.binary, {
48
+ path: 'registros.registro',
49
+ }).toNDJson()
50
+
51
+ return await split(ndjson, processRecord, { delimiter: Split.line() })
52
+ })
53
+ ```
54
+
55
+ Each child workflow receives one record as a raw JSON line (`Type.String()`
56
+ input, `JSON.parse` it) — see the **framework-fs-split** skill for the
57
+ `split`/`join` side.
58
+
59
+ ## `json(binary, options).toNDJson()`
60
+
61
+ ```typescript
62
+ function json(binary: Binary, options?: JsonOptions): Json
63
+ Json.prototype.toNDJson(): Promise<Binary>
64
+ ```
65
+
66
+ `toNDJson()` rewrites the document as NDJSON — one line per element of the
67
+ target array — and resolves with the `Binary` of the new file. Only that
68
+ reference reaches workflow history; the content never does.
69
+
70
+ | Option | Default | Behavior |
71
+ | ---------- | ------- | ---------------------------------------------------------------------------------------------- |
72
+ | `path` | — | Dot path to the array of records (`'registros.registro'`). Omit when the document root is the array. |
73
+ | `encoding` | `utf8` | Encoding used to decode the source binary before parsing. |
74
+
75
+ Behaviors you can rely on:
76
+
77
+ - **Formatting-agnostic.** Minified, pretty-printed, arbitrary whitespace and
78
+ BOM-prefixed documents all produce identical output. Values containing
79
+ `"},{"`, escaped quotes, or nested structures are preserved exactly —
80
+ records are re-serialized, never text-sliced.
81
+ - **Any element type.** Array elements may be objects, arrays or scalars;
82
+ each becomes one `JSON.stringify`'d line. An empty array yields an empty
83
+ (zero-line) file, which `split` resolves as an empty batch.
84
+ - **Fail-fast on shape mismatches.** `toNDJson()` rejects with a `TypeError`
85
+ when the `path` cannot be resolved or does not land on an array, and with a
86
+ `SyntaxError` on invalid JSON. There is no partial output.
87
+
88
+ ## Limits
89
+
90
+ The source document is parsed **in memory** inside the activity — fits files
91
+ up to tens of megabytes comfortably. For gigabyte-scale JSON a streaming
92
+ scanner would be needed; this package does not provide one today.
93
+
94
+ ## Runtime requirements
95
+
96
+ - Claim provider: `FileSystemClaim` (from `@t4h.framework/fs`).
97
+ - Production whitelist: register `JsonToNDJsonActivity` via
98
+ `runtime.addActivity`.
99
+
100
+ ## Anti-patterns
101
+
102
+ - **Parsing the batch file in workflow code.** `response.body.json()` is for
103
+ small API payloads: on a batch file it re-reads and re-parses the whole
104
+ document on every replay and holds it in workflow memory. Normalize with
105
+ `toNDJson()` and fan out with `split` instead.
106
+ - **Hand-rolling delimiters over JSON text.** `Split.char('},{')` over a JSON
107
+ document breaks on formatting changes and on values containing structural
108
+ characters. JSON is parsed, never text-split.
109
+ - **Expecting records in the workflow.** The transform resolves with a
110
+ `Binary` reference; records only materialize inside each child workflow run
111
+ started by `split`.
112
+ - **Iterating records and calling `startWorkflow` per item.** That pushes N
113
+ entries into parent history; `split` keeps it O(1). See
114
+ **framework-fs-split**.
115
+
116
+ ## Related skills
117
+
118
+ - `framework-fs-split` — `split`/`join`/`read`: fanning the NDJSON out into a
119
+ batch of workflows and folding results back.
120
+ - `framework-http` — downloading the source file; `response.body.binary` is
121
+ the natural input to `json(...)`.
122
+ - `framework-workflow-testing` — the harness for testing workflows that use
123
+ this pipeline.
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # @t4h.framework/transforms
2
+
3
+ ## 0.0.0-experimental-20260907052843
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`a30386e`](https://github.com/tech4humans-brasil/framework/commit/a30386ebf832d1eec5989b0a12a56d91a6999421)]:
8
+ - @t4h.framework/core@0.0.0-experimental-20260907052843
9
+ - @t4h.framework/fs@0.0.0-experimental-20260907052843
10
+
11
+ ## 0.1.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Re-releases the accidental `1.0.0` as a patch. `1.0.0` was published by mistake (changesets bumps peer dependents with a major when a peer dependency gets a minor bump); this package stays on the `0.x` line.
16
+ - Updated dependencies [[`8c56f76`](https://github.com/tech4humans-brasil/framework/commit/8c56f7697390a1ea966d1e91ff5f35ce5751a0d7), [`8c56f76`](https://github.com/tech4humans-brasil/framework/commit/8c56f7697390a1ea966d1e91ff5f35ce5751a0d7)]:
17
+ - @t4h.framework/fs@0.8.0
18
+
19
+ ## 0.1.1
20
+
21
+ ### Patch Changes
22
+
23
+ - [`095c3a9`](https://github.com/tech4humans-brasil/framework/commit/095c3a91191b9f541519447f212a8e9509065569) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Republish with resolved dependency versions. The previous release leaked the `workspace:^` protocol into the published manifests, breaking installs outside the monorepo.
24
+
25
+ ## 0.1.0
26
+
27
+ ### Minor Changes
28
+
29
+ - [`34698e3`](https://github.com/tech4humans-brasil/framework/commit/34698e34d0dc7f28a1e790d95d596a67d23e0c2e) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Initialize package
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @t4h.framework/transforms
2
+
3
+ Data transform activities for workflows.
4
+
5
+ ## JSON to NDJSON
6
+
7
+ Rewrites a JSON document into NDJSON — one record per line — so it can be
8
+ consumed by line-oriented activities such as `split` from
9
+ `@t4h.framework/fs`. The transform is formatting-agnostic: minified,
10
+ pretty-printed and BOM-prefixed documents all produce the same output.
11
+
12
+ ```typescript
13
+ import { split, Split } from '@t4h.framework/fs'
14
+ import { json } from '@t4h.framework/transforms'
15
+
16
+ // { "registros": { "registro": [{ ... }, { ... }] } }
17
+ const ndjson = await json(response.body.binary, {
18
+ path: 'registros.registro',
19
+ }).toNDJson()
20
+
21
+ const batch = await split(ndjson, registroWorkflow, {
22
+ delimiter: Split.line(),
23
+ })
24
+ ```
25
+
26
+ Omit `path` when the document root is the array itself. `json` captures the
27
+ source document and its options; each `.toX()` method runs a dedicated
28
+ transform activity, leaving room for other targets (`toCsv`, ...) later.
29
+
30
+ ### Options
31
+
32
+ | Option | Default | Description |
33
+ | ---------- | ------- | -------------------------------------------------- |
34
+ | `path` | — | Dot path to the array of records (`a.b.c`) |
35
+ | `encoding` | `utf8` | Encoding used to decode the source binary |
36
+
37
+ ### Limits
38
+
39
+ The source document is parsed in memory, so this activity fits files up to
40
+ tens of megabytes. Only the resulting `Binary` reference crosses the
41
+ activity boundary — the content itself never enters the workflow history.
42
+
43
+ Peer dependencies: `@t4h.framework/core`, `@t4h.framework/fs`.
@@ -0,0 +1,13 @@
1
+ import { type Binary, SyncActivity } from '@t4h.framework/core';
2
+ import type { JsonOptions } from '../json.js';
3
+ export type JsonToNDJsonActivityInput = {
4
+ binary: Binary;
5
+ options: JsonOptions;
6
+ };
7
+ export declare class JsonToNDJsonActivity extends SyncActivity<readonly [binary: Binary, options: JsonOptions], JsonToNDJsonActivityInput, Binary, Binary> {
8
+ private readonly claims;
9
+ toInput(binary: Binary, options: JsonOptions): JsonToNDJsonActivityInput;
10
+ run({ binary, options, }: JsonToNDJsonActivityInput): Promise<Binary>;
11
+ toOutput(output: Binary): Binary;
12
+ }
13
+ //# sourceMappingURL=JsonToNDJsonActivity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonToNDJsonActivity.d.ts","sourceRoot":"","sources":["../../src/activities/JsonToNDJsonActivity.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAS,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAUtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,WAAW,CAAA;CACrB,CAAA;AAED,qBAAa,oBAAqB,SAAQ,YAAY,CACpD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,EAC/C,yBAAyB,EACzB,MAAM,EACN,MAAM,CACP;IACC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAErB;IAEK,OAAO,CACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,GACnB,yBAAyB;IAIf,GAAG,CAAC,EACf,MAAM,EACN,OAAO,GACR,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAGxC"}
@@ -0,0 +1,135 @@
1
+ import { Readable } from 'node:stream';
2
+ import { StringDecoder } from 'node:string_decoder';
3
+ import { Claim, SyncActivity } from '@t4h.framework/core';
4
+ import { FileSystemClaim } from '@t4h.framework/fs';
5
+ import chain from 'stream-chain';
6
+ import { none } from 'stream-chain/defs.js';
7
+ import { parser } from 'stream-json/parser.js';
8
+ import { streamArray, } from 'stream-json/streamers/stream-array.js';
9
+ export class JsonToNDJsonActivity extends SyncActivity {
10
+ claims = new Claim({
11
+ fs: FileSystemClaim,
12
+ });
13
+ toInput(binary, options) {
14
+ return { binary, options };
15
+ }
16
+ async run({ binary, options, }) {
17
+ const encoding = options.encoding ?? 'utf8';
18
+ const records = chain([
19
+ Readable.from(decode(await binary.stream(), encoding)),
20
+ parser({ packValues: true, streamValues: false }),
21
+ navigate(options.path),
22
+ streamArray(),
23
+ ]);
24
+ return await this.claims.fs.write(`transform/${this.id}.ndjson`, Readable.from(toLines(records)));
25
+ }
26
+ toOutput(output) {
27
+ return output;
28
+ }
29
+ }
30
+ async function* decode(source, encoding) {
31
+ const decoder = new StringDecoder(encoding);
32
+ let first = true;
33
+ for await (const chunk of source) {
34
+ let text = decoder.write(chunk);
35
+ if (first && text) {
36
+ first = false;
37
+ // external producers often prepend a byte order mark
38
+ if (text.charCodeAt(0) === 0xfeff)
39
+ text = text.slice(1);
40
+ }
41
+ if (text)
42
+ yield text;
43
+ }
44
+ const rest = decoder.end();
45
+ if (rest)
46
+ yield rest;
47
+ }
48
+ function navigate(path) {
49
+ const segments = path ? path.split('.') : [];
50
+ let mode = 'root';
51
+ let index = 0;
52
+ let depth = 0;
53
+ let matches = false;
54
+ const notArray = () => new TypeError(path
55
+ ? `Expected an array at "${path}" in the JSON document`
56
+ : 'Expected the JSON document root to be an array');
57
+ const unresolvable = (length) => new TypeError(`Could not resolve "${segments.slice(0, length).join('.')}" in the JSON document`);
58
+ return token => {
59
+ switch (mode) {
60
+ case 'root':
61
+ if (segments.length === 0) {
62
+ if (token.name !== 'startArray')
63
+ throw notArray();
64
+ mode = 'forward';
65
+ depth = 1;
66
+ return token;
67
+ }
68
+ if (token.name !== 'startObject')
69
+ throw unresolvable(1);
70
+ mode = 'key';
71
+ return none;
72
+ case 'key':
73
+ if (token.name === 'endObject')
74
+ throw index === segments.length - 1
75
+ ? notArray()
76
+ : unresolvable(index + 2);
77
+ matches = token.name === 'keyValue' && token.value === segments[index];
78
+ mode = 'value';
79
+ return none;
80
+ case 'value':
81
+ if (!matches) {
82
+ if (token.name === 'startObject' || token.name === 'startArray') {
83
+ mode = 'skip';
84
+ depth = 1;
85
+ }
86
+ else {
87
+ mode = 'key';
88
+ }
89
+ return none;
90
+ }
91
+ if (index === segments.length - 1) {
92
+ if (token.name !== 'startArray')
93
+ throw notArray();
94
+ mode = 'forward';
95
+ depth = 1;
96
+ return token;
97
+ }
98
+ if (token.name !== 'startObject')
99
+ throw unresolvable(index + 2);
100
+ index += 1;
101
+ mode = 'key';
102
+ return none;
103
+ case 'skip':
104
+ if (token.name === 'startObject' || token.name === 'startArray')
105
+ depth += 1;
106
+ else if (token.name === 'endObject' || token.name === 'endArray')
107
+ depth -= 1;
108
+ if (depth === 0)
109
+ mode = 'key';
110
+ return none;
111
+ case 'forward':
112
+ if (token.name === 'startObject' || token.name === 'startArray')
113
+ depth += 1;
114
+ else if (token.name === 'endObject' || token.name === 'endArray')
115
+ depth -= 1;
116
+ if (depth === 0)
117
+ mode = 'done';
118
+ return token;
119
+ case 'done':
120
+ return none;
121
+ }
122
+ };
123
+ }
124
+ async function* toLines(records) {
125
+ try {
126
+ for await (const { value } of records)
127
+ yield JSON.stringify(value) + '\n';
128
+ }
129
+ catch (error) {
130
+ throw error instanceof Error && error.message.startsWith('Parser')
131
+ ? new SyntaxError(error.message)
132
+ : error;
133
+ }
134
+ }
135
+ //# sourceMappingURL=JsonToNDJsonActivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonToNDJsonActivity.js","sourceRoot":"","sources":["../../src/activities/JsonToNDJsonActivity.ts"],"names":[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OAAuC;IAC7D,IAAI,CAAC;QACH,IAAI,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,OAAO;YAAE,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;IAC3E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAChE,CAAC,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC;YAChC,CAAC,CAAC,KAAK,CAAA;IACX,CAAC;AACH,CAAC"}
package/dist/json.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { type Binary } from '@t4h.framework/core';
2
+ export type JsonOptions = {
3
+ path?: string;
4
+ encoding?: BufferEncoding;
5
+ };
6
+ export declare class Json {
7
+ readonly binary: Binary;
8
+ readonly options: JsonOptions;
9
+ constructor(binary: Binary, options: JsonOptions);
10
+ toNDJson(): Promise<Binary>;
11
+ }
12
+ export declare function json(binary: Binary, options?: JsonOptions): Json;
13
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,qBAAqB,CAAA;AAI1D,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,cAAc,CAAA;CAC1B,CAAA;AAED,qBAAa,IAAI;aAEG,MAAM,EAAE,MAAM;aACd,OAAO,EAAE,WAAW;gBADpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW;IAGzB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAOzC;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEpE"}
package/dist/json.js ADDED
@@ -0,0 +1,17 @@
1
+ import { History } from '@t4h.framework/core';
2
+ import { JsonToNDJsonActivity } from './activities/JsonToNDJsonActivity.js';
3
+ export class Json {
4
+ binary;
5
+ options;
6
+ constructor(binary, options) {
7
+ this.binary = binary;
8
+ this.options = options;
9
+ }
10
+ async toNDJson() {
11
+ return await History.reconciler(JsonToNDJsonActivity, this.binary, this.options);
12
+ }
13
+ }
14
+ export function json(binary, options = {}) {
15
+ return new Json(binary, options);
16
+ }
17
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAO3E,MAAM,OAAO,IAAI;IAEG;IACA;IAFlB,YACkB,MAAc,EACd,OAAoB;QADpB,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAAa;IACnC,CAAC;IAEG,KAAK,CAAC,QAAQ;QACnB,OAAO,MAAM,OAAO,CAAC,UAAU,CAC7B,oBAAoB,EACpB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACb,CAAA;IACH,CAAC;CACF;AAED,MAAM,UAAU,IAAI,CAAC,MAAc,EAAE,UAAuB,EAAE;IAC5D,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAClC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './activities/JsonToNDJsonActivity.js';
2
+ export * from './json.js';
3
+ //# sourceMappingURL=transforms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,WAAW,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './activities/JsonToNDJsonActivity.js';
2
+ export * from './json.js';
3
+ //# sourceMappingURL=transforms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transforms.js","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,WAAW,CAAA"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@t4h.framework/transforms",
3
+ "version": "0.0.0-experimental-20260907052843",
4
+ "description": "Data transform activities for the T4H Framework",
5
+ "homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/transforms",
6
+ "bugs": "https://github.com/tech4humans-brasil/framework/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/tech4humans-brasil/framework.git",
10
+ "directory": "packages/transforms"
11
+ },
12
+ "license": "MIT",
13
+ "author": "Tech4Humans <contact@tech4h.com.br> (https://tech4h.com.br)",
14
+ "type": "module",
15
+ "exports": {
16
+ "types": "./dist/transforms.d.ts",
17
+ "import": "./dist/transforms.js"
18
+ },
19
+ "module": "./dist/transforms.js",
20
+ "types": "./dist/transforms.d.ts",
21
+ "files": [
22
+ "dist",
23
+ "LICENSE",
24
+ ".ai"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc --project tsconfig.build.json",
28
+ "check-types": "tsc --noEmit",
29
+ "lint": "eslint .",
30
+ "prepublishOnly": "yarn build",
31
+ "test": "vitest run",
32
+ "test:watch": "vitest"
33
+ },
34
+ "devDependencies": {
35
+ "@t4h.framework/core": "^0.0.0-experimental-20260907052843",
36
+ "@t4h.framework/fs": "^0.0.0-experimental-20260907052843",
37
+ "typescript": "^5.9.3",
38
+ "vitest": "^4.0.18"
39
+ },
40
+ "peerDependencies": {
41
+ "@t4h.framework/core": "^0.0.0-experimental-20260907052843",
42
+ "@t4h.framework/fs": "^0.0.0-experimental-20260907052843"
43
+ },
44
+ "packageManager": "yarn@4.12.0",
45
+ "engines": {
46
+ "node": ">=22"
47
+ },
48
+ "dependencies": {
49
+ "stream-chain": "^4.2.5",
50
+ "stream-json": "^3.5.0"
51
+ }
52
+ }