@cobol-ts/cursor-file 0.0.4 → 0.0.6
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/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/src/cursor.file.callback.spec.d.ts +1 -0
- package/dist/src/cursor.file.callback.spec.js +41 -0
- package/dist/src/cursor.file.callback.spec.js.map +1 -0
- package/dist/src/cursor.file.d.ts +59 -0
- package/dist/src/cursor.file.fixture.d.ts +25 -0
- package/dist/src/cursor.file.fixture.js +143 -0
- package/dist/src/cursor.file.fixture.js.map +1 -0
- package/dist/src/cursor.file.js +194 -0
- package/dist/src/cursor.file.js.map +1 -0
- package/dist/src/cursor.file.node.d.ts +12 -0
- package/dist/src/cursor.file.node.js +24 -0
- package/dist/src/cursor.file.node.js.map +1 -0
- package/dist/src/cursor.file.node.spec.d.ts +1 -0
- package/dist/src/cursor.file.node.spec.js +23 -0
- package/dist/src/cursor.file.node.spec.js.map +1 -0
- package/dist/src/cursor.file.result.d.ts +77 -0
- package/dist/src/cursor.file.result.js +82 -0
- package/dist/src/cursor.file.result.js.map +1 -0
- package/dist/src/cursor.file.result.spec.d.ts +1 -0
- package/dist/src/cursor.file.result.spec.js +220 -0
- package/dist/src/cursor.file.result.spec.js.map +1 -0
- package/dist/src/cursor.files.spec.d.ts +1 -0
- package/dist/src/cursor.files.spec.js +127 -0
- package/dist/src/cursor.files.spec.js.map +1 -0
- package/package.json +4 -4
- package/node.d.ts +0 -1
- package/node.js +0 -2
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/cursor.file"), exports);
|
|
18
|
+
__exportStar(require("./src/cursor.file.result"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,2DAAwC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cursor_file_1 = require("./cursor.file");
|
|
4
|
+
const cursor_file_fixture_1 = require("./cursor.file.fixture");
|
|
5
|
+
test('callback receives borrowed projections, and the cursor releases them automatically', async () => {
|
|
6
|
+
const data = (0, cursor_file_fixture_1.createTestFile)('ABA');
|
|
7
|
+
const names = [];
|
|
8
|
+
let retained;
|
|
9
|
+
await (0, cursor_file_1.scanThrowingFileCursor)(cursor_file_fixture_1.customerFileDefinition, data, (0, cursor_file_fixture_1.createTestInfrastructure)(), row => {
|
|
10
|
+
names.push(row.name());
|
|
11
|
+
retained = row;
|
|
12
|
+
});
|
|
13
|
+
expect(names).toEqual(['Alice', 'Bob', 'Alice']);
|
|
14
|
+
expect(() => retained.name()).toThrow(/not bound/i);
|
|
15
|
+
});
|
|
16
|
+
test('callback can stop without visiting the remaining records', async () => {
|
|
17
|
+
const data = (0, cursor_file_fixture_1.createTestFile)('ABABA');
|
|
18
|
+
const names = [];
|
|
19
|
+
await (0, cursor_file_1.scanThrowingFileCursor)(cursor_file_fixture_1.customerFileDefinition, data, (0, cursor_file_fixture_1.createTestInfrastructure)(), row => {
|
|
20
|
+
names.push(row.name());
|
|
21
|
+
return false;
|
|
22
|
+
});
|
|
23
|
+
expect(names).toEqual(['Alice']);
|
|
24
|
+
});
|
|
25
|
+
test('callback errors terminate scan and release the borrowed row', async () => {
|
|
26
|
+
const data = (0, cursor_file_fixture_1.createTestFile)('!AB');
|
|
27
|
+
await expect((0, cursor_file_1.scanThrowingFileCursor)(cursor_file_fixture_1.customerFileDefinition, data, (0, cursor_file_fixture_1.createTestInfrastructure)(), () => { throw new Error('callback should not run'); })).rejects.toMatchObject({
|
|
28
|
+
name: 'ErrorsException', errors: ['bad row']
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
test('accepts an injected record pool on the callback path', async () => {
|
|
32
|
+
const { createSimpleRecordPool } = require('@cobol-ts/cursor-record');
|
|
33
|
+
const pool = createSimpleRecordPool();
|
|
34
|
+
const infrastructure = { ...(0, cursor_file_fixture_1.createTestInfrastructure)(), recordPool: pool };
|
|
35
|
+
const names = [];
|
|
36
|
+
await (0, cursor_file_1.scanThrowingFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)('ABA'), infrastructure, row => {
|
|
37
|
+
names.push(row.name());
|
|
38
|
+
});
|
|
39
|
+
expect(names).toEqual(['Alice', 'Bob', 'Alice']);
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=cursor.file.callback.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.file.callback.spec.js","sourceRoot":"","sources":["../../src/cursor.file.callback.spec.ts"],"names":[],"mappings":";;AAAA,+CAAqD;AAC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AAM,CAAC,IAAA,oCAAsB,EAAC,4CAAsB,EAAC,IAAI,EAAC,IAAA,8CAAwB,GAAE,EACtF,GAAE,EAAE,GAAC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;QAC1E,IAAI,EAAC,iBAAiB,EAAE,MAAM,EAAC,CAAC,SAAS,CAAC;KAC7C,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;IACpE,MAAM,EAAC,sBAAsB,EAAC,GAAG,OAAO,CAAC,yBAAyB,CAA6C,CAAC;IAChH,MAAM,IAAI,GAAG,sBAAsB,EAAO,CAAC;IAC3C,MAAM,cAAc,GAAG,EAAC,GAAG,IAAA,8CAAwB,GAAE,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;IACzE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,IAAA,oCAAsB,EAAC,4CAAsB,EAAE,IAAA,oCAAc,EAAC,KAAK,CAAC,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE;QAC9F,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAC,KAAK,EAAC,OAAO,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type Errors, type ErrorsOr } from "@cobol-ts/errors";
|
|
2
|
+
import { type CanonicalProjection, type FillFileBuffer, type ParserRegistry, type ProjectionDefinition } from "@cobol-ts/cursor-loader-types";
|
|
3
|
+
import { type RecordObjectPool } from "@cobol-ts/cursor-record";
|
|
4
|
+
import { type FileCursorResult } from "./cursor.file.result";
|
|
5
|
+
import { type IPutMetrics } from "@cobol-ts/metrics";
|
|
6
|
+
export interface CursorFileDefinition<TProjection, TFileType extends string> {
|
|
7
|
+
readonly filename: string;
|
|
8
|
+
readonly fileType: TFileType;
|
|
9
|
+
readonly projection: CanonicalProjection<ProjectionDefinition<TProjection>>;
|
|
10
|
+
}
|
|
11
|
+
export interface FileCursorInfrastructure<TFile, TFileType extends string> {
|
|
12
|
+
readonly parsers: ParserRegistry<TFileType>;
|
|
13
|
+
readonly bufferSize: number;
|
|
14
|
+
readonly fillFileBuffer: FillFileBuffer<TFile>;
|
|
15
|
+
/** Physical record-object pool; independent of the shared byte-buffer pool. */
|
|
16
|
+
readonly recordPool?: RecordObjectPool<any>;
|
|
17
|
+
/** Shared buffers must support retain/release for records crossing boundaries. */
|
|
18
|
+
readonly byteBufferPool?: import("@cobol-ts/cursor-loader-types").FileBufferPool;
|
|
19
|
+
readonly metrics?: IPutMetrics;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Callback alternative to createThrowingFileCursor.
|
|
23
|
+
*
|
|
24
|
+
* The callback receives the projected row, not a lease. Its lifetime ends
|
|
25
|
+
* when the callback returns, so callers must not retain it or await inside
|
|
26
|
+
* the callback. Returning false stops iteration (e.g. during warm-up).
|
|
27
|
+
*
|
|
28
|
+
* Unlike an async generator, the file cursor can process buffered records
|
|
29
|
+
* synchronously when the parser implements parseBuffered(). Projection and
|
|
30
|
+
* physical-record objects are pooled/reused throughout the scan.
|
|
31
|
+
*/
|
|
32
|
+
export declare function scanThrowingFileCursor<TProjection, TFile, TFileType extends string>(definition: CursorFileDefinition<TProjection, TFileType>, file: TFile, infrastructure: FileCursorInfrastructure<TFile, TFileType>, onRecord: (record: TProjection) => void | boolean): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Return successful projected rows directly.
|
|
35
|
+
*
|
|
36
|
+
* Recoverable row parser errors are returned as string[].
|
|
37
|
+
*
|
|
38
|
+
* Configuration, parser preparation and projection configuration failures
|
|
39
|
+
* throw before the data-row run.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createFileCursor<TProjection, TFile, TFileType extends string>(definition: CursorFileDefinition<TProjection, TFileType>, file: TFile, infrastructure: FileCursorInfrastructure<TFile, TFileType>): AsyncGenerator<FileCursorResult<TProjection> | string[], void, void>;
|
|
42
|
+
/**
|
|
43
|
+
* Return every data row as ErrorsOr.
|
|
44
|
+
*
|
|
45
|
+
* Configuration/preparation failures throw.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createErrorsOrFileCursor<TProjection, TFile, TFileType extends string>(definition: CursorFileDefinition<TProjection, TFileType>, file: TFile, infrastructure: FileCursorInfrastructure<TFile, TFileType>): AsyncGenerator<ErrorsOr<FileCursorResult<TProjection>>, void, void>;
|
|
48
|
+
/**
|
|
49
|
+
* Throw when a recoverable row parser error is encountered.
|
|
50
|
+
*
|
|
51
|
+
* Configuration/preparation failures also throw.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createThrowingFileCursor<TProjection, TFile, TFileType extends string>(definition: CursorFileDefinition<TProjection, TFileType>, file: TFile, infrastructure: FileCursorInfrastructure<TFile, TFileType>): AsyncGenerator<FileCursorResult<TProjection>, void, void>;
|
|
54
|
+
/**
|
|
55
|
+
* Ignore recoverable row parser errors and continue.
|
|
56
|
+
*
|
|
57
|
+
* Configuration/preparation failures always throw.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createIgnoringFileCursor<TProjection, TFile, TFileType extends string>(definition: CursorFileDefinition<TProjection, TFileType>, file: TFile, infrastructure: FileCursorInfrastructure<TFile, TFileType>, onError?: (errors: Errors) => void): AsyncGenerator<FileCursorResult<TProjection>, void, void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Parser } from "@cobol-ts/cursor-loader-types";
|
|
2
|
+
import { type CursorFileDefinition, type FileCursorInfrastructure } from "./cursor.file";
|
|
3
|
+
export interface Customer {
|
|
4
|
+
name(): string;
|
|
5
|
+
}
|
|
6
|
+
interface Representation {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TestFile {
|
|
10
|
+
readonly bytes: Uint8Array;
|
|
11
|
+
offset: number;
|
|
12
|
+
}
|
|
13
|
+
type TestParser = Parser<Representation, undefined, undefined, undefined, readonly string[]>;
|
|
14
|
+
export declare const customerProjection: import("@cobol-ts/cursor-loader-types").CanonicalProjection<import("@cobol-ts/cursor-loader-types").ProjectionDefinition<Customer>>;
|
|
15
|
+
export declare const customerFileDefinition: CursorFileDefinition<Customer, "test">;
|
|
16
|
+
export declare const testParserRegistry: {
|
|
17
|
+
test: {
|
|
18
|
+
parser: TestParser;
|
|
19
|
+
parserConfig: () => undefined;
|
|
20
|
+
createRecordState: () => undefined;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function createTestFile(records: string): TestFile;
|
|
24
|
+
export declare function createTestInfrastructure(parserConfig?: (() => undefined)): FileCursorInfrastructure<TestFile, "test">;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testParserRegistry = exports.customerFileDefinition = exports.customerProjection = void 0;
|
|
4
|
+
exports.createTestFile = createTestFile;
|
|
5
|
+
exports.createTestInfrastructure = createTestInfrastructure;
|
|
6
|
+
const cursor_projection_1 = require("@cobol-ts/cursor-projection");
|
|
7
|
+
const BUFFER_SIZE = 64;
|
|
8
|
+
const ENCODER = new TextEncoder();
|
|
9
|
+
exports.customerProjection = (0, cursor_projection_1.defineProjection)({
|
|
10
|
+
name: {
|
|
11
|
+
type: "string"
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
exports.customerFileDefinition = {
|
|
15
|
+
filename: "test.customer",
|
|
16
|
+
fileType: "test",
|
|
17
|
+
projection: exports.customerProjection
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The test format deliberately uses one byte per logical record.
|
|
21
|
+
*
|
|
22
|
+
* A -> Alice
|
|
23
|
+
* B -> Bob
|
|
24
|
+
* ! -> recoverable row error
|
|
25
|
+
*
|
|
26
|
+
* The physical buffer is deliberately much larger than the fixture so several
|
|
27
|
+
* logical records normally share one buffer. cursor-record owns testing that
|
|
28
|
+
* physical lifetime in detail; this fixture merely gives cursor-file a real
|
|
29
|
+
* parser/source pipeline to consume.
|
|
30
|
+
*/
|
|
31
|
+
const testParser = {
|
|
32
|
+
async parse(record) {
|
|
33
|
+
if (record.startByte
|
|
34
|
+
=== record.lastValidByte) {
|
|
35
|
+
await record.readMore();
|
|
36
|
+
}
|
|
37
|
+
if (record.startByte
|
|
38
|
+
>= record.lastValidByte) {
|
|
39
|
+
record.endByte =
|
|
40
|
+
record.lastValidByte;
|
|
41
|
+
return {
|
|
42
|
+
errors: [
|
|
43
|
+
"Unexpected end of test file"
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const byte = byteAt(record, record.startByte);
|
|
48
|
+
record.endByte =
|
|
49
|
+
record.startByte + 1;
|
|
50
|
+
if (byte === 33) {
|
|
51
|
+
return {
|
|
52
|
+
errors: [
|
|
53
|
+
"bad row"
|
|
54
|
+
],
|
|
55
|
+
reference: `row-${record.recordNumber}`
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
name: byte === 65
|
|
60
|
+
? "Alice"
|
|
61
|
+
: byte === 66
|
|
62
|
+
? "Bob"
|
|
63
|
+
: String.fromCharCode(byte)
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
compileProjectionPath(_details, _context, path) {
|
|
67
|
+
if (path.length !== 1
|
|
68
|
+
|| path[0] !== "name") {
|
|
69
|
+
throw new Error(`Unknown test projection path: ${path.join(".")}`);
|
|
70
|
+
}
|
|
71
|
+
return ["name"];
|
|
72
|
+
},
|
|
73
|
+
integer() {
|
|
74
|
+
throw new Error("Test parser does not support integer projections");
|
|
75
|
+
},
|
|
76
|
+
float() {
|
|
77
|
+
throw new Error("Test parser does not support float projections");
|
|
78
|
+
},
|
|
79
|
+
character() {
|
|
80
|
+
throw new Error("Test parser does not support character projections");
|
|
81
|
+
},
|
|
82
|
+
string(representation, _details, path) {
|
|
83
|
+
if (path.length !== 1
|
|
84
|
+
|| path[0] !== "name") {
|
|
85
|
+
throw new Error(`Unknown test projection path: ${path.join(".")}`);
|
|
86
|
+
}
|
|
87
|
+
return representation.name;
|
|
88
|
+
},
|
|
89
|
+
toDebugString() {
|
|
90
|
+
return "test record";
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
exports.testParserRegistry = {
|
|
94
|
+
test: {
|
|
95
|
+
parser: testParser,
|
|
96
|
+
parserConfig: () => undefined,
|
|
97
|
+
createRecordState: () => undefined
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
function createTestFile(records) {
|
|
101
|
+
return {
|
|
102
|
+
bytes: ENCODER.encode(records),
|
|
103
|
+
offset: 0
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function createTestInfrastructure(parserConfig = () => undefined) {
|
|
107
|
+
return {
|
|
108
|
+
parsers: {
|
|
109
|
+
test: {
|
|
110
|
+
parser: testParser,
|
|
111
|
+
parserConfig,
|
|
112
|
+
createRecordState: () => undefined
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
bufferSize: BUFFER_SIZE,
|
|
116
|
+
fillFileBuffer: async (file, target) => {
|
|
117
|
+
const available = file.bytes.length
|
|
118
|
+
- file.offset;
|
|
119
|
+
const count = Math.min(available, target.length);
|
|
120
|
+
if (count !== 0) {
|
|
121
|
+
target.set(file.bytes.subarray(file.offset, file.offset + count));
|
|
122
|
+
file.offset +=
|
|
123
|
+
count;
|
|
124
|
+
}
|
|
125
|
+
return count;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function byteAt(record, offset) {
|
|
130
|
+
let bufferStart = 0;
|
|
131
|
+
for (const buffer of record.buffers) {
|
|
132
|
+
const bufferEnd = bufferStart
|
|
133
|
+
+ buffer.length;
|
|
134
|
+
if (offset < bufferEnd) {
|
|
135
|
+
return buffer[offset
|
|
136
|
+
- bufferStart];
|
|
137
|
+
}
|
|
138
|
+
bufferStart =
|
|
139
|
+
bufferEnd;
|
|
140
|
+
}
|
|
141
|
+
throw new Error(`Byte offset ${offset} is outside the physical record`);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=cursor.file.fixture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.file.fixture.js","sourceRoot":"","sources":["../../src/cursor.file.fixture.ts"],"names":[],"mappings":";;;AA8MA,wCAUC;AAGD,4DAgDC;AArQD,mEAEqC;AAkCrC,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,MAAM,OAAO,GACT,IAAI,WAAW,EAAE,CAAC;AAGT,QAAA,kBAAkB,GAC3B,IAAA,oCAAgB,EAAW;IACvB,IAAI,EAAE;QACF,IAAI,EAAE,QAAQ;KACjB;CACJ,CAAC,CAAC;AAGM,QAAA,sBAAsB,GACS;IACxC,QAAQ,EACJ,eAAe;IAEnB,QAAQ,EACJ,MAAM;IAEV,UAAU,EACV,0BAAkB;CACrB,CAAC;AAGF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,GAAe;IAC3B,KAAK,CAAC,KAAK,CAAC,MAAM;QACd,IACI,MAAM,CAAC,SAAS;gBACZ,MAAM,CAAC,aAAa,EAC1B,CAAC;YACC,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC;QAED,IACI,MAAM,CAAC,SAAS;eACb,MAAM,CAAC,aAAa,EACzB,CAAC;YACC,MAAM,CAAC,OAAO;gBACV,MAAM,CAAC,aAAa,CAAC;YAEzB,OAAO;gBACH,MAAM,EAAE;oBACJ,6BAA6B;iBAChC;aACJ,CAAC;QACN,CAAC;QAED,MAAM,IAAI,GACN,MAAM,CACF,MAAM,EACN,MAAM,CAAC,SAAS,CACnB,CAAC;QAEN,MAAM,CAAC,OAAO;YACV,MAAM,CAAC,SAAS,GAAG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CAAC,MAAM,CAAC;QAEpB,IAAI,MAAM,GAAG,SAAS,EAAE,CAAC;YACrB,OAAO,MAAM,CACb,MAAM;kBACJ,WAAW,CACR,CAAC;QACV,CAAC;QAED,WAAW;YACP,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,KAAK,CACX,eAAe,MAAM,iCAAiC,CACzD,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scanThrowingFileCursor = scanThrowingFileCursor;
|
|
4
|
+
exports.createFileCursor = createFileCursor;
|
|
5
|
+
exports.createErrorsOrFileCursor = createErrorsOrFileCursor;
|
|
6
|
+
exports.createThrowingFileCursor = createThrowingFileCursor;
|
|
7
|
+
exports.createIgnoringFileCursor = createIgnoringFileCursor;
|
|
8
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
9
|
+
const cursor_record_1 = require("@cobol-ts/cursor-record");
|
|
10
|
+
const cursor_projection_1 = require("@cobol-ts/cursor-projection");
|
|
11
|
+
const cursor_file_result_1 = require("./cursor.file.result");
|
|
12
|
+
const metrics_1 = require("@cobol-ts/metrics");
|
|
13
|
+
/**
|
|
14
|
+
* Callback alternative to createThrowingFileCursor.
|
|
15
|
+
*
|
|
16
|
+
* The callback receives the projected row, not a lease. Its lifetime ends
|
|
17
|
+
* when the callback returns, so callers must not retain it or await inside
|
|
18
|
+
* the callback. Returning false stops iteration (e.g. during warm-up).
|
|
19
|
+
*
|
|
20
|
+
* Unlike an async generator, the file cursor can process buffered records
|
|
21
|
+
* synchronously when the parser implements parseBuffered(). Projection and
|
|
22
|
+
* physical-record objects are pooled/reused throughout the scan.
|
|
23
|
+
*/
|
|
24
|
+
async function scanThrowingFileCursor(definition, file, infrastructure, onRecord) {
|
|
25
|
+
const metrics = infrastructure.metrics ?? metrics_1.NULL_METRICS;
|
|
26
|
+
const opened = await openFileCursor(definition, file, {
|
|
27
|
+
...infrastructure,
|
|
28
|
+
recordPool: infrastructure.recordPool ?? (0, cursor_record_1.createReferenceCountedRecordPool)()
|
|
29
|
+
});
|
|
30
|
+
const projected = opened.projection.create();
|
|
31
|
+
try {
|
|
32
|
+
await opened.scanRecords((result, physicalRecord) => {
|
|
33
|
+
metrics.put(metrics_1.METRIC.FILE_SCAN_RECORD);
|
|
34
|
+
if ((0, errors_1.isErrors)(result)) {
|
|
35
|
+
throw new errors_1.ErrorsException(result.errors, result.reference);
|
|
36
|
+
}
|
|
37
|
+
opened.projection.bind(projected, result, physicalRecord);
|
|
38
|
+
try {
|
|
39
|
+
return onRecord(projected);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
opened.projection.clear(projected);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
opened.close();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Return successful projected rows directly.
|
|
52
|
+
*
|
|
53
|
+
* Recoverable row parser errors are returned as string[].
|
|
54
|
+
*
|
|
55
|
+
* Configuration, parser preparation and projection configuration failures
|
|
56
|
+
* throw before the data-row run.
|
|
57
|
+
*/
|
|
58
|
+
async function* createFileCursor(definition, file, infrastructure) {
|
|
59
|
+
const opened = await openFileCursor(definition, file, infrastructure);
|
|
60
|
+
const resultPool = (0, cursor_file_result_1.createFileCursorResultPool)(opened.projection);
|
|
61
|
+
try {
|
|
62
|
+
for await (const record of opened.recordCursor) {
|
|
63
|
+
const result = projectRecord(record, resultPool);
|
|
64
|
+
yield (0, errors_1.isErrors)(result)
|
|
65
|
+
? result.errors
|
|
66
|
+
: result;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
opened.close();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Return every data row as ErrorsOr.
|
|
75
|
+
*
|
|
76
|
+
* Configuration/preparation failures throw.
|
|
77
|
+
*/
|
|
78
|
+
async function* createErrorsOrFileCursor(definition, file, infrastructure) {
|
|
79
|
+
const opened = await openFileCursor(definition, file, infrastructure);
|
|
80
|
+
const resultPool = (0, cursor_file_result_1.createFileCursorResultPool)(opened.projection);
|
|
81
|
+
try {
|
|
82
|
+
for await (const record of opened.recordCursor) {
|
|
83
|
+
const result = projectRecord(record, resultPool);
|
|
84
|
+
yield (0, errors_1.isErrors)(result)
|
|
85
|
+
? result
|
|
86
|
+
: (0, errors_1.value)(result);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
opened.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Throw when a recoverable row parser error is encountered.
|
|
95
|
+
*
|
|
96
|
+
* Configuration/preparation failures also throw.
|
|
97
|
+
*/
|
|
98
|
+
async function* createThrowingFileCursor(definition, file, infrastructure) {
|
|
99
|
+
const opened = await openFileCursor(definition, file, infrastructure);
|
|
100
|
+
const resultPool = (0, cursor_file_result_1.createFileCursorResultPool)(opened.projection);
|
|
101
|
+
try {
|
|
102
|
+
for await (const record of opened.recordCursor) {
|
|
103
|
+
const result = projectRecord(record, resultPool);
|
|
104
|
+
if ((0, errors_1.isErrors)(result)) {
|
|
105
|
+
throw new errors_1.ErrorsException(result.errors, result.reference);
|
|
106
|
+
}
|
|
107
|
+
yield result;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
opened.close();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Ignore recoverable row parser errors and continue.
|
|
116
|
+
*
|
|
117
|
+
* Configuration/preparation failures always throw.
|
|
118
|
+
*/
|
|
119
|
+
async function* createIgnoringFileCursor(definition, file, infrastructure, onError) {
|
|
120
|
+
const opened = await openFileCursor(definition, file, infrastructure);
|
|
121
|
+
const resultPool = (0, cursor_file_result_1.createFileCursorResultPool)(opened.projection);
|
|
122
|
+
try {
|
|
123
|
+
for await (const record of opened.recordCursor) {
|
|
124
|
+
const result = projectRecord(record, resultPool);
|
|
125
|
+
if ((0, errors_1.isErrors)(result)) {
|
|
126
|
+
onError?.(result);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
yield result;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
opened.close();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Resolve the parser from the file definition and prepare all file-scoped
|
|
138
|
+
* state before entering the row-processing hot path.
|
|
139
|
+
*
|
|
140
|
+
* Projection paths are compiled against that prepared state. Where preparation
|
|
141
|
+
* used a physical record, its thin PhysicalRecordContext is supplied so parser-
|
|
142
|
+
* specific projection compilation can report source and record provenance
|
|
143
|
+
* without retaining the preparation record itself.
|
|
144
|
+
*/
|
|
145
|
+
async function openFileCursor(definition, file, infrastructure) {
|
|
146
|
+
const registered = infrastructure.parsers[definition.fileType];
|
|
147
|
+
if (registered === undefined) {
|
|
148
|
+
throw new Error(`No parser registered for file type ${definition.fileType}`);
|
|
149
|
+
}
|
|
150
|
+
const parser = registered.parser;
|
|
151
|
+
const parserConfig = registered.parserConfig(definition);
|
|
152
|
+
const physical = (0, cursor_record_1.createDefaultPhysicalRecordConfig)({
|
|
153
|
+
source: definition.filename,
|
|
154
|
+
file,
|
|
155
|
+
bufferSize: infrastructure.bufferSize,
|
|
156
|
+
fillFileBuffer: infrastructure.fillFileBuffer,
|
|
157
|
+
createRecordState: registered.createRecordState,
|
|
158
|
+
cleanRecordState: registered.cleanRecordState,
|
|
159
|
+
recordPool: infrastructure.recordPool,
|
|
160
|
+
byteBufferPool: infrastructure.byteBufferPool,
|
|
161
|
+
metrics: infrastructure.metrics
|
|
162
|
+
});
|
|
163
|
+
const opened = await (0, cursor_record_1.openRecordCursor)(parser, parserConfig, physical);
|
|
164
|
+
try {
|
|
165
|
+
const projection = (0, cursor_projection_1.createProjection)(parser, opened.details, opened.preparationContext, definition.projection, infrastructure.metrics);
|
|
166
|
+
return {
|
|
167
|
+
recordCursor: opened.recordCursor,
|
|
168
|
+
projection,
|
|
169
|
+
scanRecords: opened.scanRecords,
|
|
170
|
+
close: opened.close
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
opened.close();
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Project one parsed record and transfer ownership of its physical record.
|
|
180
|
+
*/
|
|
181
|
+
function projectRecord(record, resultPool) {
|
|
182
|
+
if ((0, errors_1.isErrors)(record.result)) {
|
|
183
|
+
record.physicalRecord.close();
|
|
184
|
+
return record.result;
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
return (0, cursor_file_result_1.createFileCursorResult)(record.result, record.physicalRecord, resultPool);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
record.physicalRecord.close();
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=cursor.file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.file.js","sourceRoot":"","sources":["../../src/cursor.file.ts"],"names":[],"mappings":";;AA6FA,wDA8BC;AAWD,4CAoCC;AAQD,4DAoCC;AAQD,4DAyCC;AAQD,4DAwCC;AAvTD,6CAM0B;AAa1B,2DAMiC;AAEjC,mEAEqC;AAErC,6DAK8B;AAC9B,+CAAuE;AA6CvE;;;;;;;;;;GAUG;AACI,KAAK,UAAU,sBAAsB,CAGxC,UAAuD,EACvD,IAAW,EACX,cAAyD,EACzD,QAAgD;IAEhD,MAAM,OAAO,GAAC,cAAc,CAAC,OAAO,IAAE,sBAAY,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,UAAU,EAAC,IAAI,EAAC;QAChD,GAAG,cAAc;QACjB,UAAU,EAAE,cAAc,CAAC,UAAU,IAAI,IAA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,cAAc,EACrB,UAAU,CACb,CAAC;IACN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FileHandle } from 'node:fs/promises';
|
|
2
|
+
/**
|
|
3
|
+
* Fill an existing pooled buffer directly from a Node FileHandle.
|
|
4
|
+
*
|
|
5
|
+
* A short FileHandle.read() is not EOF. Keep writing into the same supplied
|
|
6
|
+
* buffer until full or until an actual zero-byte read. This adapter never
|
|
7
|
+
* assembles records or field fragments into intermediate byte arrays.
|
|
8
|
+
*
|
|
9
|
+
* The caller retains ownership of the handle and must close it when the
|
|
10
|
+
* associated cursor is completed, cancelled, or fails.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fillNodeFileBuffer(handle: FileHandle, destination: Uint8Array): Promise<number>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fillNodeFileBuffer = fillNodeFileBuffer;
|
|
4
|
+
/**
|
|
5
|
+
* Fill an existing pooled buffer directly from a Node FileHandle.
|
|
6
|
+
*
|
|
7
|
+
* A short FileHandle.read() is not EOF. Keep writing into the same supplied
|
|
8
|
+
* buffer until full or until an actual zero-byte read. This adapter never
|
|
9
|
+
* assembles records or field fragments into intermediate byte arrays.
|
|
10
|
+
*
|
|
11
|
+
* The caller retains ownership of the handle and must close it when the
|
|
12
|
+
* associated cursor is completed, cancelled, or fails.
|
|
13
|
+
*/
|
|
14
|
+
async function fillNodeFileBuffer(handle, destination) {
|
|
15
|
+
let filled = 0;
|
|
16
|
+
while (filled < destination.length) {
|
|
17
|
+
const { bytesRead } = await handle.read(destination, filled, destination.length - filled, null);
|
|
18
|
+
if (bytesRead === 0)
|
|
19
|
+
break;
|
|
20
|
+
filled += bytesRead;
|
|
21
|
+
}
|
|
22
|
+
return filled;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=cursor.file.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.file.node.js","sourceRoot":"","sources":["../../src/cursor.file.node.ts"],"names":[],"mappings":";;AAYA,gDAQC;AAlBD;;;;;;;;;GASG;AACI,KAAK,UAAU,kBAAkB,CAAC,MAAkB,EAAE,WAAuB;IAChF,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC;QAC9F,IAAI,SAAS,KAAK,CAAC;YAAE,MAAM;QAC3B,MAAM,IAAI,SAAS,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cursor_file_node_1 = require("./cursor.file.node");
|
|
4
|
+
test('short positive Node reads fill the existing destination until full or true EOF', async () => {
|
|
5
|
+
const bytes = Uint8Array.from([1, 2, 3, 4, 5]);
|
|
6
|
+
let offset = 0;
|
|
7
|
+
let calls = 0;
|
|
8
|
+
const file = {
|
|
9
|
+
async read(destination, position, length) {
|
|
10
|
+
calls++;
|
|
11
|
+
const count = Math.min(length, 2, bytes.length - offset);
|
|
12
|
+
destination.set(bytes.subarray(offset, offset + count), position);
|
|
13
|
+
offset += count;
|
|
14
|
+
return { bytesRead: count };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const target = new Uint8Array(7);
|
|
18
|
+
expect(await (0, cursor_file_node_1.fillNodeFileBuffer)(file, target)).toBe(5);
|
|
19
|
+
expect(Array.from(target)).toEqual([1, 2, 3, 4, 5, 0, 0]);
|
|
20
|
+
expect(calls).toBe(4); // three short reads, then the *actual* EOF
|
|
21
|
+
expect(await (0, cursor_file_node_1.fillNodeFileBuffer)(file, target)).toBe(0);
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=cursor.file.node.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.file.node.spec.js","sourceRoot":"","sources":["../../src/cursor.file.node.spec.ts"],"names":[],"mappings":";;AACA,yDAAsD;AAEtD,IAAI,CAAC,gFAAgF,EAAE,KAAK,IAAI,EAAE;IAC9F,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,IAAI,GAAG;QACT,KAAK,CAAC,IAAI,CAAC,WAAuB,EAAE,QAAgB,EAAE,MAAc;YAChE,KAAK,EAAE,CAAC;YACR,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;YACzD,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CAAC;YAChB,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,CAAC;QAC9B,CAAC;KACqB,CAAC;IAC3B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,CAAC,MAAM,IAAA,qCAAkB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC;IACpD,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2CAA2C;IAClE,MAAM,CAAC,MAAM,IAAA,qCAAkB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type RefCountedPool } from "@cobol-ts/ref_counted_pool";
|
|
2
|
+
import { type PhysicalRecordContent, type PhysicalRecordLifetime, type ProjectionFactory } from "@cobol-ts/cursor-loader-types";
|
|
3
|
+
/**
|
|
4
|
+
* Public file-cursor result.
|
|
5
|
+
*
|
|
6
|
+
* The result remains valid until close() is called.
|
|
7
|
+
*
|
|
8
|
+
* close() must be called exactly once for each returned lease.
|
|
9
|
+
*
|
|
10
|
+
* After close() the caller must not use this object again.
|
|
11
|
+
*/
|
|
12
|
+
export interface FileCursorResult<TResult> {
|
|
13
|
+
readonly result: TResult;
|
|
14
|
+
close(): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Pooled file-cursor result.
|
|
18
|
+
*
|
|
19
|
+
* The complete JavaScript object is created once and never changes shape.
|
|
20
|
+
*
|
|
21
|
+
* result is permanent. It is one reusable projection object created with
|
|
22
|
+
* ProjectionFactory.create() when this pooled entry is first constructed.
|
|
23
|
+
*
|
|
24
|
+
* physicalRecord is:
|
|
25
|
+
*
|
|
26
|
+
* undefined
|
|
27
|
+
* while the pooled entry is inactive;
|
|
28
|
+
*
|
|
29
|
+
* PhysicalRecordLifetime
|
|
30
|
+
* while the entry owns an active lease.
|
|
31
|
+
*
|
|
32
|
+
* Releasing the lease clears the projection binding and restores
|
|
33
|
+
* physicalRecord to undefined.
|
|
34
|
+
*/
|
|
35
|
+
export interface PooledFileCursorResult<TProjection, TRepresentation> {
|
|
36
|
+
readonly resultPool: FileCursorResultPool<TProjection, TRepresentation>;
|
|
37
|
+
readonly projection: ProjectionFactory<TProjection, TRepresentation>;
|
|
38
|
+
readonly result: TProjection;
|
|
39
|
+
physicalRecord: PhysicalRecordLifetime | undefined;
|
|
40
|
+
close(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Pool containing file-cursor result objects.
|
|
44
|
+
*
|
|
45
|
+
* Each pooled entry owns one reusable projection object for its entire
|
|
46
|
+
* lifetime.
|
|
47
|
+
*/
|
|
48
|
+
export type FileCursorResultPool<TProjection, TRepresentation> = RefCountedPool<PooledFileCursorResult<TProjection, TRepresentation>>;
|
|
49
|
+
/**
|
|
50
|
+
* Create a pool of file-cursor result objects.
|
|
51
|
+
*
|
|
52
|
+
* Each pooled entry is created once with its complete runtime shape:
|
|
53
|
+
*
|
|
54
|
+
* resultPool
|
|
55
|
+
* projection
|
|
56
|
+
* result
|
|
57
|
+
* physicalRecord
|
|
58
|
+
* close
|
|
59
|
+
*
|
|
60
|
+
* result is created once here and is retained for the lifetime of the pooled
|
|
61
|
+
* entry.
|
|
62
|
+
*
|
|
63
|
+
* Pool reuse changes only lease-specific values and projection binding. It
|
|
64
|
+
* never replaces result and never changes the wrapper object's shape.
|
|
65
|
+
*/
|
|
66
|
+
export declare function createFileCursorResultPool<TProjection, TRepresentation>(projection: ProjectionFactory<TProjection, TRepresentation>): FileCursorResultPool<TProjection, TRepresentation>;
|
|
67
|
+
/**
|
|
68
|
+
* Acquire a file-cursor result lease.
|
|
69
|
+
*
|
|
70
|
+
* The pooled entry already owns its permanent projection object.
|
|
71
|
+
*
|
|
72
|
+
* This operation binds that projection to representation and physicalRecord,
|
|
73
|
+
* then transfers ownership of physicalRecord to the returned FileCursorResult.
|
|
74
|
+
*
|
|
75
|
+
* No projection object or accessor function is created here.
|
|
76
|
+
*/
|
|
77
|
+
export declare function createFileCursorResult<TProjection, TRepresentation, TRecordState>(representation: TRepresentation, physicalRecord: PhysicalRecordContent<TRecordState>, resultPool: FileCursorResultPool<TProjection, TRepresentation>): FileCursorResult<TProjection>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFileCursorResultPool = createFileCursorResultPool;
|
|
4
|
+
exports.createFileCursorResult = createFileCursorResult;
|
|
5
|
+
const ref_counted_pool_1 = require("@cobol-ts/ref_counted_pool");
|
|
6
|
+
/**
|
|
7
|
+
* Create a pool of file-cursor result objects.
|
|
8
|
+
*
|
|
9
|
+
* Each pooled entry is created once with its complete runtime shape:
|
|
10
|
+
*
|
|
11
|
+
* resultPool
|
|
12
|
+
* projection
|
|
13
|
+
* result
|
|
14
|
+
* physicalRecord
|
|
15
|
+
* close
|
|
16
|
+
*
|
|
17
|
+
* result is created once here and is retained for the lifetime of the pooled
|
|
18
|
+
* entry.
|
|
19
|
+
*
|
|
20
|
+
* Pool reuse changes only lease-specific values and projection binding. It
|
|
21
|
+
* never replaces result and never changes the wrapper object's shape.
|
|
22
|
+
*/
|
|
23
|
+
function createFileCursorResultPool(projection) {
|
|
24
|
+
let resultPool;
|
|
25
|
+
resultPool =
|
|
26
|
+
(0, ref_counted_pool_1.createRefCountedPool)(() => ({
|
|
27
|
+
resultPool,
|
|
28
|
+
projection,
|
|
29
|
+
result: projection.create(),
|
|
30
|
+
physicalRecord: undefined,
|
|
31
|
+
close: closeFileCursorResult
|
|
32
|
+
}));
|
|
33
|
+
return resultPool;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Acquire a file-cursor result lease.
|
|
37
|
+
*
|
|
38
|
+
* The pooled entry already owns its permanent projection object.
|
|
39
|
+
*
|
|
40
|
+
* This operation binds that projection to representation and physicalRecord,
|
|
41
|
+
* then transfers ownership of physicalRecord to the returned FileCursorResult.
|
|
42
|
+
*
|
|
43
|
+
* No projection object or accessor function is created here.
|
|
44
|
+
*/
|
|
45
|
+
function createFileCursorResult(representation, physicalRecord, resultPool) {
|
|
46
|
+
const pooled = resultPool.acquire();
|
|
47
|
+
try {
|
|
48
|
+
pooled.projection.bind(pooled.result, representation, physicalRecord);
|
|
49
|
+
pooled.physicalRecord =
|
|
50
|
+
physicalRecord;
|
|
51
|
+
return pooled;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
pooled.projection.clear(pooled.result);
|
|
55
|
+
resultPool.release(pooled);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Close an active file-cursor result lease.
|
|
61
|
+
*
|
|
62
|
+
* The projection is cleared first so it no longer retains either the parser
|
|
63
|
+
* representation or the physical record.
|
|
64
|
+
*
|
|
65
|
+
* physicalRecord is then removed from the pooled wrapper and its own lifetime
|
|
66
|
+
* is closed.
|
|
67
|
+
*
|
|
68
|
+
* Only after both references have been removed is the unchanged wrapper object
|
|
69
|
+
* returned to the result pool.
|
|
70
|
+
*/
|
|
71
|
+
function closeFileCursorResult() {
|
|
72
|
+
const physicalRecord = this.physicalRecord;
|
|
73
|
+
if (physicalRecord === undefined) {
|
|
74
|
+
throw new Error("File cursor result is not active");
|
|
75
|
+
}
|
|
76
|
+
this.projection.clear(this.result);
|
|
77
|
+
this.physicalRecord =
|
|
78
|
+
undefined;
|
|
79
|
+
physicalRecord.close();
|
|
80
|
+
this.resultPool.release(this);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=cursor.file.result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.file.result.js","sourceRoot":"","sources":["../../src/cursor.file.result.ts"],"names":[],"mappings":";;AAkHA,gEA8CC;AAaD,wDAiDC;AA9ND,iEAGoC;AA8FpC;;;;;;;;;;;;;;;;GAgB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-0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cursor_file_result_1 = require("./cursor.file.result");
|
|
4
|
+
describe("file cursor result", () => {
|
|
5
|
+
test("binds a reusable projection to the supplied representation", () => {
|
|
6
|
+
const projection = createCustomerProjection();
|
|
7
|
+
const pool = (0, cursor_file_result_1.createFileCursorResultPool)(projection);
|
|
8
|
+
const record = physicalRecord();
|
|
9
|
+
const result = (0, cursor_file_result_1.createFileCursorResult)({
|
|
10
|
+
name: "Alice"
|
|
11
|
+
}, record.value, pool);
|
|
12
|
+
expect(result.result.name()).toBe("Alice");
|
|
13
|
+
result.close();
|
|
14
|
+
expect(record.closed).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
test("reuses the same result wrapper and projection for a later record", () => {
|
|
17
|
+
const projection = createCustomerProjection();
|
|
18
|
+
const pool = (0, cursor_file_result_1.createFileCursorResultPool)(projection);
|
|
19
|
+
const firstRecord = physicalRecord();
|
|
20
|
+
const first = (0, cursor_file_result_1.createFileCursorResult)({
|
|
21
|
+
name: "Alice"
|
|
22
|
+
}, firstRecord.value, pool);
|
|
23
|
+
const firstProjection = first.result;
|
|
24
|
+
expect(firstProjection.name()).toBe("Alice");
|
|
25
|
+
first.close();
|
|
26
|
+
expect(firstRecord.closed).toBe(true);
|
|
27
|
+
const secondRecord = physicalRecord();
|
|
28
|
+
const second = (0, cursor_file_result_1.createFileCursorResult)({
|
|
29
|
+
name: "Bob"
|
|
30
|
+
}, secondRecord.value, pool);
|
|
31
|
+
expect(second).toBe(first);
|
|
32
|
+
expect(second.result).toBe(firstProjection);
|
|
33
|
+
expect(second.result.name()).toBe("Bob");
|
|
34
|
+
second.close();
|
|
35
|
+
expect(secondRecord.closed).toBe(true);
|
|
36
|
+
expect(projection.created).toBe(1);
|
|
37
|
+
});
|
|
38
|
+
test("clears the projection when the result is closed", () => {
|
|
39
|
+
const projection = createCustomerProjection();
|
|
40
|
+
const pool = (0, cursor_file_result_1.createFileCursorResultPool)(projection);
|
|
41
|
+
const record = physicalRecord();
|
|
42
|
+
const result = (0, cursor_file_result_1.createFileCursorResult)({
|
|
43
|
+
name: "Alice"
|
|
44
|
+
}, record.value, pool);
|
|
45
|
+
const customer = result.result;
|
|
46
|
+
expect(customer.name()).toBe("Alice");
|
|
47
|
+
result.close();
|
|
48
|
+
expect(record.closed).toBe(true);
|
|
49
|
+
expect(() => customer.name()).toThrow("Projection is not bound");
|
|
50
|
+
});
|
|
51
|
+
test("allows several result leases to remain live simultaneously", () => {
|
|
52
|
+
const projection = createCustomerProjection();
|
|
53
|
+
const pool = (0, cursor_file_result_1.createFileCursorResultPool)(projection);
|
|
54
|
+
const aliceRecord = physicalRecord();
|
|
55
|
+
const bobRecord = physicalRecord();
|
|
56
|
+
const alice = (0, cursor_file_result_1.createFileCursorResult)({
|
|
57
|
+
name: "Alice"
|
|
58
|
+
}, aliceRecord.value, pool);
|
|
59
|
+
const bob = (0, cursor_file_result_1.createFileCursorResult)({
|
|
60
|
+
name: "Bob"
|
|
61
|
+
}, bobRecord.value, pool);
|
|
62
|
+
expect(alice).not.toBe(bob);
|
|
63
|
+
expect(alice.result).not.toBe(bob.result);
|
|
64
|
+
expect(alice.result.name()).toBe("Alice");
|
|
65
|
+
expect(bob.result.name()).toBe("Bob");
|
|
66
|
+
expect(projection.created).toBe(2);
|
|
67
|
+
alice.close();
|
|
68
|
+
expect(aliceRecord.closed).toBe(true);
|
|
69
|
+
expect(bobRecord.closed).toBe(false);
|
|
70
|
+
expect(bob.result.name()).toBe("Bob");
|
|
71
|
+
bob.close();
|
|
72
|
+
expect(bobRecord.closed).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
test("clears the projection before closing the physical record", () => {
|
|
75
|
+
const projection = createCustomerProjection();
|
|
76
|
+
const pool = (0, cursor_file_result_1.createFileCursorResultPool)(projection);
|
|
77
|
+
let customer;
|
|
78
|
+
const record = physicalRecord(() => {
|
|
79
|
+
const currentCustomer = customer;
|
|
80
|
+
if (currentCustomer === undefined) {
|
|
81
|
+
throw new Error("Expected projection");
|
|
82
|
+
}
|
|
83
|
+
expect(() => currentCustomer.name()).toThrow("Projection is not bound");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
test("returns the pooled result after a failed bind without taking ownership of the physical record", () => {
|
|
87
|
+
const projection = createFailingCustomerProjection();
|
|
88
|
+
const pool = (0, cursor_file_result_1.createFileCursorResultPool)(projection);
|
|
89
|
+
const failedRecord = physicalRecord();
|
|
90
|
+
expect(() => (0, cursor_file_result_1.createFileCursorResult)({
|
|
91
|
+
name: "Alice"
|
|
92
|
+
}, failedRecord.value, pool)).toThrow("bind failed");
|
|
93
|
+
/*
|
|
94
|
+
* Ownership transfers only after a successful bind.
|
|
95
|
+
*/
|
|
96
|
+
expect(failedRecord.closed).toBe(false);
|
|
97
|
+
/*
|
|
98
|
+
* bind() deliberately left partial state behind before throwing.
|
|
99
|
+
* createFileCursorResult() must have cleared it.
|
|
100
|
+
*/
|
|
101
|
+
expect(projection.bound).toBe(false);
|
|
102
|
+
projection.failBinding = false;
|
|
103
|
+
const successfulRecord = physicalRecord();
|
|
104
|
+
const result = (0, cursor_file_result_1.createFileCursorResult)({
|
|
105
|
+
name: "Bob"
|
|
106
|
+
}, successfulRecord.value, pool);
|
|
107
|
+
/*
|
|
108
|
+
* The failed lease was returned to the pool, so no second projection
|
|
109
|
+
* object needed to be created.
|
|
110
|
+
*/
|
|
111
|
+
expect(projection.created).toBe(1);
|
|
112
|
+
expect(result.result.name()).toBe("Bob");
|
|
113
|
+
result.close();
|
|
114
|
+
expect(successfulRecord.closed).toBe(true);
|
|
115
|
+
/*
|
|
116
|
+
* The failed record was never owned by the result.
|
|
117
|
+
*/
|
|
118
|
+
expect(failedRecord.closed).toBe(false);
|
|
119
|
+
failedRecord.value.close();
|
|
120
|
+
expect(failedRecord.closed).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
function createCustomerProjection() {
|
|
124
|
+
const bindings = new WeakMap();
|
|
125
|
+
let created = 0;
|
|
126
|
+
return {
|
|
127
|
+
get created() {
|
|
128
|
+
return created;
|
|
129
|
+
},
|
|
130
|
+
create() {
|
|
131
|
+
created++;
|
|
132
|
+
const customer = {
|
|
133
|
+
name: () => {
|
|
134
|
+
const representation = bindings.get(customer);
|
|
135
|
+
if (representation === undefined) {
|
|
136
|
+
throw new Error("Projection is not bound");
|
|
137
|
+
}
|
|
138
|
+
return representation.name;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
return customer;
|
|
142
|
+
},
|
|
143
|
+
bind(customer, representation) {
|
|
144
|
+
bindings.set(customer, representation);
|
|
145
|
+
},
|
|
146
|
+
clear(customer) {
|
|
147
|
+
bindings.delete(customer);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function createFailingCustomerProjection() {
|
|
152
|
+
const bindings = new WeakMap();
|
|
153
|
+
let created = 0;
|
|
154
|
+
let bound = false;
|
|
155
|
+
return {
|
|
156
|
+
failBinding: true,
|
|
157
|
+
get created() {
|
|
158
|
+
return created;
|
|
159
|
+
},
|
|
160
|
+
get bound() {
|
|
161
|
+
return bound;
|
|
162
|
+
},
|
|
163
|
+
create() {
|
|
164
|
+
created++;
|
|
165
|
+
const customer = {
|
|
166
|
+
name: () => {
|
|
167
|
+
const representation = bindings.get(customer);
|
|
168
|
+
if (representation === undefined) {
|
|
169
|
+
throw new Error("Projection is not bound");
|
|
170
|
+
}
|
|
171
|
+
return representation.name;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
return customer;
|
|
175
|
+
},
|
|
176
|
+
bind(customer, representation) {
|
|
177
|
+
/*
|
|
178
|
+
* Deliberately leave partial binding state before failing. This
|
|
179
|
+
* verifies that createFileCursorResult() calls clear() when bind()
|
|
180
|
+
* throws.
|
|
181
|
+
*/
|
|
182
|
+
bindings.set(customer, representation);
|
|
183
|
+
bound = true;
|
|
184
|
+
if (this.failBinding) {
|
|
185
|
+
throw new Error("bind failed");
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
clear(customer) {
|
|
189
|
+
bindings.delete(customer);
|
|
190
|
+
bound = false;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function physicalRecord(onClose = () => undefined) {
|
|
195
|
+
let closed = false;
|
|
196
|
+
const value = {
|
|
197
|
+
buffers: [],
|
|
198
|
+
recordState: undefined,
|
|
199
|
+
startByte: 0,
|
|
200
|
+
endByte: 0,
|
|
201
|
+
lastValidByte: 0,
|
|
202
|
+
fileFinished: true,
|
|
203
|
+
source: "test-source",
|
|
204
|
+
recordNumber: 1,
|
|
205
|
+
close() {
|
|
206
|
+
if (closed) {
|
|
207
|
+
throw new Error("Physical record closed twice");
|
|
208
|
+
}
|
|
209
|
+
onClose();
|
|
210
|
+
closed = true;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
return {
|
|
214
|
+
value,
|
|
215
|
+
get closed() {
|
|
216
|
+
return closed;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=cursor.file.result.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.file.result.spec.js","sourceRoot":"","sources":["../../src/cursor.file.result.spec.ts"],"names":[],"mappings":";;AAKA,6DAG8B;AAa9B,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,UAAU,GAAG,wBAAwB,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,IAAA,+CAA0B,EAAC,UAAU,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;QAEhC,MAAM,MAAM,GAAG,IAAA,2CAAsB,EACjC;YACI,IAAI,EAAE,OAAO;SAChB,EACD,MA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V,aAAa,EAAE,CAAC;QAChB,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,aAAa;QACrB,YAAY,EAAE,CAAC;QAEf,KAAK;YACD,IAAI,MAAM,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;YACpD,CAAC;YAED,OAAO,EAAE,CAAC;YAEV,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;KACJ,CAAC;IAEF,OAAO;QACH,KAAK;QAEL,IAAI,MAAM;YACN,OAAO,MAAM,CAAC;QAClB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
4
|
+
const cursor_file_1 = require("./cursor.file");
|
|
5
|
+
const cursor_file_fixture_1 = require("./cursor.file.fixture");
|
|
6
|
+
function cursorValue(result) {
|
|
7
|
+
if (result.done === true) {
|
|
8
|
+
throw new Error("Expected cursor value");
|
|
9
|
+
}
|
|
10
|
+
return result.value;
|
|
11
|
+
}
|
|
12
|
+
function projectedValue(result) {
|
|
13
|
+
if (Array.isArray(result)) {
|
|
14
|
+
throw new Error(`Expected projected value but got errors: ${result.join(", ")}`);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
describe("createFileCursor", () => {
|
|
19
|
+
test("fixture compiles named paths and rejects unsupported numeric selectors", () => {
|
|
20
|
+
const compile = cursor_file_fixture_1.testParserRegistry.test.parser.compileProjectionPath;
|
|
21
|
+
expect(compile(undefined, undefined, ["name"])).toEqual(["name"]);
|
|
22
|
+
expect(() => compile(undefined, undefined, ["name", 0])).toThrow("Unknown test projection path: name.0");
|
|
23
|
+
});
|
|
24
|
+
test("selects the parser through the registry and returns a projected value", async () => {
|
|
25
|
+
const cursor = (0, cursor_file_1.createFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("A"), (0, cursor_file_fixture_1.createTestInfrastructure)());
|
|
26
|
+
const result = projectedValue(cursorValue(await cursor.next()));
|
|
27
|
+
expect(result.result.name()).toBe("Alice");
|
|
28
|
+
result.close();
|
|
29
|
+
await expectFinished(cursor);
|
|
30
|
+
});
|
|
31
|
+
test("returns string errors and continues with the next row", async () => {
|
|
32
|
+
const cursor = (0, cursor_file_1.createFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("!A"), (0, cursor_file_fixture_1.createTestInfrastructure)());
|
|
33
|
+
const error = cursorValue(await cursor.next());
|
|
34
|
+
expect(error).toEqual([
|
|
35
|
+
"bad row"
|
|
36
|
+
]);
|
|
37
|
+
const result = projectedValue(cursorValue(await cursor.next()));
|
|
38
|
+
expect(result.result.name()).toBe("Alice");
|
|
39
|
+
result.close();
|
|
40
|
+
await expectFinished(cursor);
|
|
41
|
+
});
|
|
42
|
+
test("clears the lazy projection when the result closes", async () => {
|
|
43
|
+
const cursor = (0, cursor_file_1.createFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("A"), (0, cursor_file_fixture_1.createTestInfrastructure)());
|
|
44
|
+
const result = projectedValue(cursorValue(await cursor.next()));
|
|
45
|
+
expect(result.result.name()).toBe("Alice");
|
|
46
|
+
result.close();
|
|
47
|
+
expect(() => result.result.name()).toThrow("Projection is not bound");
|
|
48
|
+
await expectFinished(cursor);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe("createErrorsOrFileCursor", () => {
|
|
52
|
+
test("wraps a successful row in ErrorsOr", async () => {
|
|
53
|
+
const cursor = (0, cursor_file_1.createErrorsOrFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("A"), (0, cursor_file_fixture_1.createTestInfrastructure)());
|
|
54
|
+
const result = cursorValue(await cursor.next());
|
|
55
|
+
if (!(0, errors_1.isValue)(result)) {
|
|
56
|
+
throw new Error("Expected value");
|
|
57
|
+
}
|
|
58
|
+
expect(result.value.result.name()).toBe("Alice");
|
|
59
|
+
result.value.close();
|
|
60
|
+
await expectFinished(cursor);
|
|
61
|
+
});
|
|
62
|
+
test("returns Errors unchanged", async () => {
|
|
63
|
+
const cursor = (0, cursor_file_1.createErrorsOrFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("!"), (0, cursor_file_fixture_1.createTestInfrastructure)());
|
|
64
|
+
const result = cursorValue(await cursor.next());
|
|
65
|
+
expect(result).toEqual({
|
|
66
|
+
errors: [
|
|
67
|
+
"bad row"
|
|
68
|
+
],
|
|
69
|
+
reference: "row-1"
|
|
70
|
+
});
|
|
71
|
+
await expectFinished(cursor);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe("createThrowingFileCursor", () => {
|
|
75
|
+
test("throws ErrorsException for a row error", async () => {
|
|
76
|
+
const cursor = (0, cursor_file_1.createThrowingFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("!"), (0, cursor_file_fixture_1.createTestInfrastructure)());
|
|
77
|
+
await expect(cursor.next()).rejects.toEqual(expect.objectContaining({
|
|
78
|
+
name: "ErrorsException",
|
|
79
|
+
errors: [
|
|
80
|
+
"bad row"
|
|
81
|
+
],
|
|
82
|
+
reference: "row-1"
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
test("returns successful rows normally", async () => {
|
|
86
|
+
const cursor = (0, cursor_file_1.createThrowingFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("A"), (0, cursor_file_fixture_1.createTestInfrastructure)());
|
|
87
|
+
const result = cursorValue(await cursor.next());
|
|
88
|
+
expect(result.result.name()).toBe("Alice");
|
|
89
|
+
result.close();
|
|
90
|
+
await expectFinished(cursor);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe("createIgnoringFileCursor", () => {
|
|
94
|
+
test("skips errors and continues to the next successful row", async () => {
|
|
95
|
+
const cursor = (0, cursor_file_1.createIgnoringFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("!A"), (0, cursor_file_fixture_1.createTestInfrastructure)());
|
|
96
|
+
const result = cursorValue(await cursor.next());
|
|
97
|
+
expect(result.result.name()).toBe("Alice");
|
|
98
|
+
result.close();
|
|
99
|
+
await expectFinished(cursor);
|
|
100
|
+
});
|
|
101
|
+
test("calls onError with the full Errors object", async () => {
|
|
102
|
+
const received = [];
|
|
103
|
+
const cursor = (0, cursor_file_1.createIgnoringFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("!"), (0, cursor_file_fixture_1.createTestInfrastructure)(), error => received.push(error));
|
|
104
|
+
const next = await cursor.next();
|
|
105
|
+
expect(next.done).toBe(true);
|
|
106
|
+
expect(received).toEqual([
|
|
107
|
+
{
|
|
108
|
+
errors: [
|
|
109
|
+
"bad row"
|
|
110
|
+
],
|
|
111
|
+
reference: "row-1"
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
});
|
|
115
|
+
test("does not swallow configuration failures", async () => {
|
|
116
|
+
const received = [];
|
|
117
|
+
const cursor = (0, cursor_file_1.createIgnoringFileCursor)(cursor_file_fixture_1.customerFileDefinition, (0, cursor_file_fixture_1.createTestFile)("A"), (0, cursor_file_fixture_1.createTestInfrastructure)(() => {
|
|
118
|
+
throw new Error("bad configuration");
|
|
119
|
+
}), error => received.push(error));
|
|
120
|
+
await expect(cursor.next()).rejects.toThrow("bad configuration");
|
|
121
|
+
expect(received).toEqual([]);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
async function expectFinished(cursor) {
|
|
125
|
+
expect((await cursor.next()).done).toBe(true);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=cursor.files.spec.js.map
|
|
@@ -0,0 +1 @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IAAI,CAAC,KAAK,CAAC,CAChC,CAAC;QAEN,MAAM,MAAM,CACR,MAAM,CAAC,IAAI,EAAE,CAChB,CAAC,OAAO,CAAC,OAAO,CACb,mBAAmB,CACtB,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAGH,KAAK,UAAU,cAAc,CACzB,MAAmC;IAEnC,MAAM,CACF,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAC7B,CAAC,IAAI,CACF,IAAI,CACP,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/cursor-file",
|
|
3
3
|
"description": "the cursor that physically reads the file and returns the byte arrays to the cursor loader",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"browserslist": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cobol-ts/cursor-loader-types": "0.0.
|
|
21
|
-
"@cobol-ts/cursor-record": "0.0.
|
|
22
|
-
"@cobol-ts/metrics": "0.0.
|
|
20
|
+
"@cobol-ts/cursor-loader-types": "0.0.6",
|
|
21
|
+
"@cobol-ts/cursor-record": "0.0.6",
|
|
22
|
+
"@cobol-ts/metrics": "0.0.6"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"typescript": "^5.2.2",
|
package/node.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/node';
|
package/node.js
DELETED