@druumen/sessions-db 0.1.0 → 0.1.3
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/CHANGELOG.md +254 -1
- package/README.md +28 -0
- package/lib/index.cjs +1699 -0
- package/package.json +28 -7
- package/types/index.d.cts +62 -0
- package/types/index.d.ts +30 -96
package/package.json
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@druumen/sessions-db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Cross-session traceability for Claude Code — events.jsonl SSoT + JSON projection cache + 3-priority identity reconciliation",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "./lib/index.
|
|
7
|
+
"main": "./lib/index.cjs",
|
|
8
|
+
"module": "./lib/index.mjs",
|
|
8
9
|
"types": "./types/index.d.ts",
|
|
9
10
|
"bin": {
|
|
10
11
|
"sessions-db": "./cli/sessions-db.mjs",
|
|
11
12
|
"sessions-db-session-start": "./cli/sessions-db-session-start.mjs"
|
|
12
13
|
},
|
|
13
14
|
"exports": {
|
|
14
|
-
".":
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./types/index.d.ts",
|
|
18
|
+
"default": "./lib/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./types/index.d.cts",
|
|
22
|
+
"default": "./lib/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"default": "./lib/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./cli": {
|
|
27
|
+
"import": "./cli/sessions-db.mjs",
|
|
28
|
+
"default": "./cli/sessions-db.mjs"
|
|
29
|
+
},
|
|
30
|
+
"./hook": {
|
|
31
|
+
"import": "./cli/sessions-db-session-start.mjs",
|
|
32
|
+
"default": "./cli/sessions-db-session-start.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
17
35
|
},
|
|
18
36
|
"files": [
|
|
19
37
|
"lib/",
|
|
@@ -29,7 +47,7 @@
|
|
|
29
47
|
},
|
|
30
48
|
"repository": {
|
|
31
49
|
"type": "git",
|
|
32
|
-
"url": "git+
|
|
50
|
+
"url": "git+https://github.com/druumen/sessions-db.git"
|
|
33
51
|
},
|
|
34
52
|
"bugs": {
|
|
35
53
|
"email": "security@druumen.com"
|
|
@@ -44,10 +62,13 @@
|
|
|
44
62
|
"scripts": {
|
|
45
63
|
"test": "find __tests__ -name '*.test.mjs' -type f -print0 | xargs -0 node --test",
|
|
46
64
|
"build:types": "tsc -p tsconfig.json",
|
|
65
|
+
"build:cjs": "esbuild lib/index.mjs --bundle --format=cjs --platform=node --target=node18 --outfile=lib/index.cjs",
|
|
66
|
+
"build": "npm run build:types && npm run build:cjs",
|
|
47
67
|
"check:types-smoke": "tsc --noEmit -p __tests__/types-smoke/tsconfig.json",
|
|
48
|
-
"prepublishOnly": "npm run build
|
|
68
|
+
"prepublishOnly": "npm run build"
|
|
49
69
|
},
|
|
50
70
|
"devDependencies": {
|
|
71
|
+
"esbuild": "^0.25.12",
|
|
51
72
|
"typescript": "^5.9.3"
|
|
52
73
|
}
|
|
53
74
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @druumen/sessions-db — public TypeScript entry point for CJS consumers.
|
|
3
|
+
*
|
|
4
|
+
* This is the `.d.cts` sibling of `./index.d.ts`. Both have the same
|
|
5
|
+
* value + type re-export shape; the only difference is the extension,
|
|
6
|
+
* which tells TypeScript Node16/NodeNext module resolution that the
|
|
7
|
+
* underlying runtime module is CJS.
|
|
8
|
+
*
|
|
9
|
+
* Without this file, a consumer with `moduleResolution: "Node16"` in
|
|
10
|
+
* a CJS context (no `"type": "module"` in their package.json) hits
|
|
11
|
+
* `TS1479` because the Node16 resolver picks the `import` condition's
|
|
12
|
+
* `.d.mts` types — which TS treats as "ESM origin" — and refuses to
|
|
13
|
+
* `require()` them from CJS.
|
|
14
|
+
*
|
|
15
|
+
* `package.json` exports map nests `types` per runtime condition:
|
|
16
|
+
*
|
|
17
|
+
* "exports": {
|
|
18
|
+
* ".": {
|
|
19
|
+
* "import": { "types": "./types/index.d.ts", ... },
|
|
20
|
+
* "require": { "types": "./types/index.d.cts", ... }
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* This was added in 0.1.1 as part of the cockpit B1 packaging fix.
|
|
25
|
+
*
|
|
26
|
+
* NOTE on file content: identical to `index.d.ts` except for the
|
|
27
|
+
* extension. The runtime IS bundled into a single `lib/index.cjs`
|
|
28
|
+
* (esbuild) so type signatures match across both .d.mts re-exports
|
|
29
|
+
* (ESM source paths) and the .cjs bundle (which contains the same
|
|
30
|
+
* symbols).
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
// Runtime VALUES (functions + constants) + their inferred TypeScript types,
|
|
34
|
+
// from the auto-emitted mirror of `lib/index.mjs`. Same source-of-truth as
|
|
35
|
+
// the .d.ts barrel; the .cts extension flips TS's runtime-origin assumption
|
|
36
|
+
// to CJS, matching the actual `lib/index.cjs` bundle that the require()
|
|
37
|
+
// condition resolves at runtime.
|
|
38
|
+
export * from './index.d.mts';
|
|
39
|
+
|
|
40
|
+
// TYPE NAMES (branded scalars, enums, composite shapes), from the
|
|
41
|
+
// auto-emitted mirror of `lib/types.mjs`'s @typedef block.
|
|
42
|
+
export type {
|
|
43
|
+
// Branded scalars
|
|
44
|
+
SessionStableId,
|
|
45
|
+
ClaudeSessionId,
|
|
46
|
+
EventId,
|
|
47
|
+
Iso8601,
|
|
48
|
+
// Enums
|
|
49
|
+
ActivityState,
|
|
50
|
+
Outcome,
|
|
51
|
+
IdentitySource,
|
|
52
|
+
IdentityConfidence,
|
|
53
|
+
EventOp,
|
|
54
|
+
// Composite shapes
|
|
55
|
+
TranscriptFile,
|
|
56
|
+
IdentityResolution,
|
|
57
|
+
ParentCandidate,
|
|
58
|
+
KnownSession,
|
|
59
|
+
ProjectionMeta,
|
|
60
|
+
Projection,
|
|
61
|
+
SessionEvent,
|
|
62
|
+
} from './types.d.mts';
|
package/types/index.d.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @druumen/sessions-db — public TypeScript entry point.
|
|
2
|
+
* @druumen/sessions-db — public TypeScript entry point (hand-crafted barrel).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* (because the sources are `.mjs`); this `.d.ts` curates the public type
|
|
7
|
-
* surface so cockpit-class consumers can write:
|
|
4
|
+
* Stitches together the two files that `tsc --emitDeclarationOnly` produces
|
|
5
|
+
* from the JS source so consumers get one curated import surface:
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
7
|
+
* - `./index.d.mts` — value re-exports mirroring `lib/index.mjs` (run-
|
|
8
|
+
* time functions + constants, with their TypeScript type signatures).
|
|
9
|
+
* - `./types.d.mts` — type declarations lifted from the `@typedef`
|
|
10
|
+
* block in `lib/types.mjs` (branded scalars, enums, composite shapes).
|
|
11
|
+
*
|
|
12
|
+
* Two files exist because `lib/index.mjs` is plain JS — it can re-export
|
|
13
|
+
* runtime symbols but not `export type` (TypeScript-only syntax). This
|
|
14
|
+
* file does the type-side stitching that JS cannot.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* `package.json` `"types"` and `exports[".".types]` both point here.
|
|
17
|
+
* `tsc` never overwrites this file — it emits `.d.mts` for `.mjs`
|
|
18
|
+
* sources, so the `.d.ts` extension keeps it out of the build path.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
* (re-exports happen on Day 3 — once the public *function* surface is
|
|
22
|
-
* settled). This `.d.ts` is safe to ship today because it is types-only
|
|
23
|
-
* and has zero runtime side effects.
|
|
20
|
+
* Cockpit / consumer pattern:
|
|
24
21
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* import {
|
|
23
|
+
* loadProjection, // runtime value
|
|
24
|
+
* setAlias, // runtime value
|
|
25
|
+
* type KnownSession, // type
|
|
26
|
+
* type Projection, // type
|
|
27
|
+
* } from '@druumen/sessions-db';
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
29
|
+
* This barrel was added in 0.1.1 to fix Bug B from 0.1.0, where the
|
|
30
|
+
* previous hand-crafted file used `export type X = typeof import('...')`
|
|
31
|
+
* patterns that re-exported type aliases instead of values, breaking
|
|
32
|
+
* `import { loadProjection }` for cockpit-class consumers under Node16.
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
// surface for cockpit consumers.
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
35
|
+
// Runtime VALUES (functions + constants) + their inferred TypeScript types,
|
|
36
|
+
// from the auto-emitted mirror of `lib/index.mjs`.
|
|
37
|
+
export * from './index.d.mts';
|
|
40
38
|
|
|
39
|
+
// TYPE NAMES (branded scalars, enums, composite shapes), from the
|
|
40
|
+
// auto-emitted mirror of `lib/types.mjs`'s @typedef block.
|
|
41
41
|
export type {
|
|
42
42
|
// Branded scalars
|
|
43
43
|
SessionStableId,
|
|
@@ -59,69 +59,3 @@ export type {
|
|
|
59
59
|
Projection,
|
|
60
60
|
SessionEvent,
|
|
61
61
|
} from './types.d.mts';
|
|
62
|
-
|
|
63
|
-
// ---------------------------------------------------------------------------
|
|
64
|
-
// Function signatures — re-exported from per-source `.d.mts` neighbours.
|
|
65
|
-
//
|
|
66
|
-
// We re-export TYPES of functions (typeof) rather than the runtime symbols
|
|
67
|
-
// because Day 2 keeps `lib/index.mjs` a runtime stub. Day 3 will flip
|
|
68
|
-
// `lib/index.mjs` into a real re-export hub and at that point `tsc` will
|
|
69
|
-
// regenerate `types/index.d.mts` with the same shape — but consumers who
|
|
70
|
-
// imported through this `.d.ts` see no breakage because the type names
|
|
71
|
-
// are identical.
|
|
72
|
-
//
|
|
73
|
-
// The `typeof import(...)` pattern is the standard TypeScript ambient
|
|
74
|
-
// re-export when the source is JS-with-JSDoc.
|
|
75
|
-
// ---------------------------------------------------------------------------
|
|
76
|
-
|
|
77
|
-
// uuid.mjs
|
|
78
|
-
export type GenerateSessionId = typeof import('./uuid.d.mts').generateSessionId;
|
|
79
|
-
export type IsSessionId = typeof import('./uuid.d.mts').isSessionId;
|
|
80
|
-
export type ExtractTimestamp = typeof import('./uuid.d.mts').extractTimestamp;
|
|
81
|
-
|
|
82
|
-
// projection.mjs
|
|
83
|
-
export type ApplyEvent = typeof import('./projection.d.mts').applyEvent;
|
|
84
|
-
export type EmptyProjection = typeof import('./projection.d.mts').emptyProjection;
|
|
85
|
-
export type EmptySession = typeof import('./projection.d.mts').emptySession;
|
|
86
|
-
export type RebuildFromEvents = typeof import('./projection.d.mts').rebuildFromEvents;
|
|
87
|
-
|
|
88
|
-
// storage.mjs
|
|
89
|
-
export type NewEvent = typeof import('./storage.d.mts').newEvent;
|
|
90
|
-
export type AppendEvent = typeof import('./storage.d.mts').appendEvent;
|
|
91
|
-
export type ReadAllEvents = typeof import('./storage.d.mts').readAllEvents;
|
|
92
|
-
export type LoadProjection = typeof import('./storage.d.mts').loadProjection;
|
|
93
|
-
export type SaveProjection = typeof import('./storage.d.mts').saveProjection;
|
|
94
|
-
export type RebuildProjection = typeof import('./storage.d.mts').rebuildProjection;
|
|
95
|
-
export type TryUpdateProjection = typeof import('./storage.d.mts').tryUpdateProjection;
|
|
96
|
-
export type RecordSessionSeen = typeof import('./storage.d.mts').recordSessionSeen;
|
|
97
|
-
|
|
98
|
-
// identity.mjs
|
|
99
|
-
export type ResolveIdentity = typeof import('./identity.d.mts').resolveIdentity;
|
|
100
|
-
export type FindByClaudeSessionId = typeof import('./identity.d.mts').findByClaudeSessionId;
|
|
101
|
-
export type FindByTranscriptLineage = typeof import('./identity.d.mts').findByTranscriptLineage;
|
|
102
|
-
export type ScanFingerprintCandidates = typeof import('./identity.d.mts').scanFingerprintCandidates;
|
|
103
|
-
export type CollectParentCandidates = typeof import('./identity.d.mts').collectParentCandidates;
|
|
104
|
-
export type CapParentCandidates = typeof import('./identity.d.mts').capParentCandidates;
|
|
105
|
-
export type ClassifyCorroborators = typeof import('./identity.d.mts').classifyCorroborators;
|
|
106
|
-
export type MeetsThreshold = typeof import('./identity.d.mts').meetsThreshold;
|
|
107
|
-
|
|
108
|
-
// sweep.mjs
|
|
109
|
-
export type ComputeSweepTransitions = typeof import('./sweep.d.mts').computeSweepTransitions;
|
|
110
|
-
export type ComputeEffectiveLastProgress = typeof import('./sweep.d.mts').computeEffectiveLastProgress;
|
|
111
|
-
|
|
112
|
-
// sanitize.mjs
|
|
113
|
-
export type SanitizeFirstPrompt = typeof import('./sanitize.d.mts').sanitizeFirstPrompt;
|
|
114
|
-
export type StripSystemReminders = typeof import('./sanitize.d.mts').stripSystemReminders;
|
|
115
|
-
export type StripIdeWrappers = typeof import('./sanitize.d.mts').stripIdeWrappers;
|
|
116
|
-
|
|
117
|
-
// transcript.mjs
|
|
118
|
-
export type ParseTranscriptFile = typeof import('./transcript.d.mts').parseTranscriptFile;
|
|
119
|
-
export type ListTranscriptFiles = typeof import('./transcript.d.mts').listTranscriptFiles;
|
|
120
|
-
export type WorkspaceHashFromCwd = typeof import('./transcript.d.mts').workspaceHashFromCwd;
|
|
121
|
-
|
|
122
|
-
// git-context.mjs
|
|
123
|
-
export type GitContextFn = typeof import('./git-context.d.mts').gitContext;
|
|
124
|
-
|
|
125
|
-
// paths.mjs (Day 4 — storage path resolution chain)
|
|
126
|
-
export type ResolveStoragePaths = typeof import('./paths.d.mts').resolveStoragePaths;
|
|
127
|
-
export type PathsFromRoot = typeof import('./paths.d.mts').pathsFromRoot;
|