@danypops/papyrus 0.29.8 → 0.30.0
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/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Db } from "../db.ts";
|
|
2
2
|
import { inTransaction } from "../db.ts";
|
|
3
3
|
import type { AtomicArtifactStore } from "../ports/atomic-artifact-store.ts";
|
|
4
|
+
import type { ArtifactEventReader } from "../ports/artifact-event-reader.ts";
|
|
5
|
+
import type { ArtifactTrashStore } from "../ports/artifact-trash-store.ts";
|
|
4
6
|
import type {
|
|
5
7
|
Artifact,
|
|
6
8
|
ArtifactEdge,
|
|
@@ -30,7 +32,7 @@ import {
|
|
|
30
32
|
updateStatus,
|
|
31
33
|
} from "../ops.ts";
|
|
32
34
|
|
|
33
|
-
export class SQLiteArtifactStore implements AtomicArtifactStore {
|
|
35
|
+
export class SQLiteArtifactStore implements AtomicArtifactStore, ArtifactTrashStore, ArtifactEventReader {
|
|
34
36
|
constructor(private readonly db: Db) {}
|
|
35
37
|
|
|
36
38
|
atomic<T>(operation: () => T): T {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArtifactEventPage, ArtifactEventQuery } from "../domain/artifact-event.ts";
|
|
2
|
+
|
|
3
|
+
/** Read access to the generic mutation event log shared by every kind -- split out of
|
|
4
|
+
* ArtifactStore since only service.ts's graph.history operation reads it. */
|
|
5
|
+
export interface ArtifactEventReader {
|
|
6
|
+
/** Bounded query over the generic mutation event log shared by every kind. */
|
|
7
|
+
events(query: ArtifactEventQuery): ArtifactEventPage;
|
|
8
|
+
}
|
|
@@ -8,9 +8,11 @@ import type {
|
|
|
8
8
|
RelationshipQuery,
|
|
9
9
|
UpdateArtifactInput,
|
|
10
10
|
} from "../domain/artifact.ts";
|
|
11
|
-
import type { ArtifactEventContext
|
|
12
|
-
import type { ArtifactTrashRecord } from "../domain/artifact-trash.ts";
|
|
11
|
+
import type { ArtifactEventContext } from "../domain/artifact-event.ts";
|
|
13
12
|
|
|
13
|
+
/** Core CRUD/graph operations every domain-service module needs. Trash lifecycle and event-log
|
|
14
|
+
* reading are separate ports (ArtifactTrashStore, ArtifactEventReader) -- only the composition
|
|
15
|
+
* root (daemon.ts, service.ts) needs those, not every consumer of this store. */
|
|
14
16
|
export interface ArtifactStore {
|
|
15
17
|
create(input: CreateArtifactInput, context?: ArtifactEventContext): Artifact;
|
|
16
18
|
get(id: string, options?: ArtifactGraphOptions): Artifact | null;
|
|
@@ -22,14 +24,4 @@ export interface ArtifactStore {
|
|
|
22
24
|
setExtra(id: string, extra: Record<string, unknown>, context?: ArtifactEventContext): Artifact | null;
|
|
23
25
|
updateContent(id: string, input: UpdateArtifactInput, context?: ArtifactEventContext): Artifact | null;
|
|
24
26
|
relationships(filter?: RelationshipQuery): ArtifactEdge[];
|
|
25
|
-
/** Bounded query over the generic mutation event log shared by every kind. */
|
|
26
|
-
events(query: ArtifactEventQuery): ArtifactEventPage;
|
|
27
|
-
/** See domain/artifact-trash.ts. Moves an artifact to the trash; throws if it does not exist or is the live Task Focus in any scope. */
|
|
28
|
-
trash(id: string, options?: { reason?: string; context?: ArtifactEventContext }): ArtifactTrashRecord;
|
|
29
|
-
/** Idempotent: restoring an artifact that is not currently trashed is a real no-op. */
|
|
30
|
-
restore(id: string, context?: ArtifactEventContext): { restored: boolean };
|
|
31
|
-
trashStatus(id: string): ArtifactTrashRecord | null;
|
|
32
|
-
listTrash(): ArtifactTrashRecord[];
|
|
33
|
-
/** Real, cascading, irreversible deletion of every artifact past its purge deadline; returns how many were purged. */
|
|
34
|
-
purgeDueTrash(): number;
|
|
35
27
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ArtifactEventContext } from "../domain/artifact-event.ts";
|
|
2
|
+
import type { ArtifactTrashRecord } from "../domain/artifact-trash.ts";
|
|
3
|
+
|
|
4
|
+
/** Trash lifecycle for artifacts -- split out of ArtifactStore since only the composition root
|
|
5
|
+
* (daemon.ts, service.ts) needs it; every domain-service module depends on core CRUD/graph only. */
|
|
6
|
+
export interface ArtifactTrashStore {
|
|
7
|
+
/** See domain/artifact-trash.ts. Moves an artifact to the trash; throws if it does not exist or is the live Task Focus in any scope. */
|
|
8
|
+
trash(id: string, options?: { reason?: string; context?: ArtifactEventContext }): ArtifactTrashRecord;
|
|
9
|
+
/** Idempotent: restoring an artifact that is not currently trashed is a real no-op. */
|
|
10
|
+
restore(id: string, context?: ArtifactEventContext): { restored: boolean };
|
|
11
|
+
trashStatus(id: string): ArtifactTrashRecord | null;
|
|
12
|
+
listTrash(): ArtifactTrashRecord[];
|
|
13
|
+
/** Real, cascading, irreversible deletion of every artifact past its purge deadline; returns how many were purged. */
|
|
14
|
+
purgeDueTrash(): number;
|
|
15
|
+
}
|
package/src/service.ts
CHANGED
|
@@ -14,6 +14,8 @@ import { AuthorityRegistry, AuthorizedArtifactWriter, type AuthorityClaim } from
|
|
|
14
14
|
import type { TaskEventContext } from "./domain/task-event.ts";
|
|
15
15
|
import type { TaskViewMode } from "./domain/task-scope.ts";
|
|
16
16
|
import type { ArtifactStore } from "./ports/artifact-store.ts";
|
|
17
|
+
import type { ArtifactEventReader } from "./ports/artifact-event-reader.ts";
|
|
18
|
+
import type { ArtifactTrashStore } from "./ports/artifact-trash-store.ts";
|
|
17
19
|
import type { GateRunner } from "./ports/gate-runner.ts";
|
|
18
20
|
import type { TaskEventStore } from "./ports/task-event-store.ts";
|
|
19
21
|
import type { TaskScopeStore } from "./ports/task-scope-store.ts";
|
|
@@ -187,7 +189,10 @@ export interface PapyrusService {
|
|
|
187
189
|
}
|
|
188
190
|
|
|
189
191
|
function handlers(
|
|
190
|
-
|
|
192
|
+
// The composition root's own handler table -- the one place that genuinely needs trash
|
|
193
|
+
// lifecycle and event-log reading alongside core CRUD/graph, unlike every domain-service
|
|
194
|
+
// module (which only ever depends on the narrower ArtifactStore).
|
|
195
|
+
artifacts: ArtifactStore & ArtifactTrashStore & ArtifactEventReader,
|
|
191
196
|
gates: GateRunner,
|
|
192
197
|
tasks: Tasks,
|
|
193
198
|
notes: Notes,
|