@cobol-ts/cursor-loader-test 0.0.3 → 0.0.5

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.
Files changed (29) hide show
  1. package/dist/index.js.map +1 -0
  2. package/dist/src/cursor.loader.cobol.aws.int.test.d.ts +1 -0
  3. package/dist/src/cursor.loader.cobol.aws.int.test.js +152 -0
  4. package/dist/src/cursor.loader.cobol.aws.int.test.js.map +1 -0
  5. package/dist/src/cursor.loader.cobol.carddemo.int.test.d.ts +1 -0
  6. package/dist/src/cursor.loader.cobol.carddemo.int.test.js +105 -0
  7. package/dist/src/cursor.loader.cobol.carddemo.int.test.js.map +1 -0
  8. package/dist/src/cursor.loader.cobol.odo.acceptance.test.d.ts +1 -0
  9. package/dist/src/cursor.loader.cobol.odo.acceptance.test.js +91 -0
  10. package/dist/src/cursor.loader.cobol.odo.acceptance.test.js.map +1 -0
  11. package/dist/src/cursor.loader.cobol.rdw.aws.int.test.d.ts +1 -0
  12. package/dist/src/cursor.loader.cobol.rdw.aws.int.test.js +57 -0
  13. package/dist/src/cursor.loader.cobol.rdw.aws.int.test.js.map +1 -0
  14. package/dist/src/cursor.loader.csv.fixture.d.ts +21 -0
  15. package/dist/src/cursor.loader.csv.fixture.js +102 -0
  16. package/dist/src/cursor.loader.csv.fixture.js.map +1 -0
  17. package/dist/src/cursor.loader.csv.onefile.int.test.d.ts +1 -0
  18. package/dist/src/cursor.loader.csv.onefile.int.test.js +284 -0
  19. package/dist/src/cursor.loader.csv.onefile.int.test.js.map +1 -0
  20. package/dist/src/cursor.loader.fixture.d.ts +16 -0
  21. package/dist/src/cursor.loader.fixture.js +28 -0
  22. package/dist/src/cursor.loader.fixture.js.map +1 -0
  23. package/dist/src/cursor.loader.jsonl.fixture.d.ts +46 -0
  24. package/dist/src/cursor.loader.jsonl.fixture.js +60 -0
  25. package/dist/src/cursor.loader.jsonl.fixture.js.map +1 -0
  26. package/dist/src/cursor.loader.jsonl.onefile.int.test.d.ts +1 -0
  27. package/dist/src/cursor.loader.jsonl.onefile.int.test.js +213 -0
  28. package/dist/src/cursor.loader.jsonl.onefile.int.test.js.map +1 -0
  29. package/package.json +14 -13
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cursor_file_1 = require("@cobol-ts/cursor-file");
4
+ const cursor_loader_csv_fixture_1 = require("./cursor.loader.csv.fixture");
5
+ describe("CSV file cursor integration", () => {
6
+ test("loads complete customers including quoted fields", async () => {
7
+ const customers = [];
8
+ const cursor = (0, cursor_file_1.createFileCursor)(cursor_loader_csv_fixture_1.customerCsvDefinition, (0, cursor_loader_csv_fixture_1.createCsvFixtureFile)(cursor_loader_csv_fixture_1.customerCsvDefinition.filename), (0, cursor_loader_csv_fixture_1.createCsvInfrastructure)(7));
9
+ for await (const result of cursor) {
10
+ const row = projectedValue(result);
11
+ customers.push(readCustomer(row.result));
12
+ row.close();
13
+ }
14
+ expect(customers).toEqual([
15
+ {
16
+ id: 1001,
17
+ name: "Alice Smith",
18
+ age: 42,
19
+ address: {
20
+ line1: "12 High Street",
21
+ line2: "Flat 2, Rear",
22
+ postcode: "SW1A 1AA"
23
+ },
24
+ status: "A",
25
+ balance: 1234.56
26
+ },
27
+ {
28
+ id: 1002,
29
+ name: "Bob Jones",
30
+ age: 37,
31
+ address: {
32
+ line1: "8 Station Road",
33
+ line2: "",
34
+ postcode: "LS1 4AB"
35
+ },
36
+ status: "I",
37
+ balance: 98.75
38
+ },
39
+ {
40
+ id: 1003,
41
+ name: "Carol Brown",
42
+ age: 29,
43
+ address: {
44
+ line1: "The Old Mill",
45
+ line2: "Riverside, East Wing",
46
+ postcode: "BS1 5TY"
47
+ },
48
+ status: "A",
49
+ balance: 0
50
+ }
51
+ ]);
52
+ });
53
+ test("loads a different projection from the same CSV records", async () => {
54
+ const customers = [];
55
+ const cursor = (0, cursor_file_1.createFileCursor)(cursor_loader_csv_fixture_1.minimalCustomerCsvDefinition, (0, cursor_loader_csv_fixture_1.createCsvFixtureFile)(cursor_loader_csv_fixture_1.minimalCustomerCsvDefinition.filename), (0, cursor_loader_csv_fixture_1.createCsvInfrastructure)(5));
56
+ for await (const result of cursor) {
57
+ const row = projectedValue(result);
58
+ customers.push(readMinimalCustomer(row.result));
59
+ row.close();
60
+ }
61
+ expect(customers).toEqual([
62
+ {
63
+ id: 1001,
64
+ status: "A"
65
+ },
66
+ {
67
+ id: 1002,
68
+ status: "I"
69
+ },
70
+ {
71
+ id: 1003,
72
+ status: "A"
73
+ }
74
+ ]);
75
+ });
76
+ test("loads quoted commas doubled quotes empty fields and quoted numbers", async () => {
77
+ const customers = [];
78
+ const cursor = (0, cursor_file_1.createFileCursor)(cursor_loader_csv_fixture_1.richCustomerCsvDefinition, (0, cursor_loader_csv_fixture_1.createCsvFixtureFile)(cursor_loader_csv_fixture_1.richCustomerCsvDefinition.filename), (0, cursor_loader_csv_fixture_1.createCsvInfrastructure)(11));
79
+ for await (const result of cursor) {
80
+ const row = projectedValue(result);
81
+ customers.push(readCustomer(row.result));
82
+ row.close();
83
+ }
84
+ expect(customers).toEqual([
85
+ {
86
+ id: 1001,
87
+ name: "Alice Smith",
88
+ age: 42,
89
+ address: {
90
+ line1: "12 High Street",
91
+ line2: "Flat 2, Rear",
92
+ postcode: "SW1A 1AA"
93
+ },
94
+ status: "A",
95
+ balance: 1234.56
96
+ },
97
+ {
98
+ id: 1002,
99
+ name: "Bob Jones",
100
+ age: 37,
101
+ address: {
102
+ line1: "8 Station Road",
103
+ line2: "",
104
+ postcode: "LS1 4AB"
105
+ },
106
+ status: "I",
107
+ balance: 98.75
108
+ },
109
+ {
110
+ id: 1003,
111
+ name: "Carol Brown",
112
+ age: 29,
113
+ address: {
114
+ line1: "The Old Mill",
115
+ line2: "Riverside, East Wing",
116
+ postcode: "BS1 5TY"
117
+ },
118
+ status: "A",
119
+ balance: 0
120
+ },
121
+ {
122
+ id: 1004,
123
+ name: "David Green",
124
+ age: 51,
125
+ address: {
126
+ line1: "7 King's Road",
127
+ line2: "He said \"use the rear entrance\"",
128
+ postcode: "M1 2AB"
129
+ },
130
+ status: "A",
131
+ balance: 42.10
132
+ },
133
+ {
134
+ id: 1005,
135
+ name: "Eve Black",
136
+ age: 33,
137
+ address: {
138
+ line1: "Apartment 4",
139
+ line2: "Floor 2, \"West Wing\"",
140
+ postcode: "EH1 1AA"
141
+ },
142
+ status: "I",
143
+ balance: 100
144
+ },
145
+ {
146
+ id: 1006,
147
+ name: "Frank White",
148
+ age: 60,
149
+ address: {
150
+ line1: "1 Market Street",
151
+ line2: "",
152
+ postcode: "AB1 2CD"
153
+ },
154
+ status: "A",
155
+ balance: 123.45
156
+ },
157
+ {
158
+ id: 1007,
159
+ name: "Grace Blue",
160
+ age: 44,
161
+ address: {
162
+ line1: "2 River Road",
163
+ line2: "Comma, and \"quotes\" together",
164
+ postcode: "YO1 7AA"
165
+ },
166
+ status: "A",
167
+ balance: 9.50
168
+ }
169
+ ]);
170
+ });
171
+ test("uses the CSV configuration selected by the file definition", async () => {
172
+ const customers = [];
173
+ const cursor = (0, cursor_file_1.createFileCursor)(cursor_loader_csv_fixture_1.pipeCustomerCsvDefinition, (0, cursor_loader_csv_fixture_1.createCsvFixtureFile)(cursor_loader_csv_fixture_1.pipeCustomerCsvDefinition.filename), (0, cursor_loader_csv_fixture_1.createCsvInfrastructure)(9));
174
+ for await (const result of cursor) {
175
+ const row = projectedValue(result);
176
+ customers.push(readCustomer(row.result));
177
+ row.close();
178
+ }
179
+ expect(customers).toEqual([
180
+ {
181
+ id: 2001,
182
+ name: "Alice Pipe",
183
+ age: 40,
184
+ address: {
185
+ line1: "10 North | Road",
186
+ line2: "Wing | A",
187
+ postcode: "P1 1AA"
188
+ },
189
+ status: "A",
190
+ balance: 12.50
191
+ },
192
+ {
193
+ id: 2002,
194
+ name: "Bob Pipe",
195
+ age: 41,
196
+ address: {
197
+ line1: "20 South Road",
198
+ line2: "He said \"hello\"",
199
+ postcode: "P2 2BB"
200
+ },
201
+ status: "I",
202
+ balance: 20
203
+ },
204
+ {
205
+ id: 2003,
206
+ name: "Carol Pipe",
207
+ age: 42,
208
+ address: {
209
+ line1: "30 East Road",
210
+ line2: "",
211
+ postcode: "P3 3CC"
212
+ },
213
+ status: "A",
214
+ balance: 0
215
+ }
216
+ ]);
217
+ });
218
+ test("returns a physical-width row error and continues", async () => {
219
+ const results = [];
220
+ const cursor = (0, cursor_file_1.createFileCursor)(cursor_loader_csv_fixture_1.widthErrorCustomerCsvDefinition, (0, cursor_loader_csv_fixture_1.createCsvFixtureFile)(cursor_loader_csv_fixture_1.widthErrorCustomerCsvDefinition.filename), (0, cursor_loader_csv_fixture_1.createCsvInfrastructure)(7));
221
+ for await (const result of cursor) {
222
+ if (Array.isArray(result)) {
223
+ results.push(result);
224
+ continue;
225
+ }
226
+ results.push(result.result.id());
227
+ result.close();
228
+ }
229
+ expect(results).toEqual([
230
+ 1001,
231
+ [
232
+ "CSV record has 9 columns; header has 8"
233
+ ],
234
+ 1003
235
+ ]);
236
+ });
237
+ test("throws when a projected CSV column does not exist", async () => {
238
+ const cursor = (0, cursor_file_1.createFileCursor)(cursor_loader_csv_fixture_1.badHeaderCustomerCsvDefinition, (0, cursor_loader_csv_fixture_1.createCsvFixtureFile)(cursor_loader_csv_fixture_1.badHeaderCustomerCsvDefinition.filename), (0, cursor_loader_csv_fixture_1.createCsvInfrastructure)(7));
239
+ await expect(cursor.next()).rejects.toEqual(new Error('test.comma.bad-header.csv: record 1: '
240
+ + 'CSV column "addressLine2" does not exist. '
241
+ + 'Available columns: "id", "name", "age", "addressLine1", "status".'));
242
+ });
243
+ test("does not treat a newline inside an unterminated quoted field as a record boundary", async () => {
244
+ const cursor = (0, cursor_file_1.createFileCursor)(cursor_loader_csv_fixture_1.unterminatedCustomerCsvDefinition, (0, cursor_loader_csv_fixture_1.createCsvFixtureFile)(cursor_loader_csv_fixture_1.unterminatedCustomerCsvDefinition.filename), (0, cursor_loader_csv_fixture_1.createCsvInfrastructure)(7));
245
+ const first = await cursor.next();
246
+ if (first.done === true) {
247
+ throw new Error("Expected first CSV record");
248
+ }
249
+ if (Array.isArray(first.value)) {
250
+ throw new Error(`Expected projected value but got errors: ${first.value.join(", ")}`);
251
+ }
252
+ expect(first.value.result.id()).toBe(1001);
253
+ first.value.close();
254
+ await expect(cursor.next()).rejects.toEqual(new Error("test.comma.unterminated.csv: record 3: "
255
+ + "CSV column 4: unexpected byte after closing quote at logical byte 77"));
256
+ });
257
+ });
258
+ function projectedValue(result) {
259
+ if (Array.isArray(result)) {
260
+ throw new Error(`Expected projected value but got errors: ${result.join(", ")}`);
261
+ }
262
+ return result;
263
+ }
264
+ function readCustomer(customer) {
265
+ return {
266
+ id: customer.id(),
267
+ name: customer.name(),
268
+ age: customer.age(),
269
+ address: {
270
+ line1: customer.addressLine1(),
271
+ line2: customer.addressLine2(),
272
+ postcode: customer.postcode()
273
+ },
274
+ status: customer.status(),
275
+ balance: customer.balance()
276
+ };
277
+ }
278
+ function readMinimalCustomer(customer) {
279
+ return {
280
+ id: customer.id(),
281
+ status: customer.status()
282
+ };
283
+ }
284
+ //# sourceMappingURL=cursor.loader.csv.onefile.int.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.loader.csv.onefile.int.test.js","sourceRoot":"","sources":["../../src/cursor.loader.csv.onefile.int.test.ts"],"names":[],"mappings":";;AAAA,uDAG+B;AAO/B,2EAUqC;AAGrC,QAAQ,CAAC,6BAA6B,EAAC,GAAG,EAAE;IACxC,IAAI,CAAC,kDAAkD,EAAC,KAAK,IAAI,EAAE;QAC/D,MAAM,SAAS,GAAoB,EAAE,CAAC;QAEtC,MAAM,MAAM,GACR,IAAA,8BAAgB,EACZ,iDAAqB,EACrB,IAAA,gDAAoB,EAChB,iDAAqB,CAAC,QAAQ,CACjC,EACD,IAAA,mDAAuB,EAAC,CAAC,CAAC,CAC7B,CAAC;QAEN,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,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CAAC,IAAI,CAAC,EAAE,CAClE,CAAC;IACN,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAyBD,SAAS,YAAY,CACjB,QAAkB;IAElB,OAAO;QACH,EAAE,EACE,QAAQ,CAAC,EAAE,EAAE;QAEjB,IAAI,EACA,QAAQ,CAAC,IAAI,EAAE;QAEnB,GAAG,EACC,QAAQ,CAAC,GAAG,EAAE;QAElB,OAAO,EAAE;YACL,KAAK,EACD,QAAQ,CAAC,YAAY,EAAE;YAE3B,KAAK,EACD,QAAQ,CAAC,YAAY,EAAE;YAE3B,QAAQ,EACJ,QAAQ,CAAC,QAAQ,EAAE;SAC1B;QAED,MAAM,EACF,QAAQ,CAAC,MAAM,EAAE;QAErB,OAAO,EACH,QAAQ,CAAC,OAAO,EAAE;KACzB,CAAC;AACN,CAAC;AAGD,SAAS,mBAAmB,CACxB,QAAyB;IAEzB,OAAO;QACH,EAAE,EACE,QAAQ,CAAC,EAAE,EAAE;QAEjB,MAAM,EACF,QAAQ,CAAC,MAAM,EAAE;KACxB,CAAC;AACN,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface Customer {
2
+ id(): number;
3
+ name(): string;
4
+ age(): number;
5
+ addressLine1(): string;
6
+ addressLine2(): string;
7
+ postcode(): string;
8
+ status(): string;
9
+ balance(): number;
10
+ }
11
+ export interface MinimalCustomer {
12
+ id(): number;
13
+ status(): string;
14
+ }
15
+ export declare const customerProjection: import("@cobol-ts/cursor-loader-types").CanonicalProjection<import("@cobol-ts/cursor-loader-types").ProjectionDefinition<Customer>>;
16
+ export declare const minimalCustomerProjection: import("@cobol-ts/cursor-loader-types").CanonicalProjection<import("@cobol-ts/cursor-loader-types").ProjectionDefinition<MinimalCustomer>>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.minimalCustomerProjection = exports.customerProjection = void 0;
4
+ const cursor_projection_1 = require("@cobol-ts/cursor-projection");
5
+ exports.customerProjection = (0, cursor_projection_1.defineProjection)({
6
+ id: { type: "integer" },
7
+ name: { type: "string" },
8
+ age: { type: "integer" },
9
+ addressLine1: {
10
+ type: "string",
11
+ path: ["address", "line1"]
12
+ },
13
+ addressLine2: {
14
+ type: "string",
15
+ path: ["address", "line2"]
16
+ },
17
+ postcode: {
18
+ type: "string",
19
+ path: ["address", "postcode"]
20
+ },
21
+ status: { type: "character" },
22
+ balance: { type: "float" }
23
+ });
24
+ exports.minimalCustomerProjection = (0, cursor_projection_1.defineProjection)({
25
+ id: { type: "integer" },
26
+ status: { type: "character" }
27
+ });
28
+ //# sourceMappingURL=cursor.loader.fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.loader.fixture.js","sourceRoot":"","sources":["../../src/cursor.loader.fixture.ts"],"names":[],"mappings":";;;AAAA,mEAEqC;AAqBxB,QAAA,kBAAkB,GAAG,IAAA,oCAAgB,EAAW;IACzD,EAAE,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC;IACrB,IAAI,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;IACtB,GAAG,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC;IAEtB,YAAY,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC;KAC7B;IAED,YAAY,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC;KAC7B;IAED,QAAQ,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;KAChC;IAED,MAAM,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC;IAC3B,OAAO,EAAE,EAAC,IAAI,EAAE,OAAO,EAAC;CAC3B,CAAC,CAAC;AAGU,QAAA,yBAAyB,GAAG,IAAA,oCAAgB,EAAkB;IACvE,EAAE,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC;IACrB,MAAM,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC;CAC9B,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ export interface JsonlFixtureFile {
2
+ readonly bytes: Uint8Array;
3
+ offset: number;
4
+ }
5
+ export declare const customerJsonlDefinition: {
6
+ filename: string;
7
+ fileType: "json";
8
+ projection: import("@cobol-ts/cursor-loader-types").CanonicalProjection<import("@cobol-ts/cursor-loader-types").ProjectionDefinition<import("./cursor.loader.fixture").Customer>>;
9
+ };
10
+ export declare const minimalCustomerJsonlDefinition: {
11
+ filename: string;
12
+ fileType: "json";
13
+ projection: import("@cobol-ts/cursor-loader-types").CanonicalProjection<import("@cobol-ts/cursor-loader-types").ProjectionDefinition<import("./cursor.loader.fixture").MinimalCustomer>>;
14
+ };
15
+ export declare const badJsonCustomerJsonlDefinition: {
16
+ filename: string;
17
+ fileType: "json";
18
+ projection: import("@cobol-ts/cursor-loader-types").CanonicalProjection<import("@cobol-ts/cursor-loader-types").ProjectionDefinition<import("./cursor.loader.fixture").Customer>>;
19
+ };
20
+ export declare const lazyErrorCustomerJsonlDefinition: {
21
+ filename: string;
22
+ fileType: "json";
23
+ projection: import("@cobol-ts/cursor-loader-types").CanonicalProjection<import("@cobol-ts/cursor-loader-types").ProjectionDefinition<import("./cursor.loader.fixture").Customer>>;
24
+ };
25
+ export declare function createJsonlFixtureFile(filename: string): JsonlFixtureFile;
26
+ export declare function createJsonlInfrastructure(bufferSize: number): {
27
+ parsers: {
28
+ json: {
29
+ parser: {
30
+ toDebugString: typeof import("@cobol-ts/cursor-loader-types").utf8RangeToString;
31
+ parse: (record: import("@cobol-ts/cursor-loader-types").ParserPhysicalRecordContent<unknown>, _details: undefined) => Promise<import("@cobol-ts/cursor-loader-types").ParserResult<import("@cobol-ts/cursor-loader-json").JsonValue>>;
32
+ compileProjectionPath: (_details: undefined, _context: import("@cobol-ts/cursor-loader-types").PhysicalRecordContext | undefined, path: readonly (string | number)[]) => readonly string[];
33
+ object(representation: import("@cobol-ts/cursor-loader-json").JsonValue, _details: undefined, path: readonly string[]): import("@cobol-ts/cursor-loader-json").JsonValue;
34
+ array(representation: import("@cobol-ts/cursor-loader-json").JsonValue, _details: undefined, path: readonly string[]): import("@cobol-ts/arrays").ProjectedArraySource<import("@cobol-ts/cursor-loader-json").JsonValue>;
35
+ integer(representation: unknown, _details: undefined, path: readonly string[], ...occurrenceIndices: number[]): number;
36
+ float(representation: unknown, _details: undefined, path: readonly string[], ...occurrenceIndices: number[]): number;
37
+ character(representation: unknown, _details: undefined, path: readonly string[], ...occurrenceIndices: number[]): string;
38
+ string(representation: unknown, _details: undefined, path: readonly string[], ...occurrenceIndices: number[]): string;
39
+ };
40
+ parserConfig: () => undefined;
41
+ createRecordState: () => import("@cobol-ts/cursor-loader-json").JsonRecordState;
42
+ };
43
+ };
44
+ bufferSize: number;
45
+ fillFileBuffer: (file: JsonlFixtureFile, target: Uint8Array) => Promise<number>;
46
+ };
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lazyErrorCustomerJsonlDefinition = exports.badJsonCustomerJsonlDefinition = exports.minimalCustomerJsonlDefinition = exports.customerJsonlDefinition = void 0;
4
+ exports.createJsonlFixtureFile = createJsonlFixtureFile;
5
+ exports.createJsonlInfrastructure = createJsonlInfrastructure;
6
+ const cursor_loader_json_1 = require("@cobol-ts/cursor-loader-json");
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = require("node:path");
9
+ const cursor_loader_fixture_1 = require("./cursor.loader.fixture");
10
+ exports.customerJsonlDefinition = {
11
+ filename: "test.customer.jsonl",
12
+ fileType: "json",
13
+ projection: cursor_loader_fixture_1.customerProjection
14
+ };
15
+ exports.minimalCustomerJsonlDefinition = {
16
+ filename: "test.customer.jsonl",
17
+ fileType: "json",
18
+ projection: cursor_loader_fixture_1.minimalCustomerProjection
19
+ };
20
+ exports.badJsonCustomerJsonlDefinition = {
21
+ filename: "test.customer.bad-json.jsonl",
22
+ fileType: "json",
23
+ projection: cursor_loader_fixture_1.customerProjection
24
+ };
25
+ exports.lazyErrorCustomerJsonlDefinition = {
26
+ filename: "test.customer.lazy-error.jsonl",
27
+ fileType: "json",
28
+ projection: cursor_loader_fixture_1.customerProjection
29
+ };
30
+ const parserRegistry = {
31
+ json: {
32
+ parser: cursor_loader_json_1.jsonParser,
33
+ parserConfig: () => undefined,
34
+ createRecordState: cursor_loader_json_1.createJsonRecordState
35
+ }
36
+ };
37
+ function createJsonlFixtureFile(filename) {
38
+ const buffer = (0, node_fs_1.readFileSync)((0, node_path_1.resolve)(process.cwd(), filename));
39
+ return {
40
+ bytes: new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength),
41
+ offset: 0
42
+ };
43
+ }
44
+ function createJsonlInfrastructure(bufferSize) {
45
+ return {
46
+ parsers: parserRegistry,
47
+ bufferSize,
48
+ fillFileBuffer: async (file, target) => {
49
+ const available = file.bytes.length
50
+ - file.offset;
51
+ const count = Math.min(target.length, available);
52
+ if (count !== 0) {
53
+ target.set(file.bytes.subarray(file.offset, file.offset + count));
54
+ file.offset += count;
55
+ }
56
+ return count;
57
+ }
58
+ };
59
+ }
60
+ //# sourceMappingURL=cursor.loader.jsonl.fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.loader.jsonl.fixture.js","sourceRoot":"","sources":["../../src/cursor.loader.jsonl.fixture.ts"],"names":[],"mappings":";;;AAqDA,wDAsBC;AAGD,8DAsCC;AApHD,qEAA+E;AAC/E,qCAAqC;AACrC,yCAAkC;AAElC,mEAGiC;AASpB,QAAA,uBAAuB,GAAG;IACnC,QAAQ,EAAE,qBAAqB;IAC/B,QAAQ,EAAE,MAAe;IACzB,UAAU,EAAE,0CAAkB;CACjC,CAAC;AAGW,QAAA,8BAA8B,GAAG;IAC1C,QAAQ,EAAE,qBAAqB;IAC/B,QAAQ,EAAE,MAAe;IACzB,UAAU,EAAE,iDAAyB;CACxC,CAAC;AAGW,QAAA,8BAA8B,GAA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