@gobing-ai/ts-llm-jsonl-importer 0.2.8 → 0.2.9
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 +2 -1
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +9 -0
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +3 -2
- package/dist/importer.d.ts.map +1 -1
- package/dist/importer.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +4 -3
- package/src/errors.ts +10 -0
- package/src/hash.ts +3 -2
- package/src/importer.ts +2 -1
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -40,7 +40,8 @@ const result = await runJsonlImport('codex', {
|
|
|
40
40
|
mode: 'incremental',
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
result.importedRecords;
|
|
44
|
+
result.skippedDuplicates;
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
`runJsonlImport()` applies the package-owned schema automatically before processing. Use `applyHistoryImportSchema(db)` directly when your application has an explicit migration step.
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Error raised for invalid importer configuration or unsafe generated SQL identifiers. */
|
|
2
|
+
export declare class HistoryImportError extends Error {
|
|
3
|
+
readonly details?: unknown | undefined;
|
|
4
|
+
constructor(message: string, details?: unknown | undefined);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,qBAAa,kBAAmB,SAAQ,KAAK;IAGrC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO;gBAD1B,OAAO,EAAE,MAAM,EACN,OAAO,CAAC,EAAE,OAAO,YAAA;CAKjC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Error raised for invalid importer configuration or unsafe generated SQL identifiers. */
|
|
2
|
+
export class HistoryImportError extends Error {
|
|
3
|
+
details;
|
|
4
|
+
constructor(message, details) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.details = details;
|
|
7
|
+
this.name = 'HistoryImportError';
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/hash.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAEA,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAEA,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAajD;AAED,+DAA+D;AAC/D,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE7C"}
|
package/dist/hash.js
CHANGED
|
@@ -2,16 +2,17 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
/** Serialize JSON with sorted object keys so equivalent records hash identically. */
|
|
3
3
|
export function stableJson(value) {
|
|
4
4
|
if (Array.isArray(value)) {
|
|
5
|
-
return `[${value.map((entry) => stableJson(entry)).join(',')}]`;
|
|
5
|
+
return `[${value.map((entry) => (entry === undefined ? 'null' : stableJson(entry))).join(',')}]`;
|
|
6
6
|
}
|
|
7
7
|
if (value !== null && typeof value === 'object') {
|
|
8
8
|
const record = value;
|
|
9
9
|
return `{${Object.keys(record)
|
|
10
|
+
.filter((key) => record[key] !== undefined)
|
|
10
11
|
.sort()
|
|
11
12
|
.map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`)
|
|
12
13
|
.join(',')}}`;
|
|
13
14
|
}
|
|
14
|
-
return JSON.stringify(value);
|
|
15
|
+
return JSON.stringify(value) ?? 'null';
|
|
15
16
|
}
|
|
16
17
|
/** Compute a SHA-256 hash for an already-normalized record. */
|
|
17
18
|
export function sha256(value) {
|
package/dist/importer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../src/importer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../src/importer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAER,aAAa,EACb,YAAY,EAEZ,cAAc,EAGjB,MAAM,SAAS,CAAC;AAajB,0DAA0D;AAC1D,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAOrF;AAED,+DAA+D;AAC/D,wBAAsB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA4G1G"}
|
package/dist/importer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { getFs, walkDir } from '@gobing-ai/ts-runtime';
|
|
3
|
+
import { HistoryImportError } from './errors.js';
|
|
3
4
|
import { sha256 } from './hash.js';
|
|
4
5
|
import { redactRecord } from './redaction.js';
|
|
5
6
|
import { HISTORY_IMPORT_SCHEMA_SQL } from './schema-sql.js';
|
|
@@ -217,7 +218,7 @@ async function insertLedger(db, recordHash, source, sourceFile, sourceLine, spli
|
|
|
217
218
|
}
|
|
218
219
|
function targetTableFor(table) {
|
|
219
220
|
if (!VALID_TABLE_NAME.test(table)) {
|
|
220
|
-
throw new
|
|
221
|
+
throw new HistoryImportError(`Invalid history ETL target table: ${table}`, { table });
|
|
221
222
|
}
|
|
222
223
|
return table;
|
|
223
224
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpE,YAAY,EACR,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GACnB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpE,YAAY,EACR,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GACnB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-llm-jsonl-importer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "@gobing-ai/ts-llm-jsonl-importer — Generic JSONL importer for LLM agent history files.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -47,8 +47,9 @@
|
|
|
47
47
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-llm-jsonl-importer-v<version> && git push --tags' && exit 1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@gobing-ai/ts-db": "^0.2.
|
|
51
|
-
"@gobing-ai/ts-runtime": "^0.2.
|
|
50
|
+
"@gobing-ai/ts-db": "^0.2.9",
|
|
51
|
+
"@gobing-ai/ts-runtime": "^0.2.9",
|
|
52
|
+
"@gobing-ai/ts-utils": "^0.2.9",
|
|
52
53
|
"zod": "^4.1.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Error raised for invalid importer configuration or unsafe generated SQL identifiers. */
|
|
2
|
+
export class HistoryImportError extends Error {
|
|
3
|
+
constructor(
|
|
4
|
+
message: string,
|
|
5
|
+
readonly details?: unknown,
|
|
6
|
+
) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'HistoryImportError';
|
|
9
|
+
}
|
|
10
|
+
}
|
package/src/hash.ts
CHANGED
|
@@ -3,16 +3,17 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
/** Serialize JSON with sorted object keys so equivalent records hash identically. */
|
|
4
4
|
export function stableJson(value: unknown): string {
|
|
5
5
|
if (Array.isArray(value)) {
|
|
6
|
-
return `[${value.map((entry) => stableJson(entry)).join(',')}]`;
|
|
6
|
+
return `[${value.map((entry) => (entry === undefined ? 'null' : stableJson(entry))).join(',')}]`;
|
|
7
7
|
}
|
|
8
8
|
if (value !== null && typeof value === 'object') {
|
|
9
9
|
const record = value as Record<string, unknown>;
|
|
10
10
|
return `{${Object.keys(record)
|
|
11
|
+
.filter((key) => record[key] !== undefined)
|
|
11
12
|
.sort()
|
|
12
13
|
.map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`)
|
|
13
14
|
.join(',')}}`;
|
|
14
15
|
}
|
|
15
|
-
return JSON.stringify(value);
|
|
16
|
+
return JSON.stringify(value) ?? 'null';
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/** Compute a SHA-256 hash for an already-normalized record. */
|
package/src/importer.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { getFs, walkDir } from '@gobing-ai/ts-runtime';
|
|
3
|
+
import { HistoryImportError } from './errors';
|
|
3
4
|
import { sha256 } from './hash';
|
|
4
5
|
import { redactRecord } from './redaction';
|
|
5
6
|
import { HISTORY_IMPORT_SCHEMA_SQL } from './schema-sql';
|
|
@@ -332,7 +333,7 @@ async function insertLedger(
|
|
|
332
333
|
|
|
333
334
|
function targetTableFor(table: string): string {
|
|
334
335
|
if (!VALID_TABLE_NAME.test(table)) {
|
|
335
|
-
throw new
|
|
336
|
+
throw new HistoryImportError(`Invalid history ETL target table: ${table}`, { table });
|
|
336
337
|
}
|
|
337
338
|
return table;
|
|
338
339
|
}
|
package/src/index.ts
CHANGED