@cobol-ts/file-display 0.0.0-stage → 0.0.1
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 +53 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/package.json +65 -3
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cobol-ts/file-display
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Streams JSON Lines from a physical COBOL file using an in-memory default projection. It does **not** import, compile or execute generated TypeScript. The projection is constructed from the copybook AST, and the existing byte-backed COBOL reader supplies values.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
The two relevant files live in the discovered `.cobolts` directory. `generation.yaml` is not used by display.
|
|
8
|
+
|
|
9
|
+
`.cobolts/files.yaml`:
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
root: ../copybooks
|
|
13
|
+
files:
|
|
14
|
+
customers:
|
|
15
|
+
type: cobol
|
|
16
|
+
copybook: CUSTOMER.cpy
|
|
17
|
+
options:
|
|
18
|
+
framing:
|
|
19
|
+
kind: fixed
|
|
20
|
+
recordLength: 45
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`.cobolts/data.yaml`:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
root: ../data
|
|
27
|
+
files:
|
|
28
|
+
customers: customers.fb
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Both roots are interpreted relative to `.cobolts` (absolute roots are also accepted). A `files` entry is a logical-name-to-filename binding; it can be partial, and it cannot escape its data root. An explicit `input` option overrides the binding and is interpreted relative to the caller's working directory if not absolute.
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import {openFileDisplay} from '@cobol-ts/file-display'
|
|
37
|
+
import {valueOrThrow} from '@cobol-ts/errors'
|
|
38
|
+
|
|
39
|
+
const stream = valueOrThrow(await openFileDisplay({
|
|
40
|
+
configDirectory: '/path/to/project/.cobolts',
|
|
41
|
+
logicalName: 'customers',
|
|
42
|
+
count: 10
|
|
43
|
+
}))
|
|
44
|
+
console.log(stream.filename)
|
|
45
|
+
for await (const line of stream.lines) console.log(line)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`openFileDisplay()` returns `Promise<ErrorsOr<DisplayStream>>`; `DisplayStream.lines` is a one-pass `AsyncIterable<string>`. Each string is one JSON object without a trailing newline. The library writes no headers, and does not buffer the file's records in memory. It closes every borrowed cursor result even when iteration stops early.
|
|
49
|
+
|
|
50
|
+
The default count is 10. Use `all: true` to remove that limit and `skip` to ignore leading records. `all` and an explicit `count` cannot be combined. Values retain the reader's string padding; they are not silently trimmed. ODO arrays contain only active occurrences and REDEFINES alternatives are independently accessible in the JSON object.
|
|
51
|
+
|
|
52
|
+
Currently `display` supports COBOL. CSV and JSONL can be bound in `data.yaml`, but attempting to display those formats returns an explicit unsupported-format error until their readers are integrated.
|
|
53
|
+
|
|
54
|
+
The Node reader is imported as TypeScript source to support the monorepo's direct-TS execution without requiring `dist/node.js` wrappers. This package uses only normal static imports.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/file.display"), exports);
|
|
18
|
+
__exportStar(require("./src/projection.json"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/file-display",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Stream JSONL from configured COBOL data files using an in-memory default projection",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"types": "dist/index",
|
|
7
|
+
"browserslist": {
|
|
8
|
+
"development": [
|
|
9
|
+
"last 1 chrome version",
|
|
10
|
+
"last 1 firefox version",
|
|
11
|
+
"last 1 safari version"
|
|
12
|
+
],
|
|
13
|
+
"production": [
|
|
14
|
+
">0.2%",
|
|
15
|
+
"not dead",
|
|
16
|
+
"not op_mini all"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@cobol-ts/copybook": "0.0.1",
|
|
21
|
+
"@cobol-ts/cursor-loader-cobol": "0.0.1",
|
|
22
|
+
"@cobol-ts/cursor-loader-types": "0.0.1",
|
|
23
|
+
"@cobol-ts/cursor-projection": "0.0.1",
|
|
24
|
+
"@cobol-ts/default-projection-typescript": "0.0.1",
|
|
25
|
+
"@cobol-ts/errors": "0.0.1",
|
|
26
|
+
"@cobol-ts/file-catalogue": "0.0.1",
|
|
27
|
+
"@cobol-ts/files": "0.0.1"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@testing-library/jest-dom": "^6.1.4",
|
|
31
|
+
"@types/jest": "^29.0.0",
|
|
32
|
+
"@types/node": "^14.0.0",
|
|
33
|
+
"jest": "^29.0.0",
|
|
34
|
+
"ts-jest": "^29.0.0",
|
|
35
|
+
"typescript": "^5.2.2"
|
|
36
|
+
},
|
|
37
|
+
"eslintConfig": {
|
|
38
|
+
"extends": [
|
|
39
|
+
"react-app",
|
|
40
|
+
"react-app/jest"
|
|
41
|
+
],
|
|
42
|
+
"overrides": [
|
|
43
|
+
{
|
|
44
|
+
"files": [
|
|
45
|
+
"**/*.stories.*"
|
|
46
|
+
],
|
|
47
|
+
"rules": {
|
|
48
|
+
"import/no-anonymous-default-export": "off"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist/index.js",
|
|
55
|
+
"dist/index.d.ts",
|
|
56
|
+
"dist/src/",
|
|
57
|
+
"build/"
|
|
58
|
+
],
|
|
59
|
+
"keywords": [
|
|
60
|
+
"indexing"
|
|
61
|
+
],
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"repository": "git@github.com:intellimaintain/intellimaintain.git",
|
|
64
|
+
"scripts": {
|
|
65
|
+
"test": "jest --config jest.config.json --env node",
|
|
66
|
+
"test:watch": "npm run test -- --watch"
|
|
67
|
+
}
|
|
6
68
|
}
|