@absolutejs/artifacts 0.1.0 → 0.1.1
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 +5 -0
- package/dist/drizzle.js +7 -0
- package/dist/index.js +13 -0
- package/dist/src/manifest.d.ts +3 -0
- package/dist/src/service.d.ts +1 -0
- package/dist/src/store.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,6 +108,11 @@ normal migration workflow owns the four tables. Insert and select TypeBoxes
|
|
|
108
108
|
generated directly from those tables are exported from the same entry point;
|
|
109
109
|
hosts should reuse them instead of redefining database row schemas.
|
|
110
110
|
|
|
111
|
+
When a host owner is permanently deleted, call `artifacts.purgeOwner(ownerId)`.
|
|
112
|
+
The production store removes its current records, revisions, indexing state,
|
|
113
|
+
and outbox events in one transaction; orphaned asset bytes remain subject to
|
|
114
|
+
the package's history-aware garbage collector.
|
|
115
|
+
|
|
111
116
|
## File-backed artifact kinds
|
|
112
117
|
|
|
113
118
|
Use the bundled definitions directly or compose them with application-specific
|
package/dist/drizzle.js
CHANGED
|
@@ -216,6 +216,13 @@ var createDrizzleArtifactStore = (options) => ({
|
|
|
216
216
|
if (events.length > 0)
|
|
217
217
|
await transaction.insert(artifactEvents).values(eventRows(events));
|
|
218
218
|
}),
|
|
219
|
+
purgeOwner: (ownerId) => options.db.transaction(async (transaction) => {
|
|
220
|
+
await transaction.delete(artifactIndexingStates).where(eq(artifactIndexingStates.ownerId, ownerId));
|
|
221
|
+
await transaction.delete(artifactEvents).where(eq(artifactEvents.ownerId, ownerId));
|
|
222
|
+
await transaction.delete(artifactRevisions).where(eq(artifactRevisions.ownerId, ownerId));
|
|
223
|
+
const deleted = await transaction.delete(artifactRecords).where(eq(artifactRecords.ownerId, ownerId)).returning({ id: artifactRecords.id });
|
|
224
|
+
return deleted.length;
|
|
225
|
+
}),
|
|
219
226
|
save: (record, expectedRevision, events = []) => options.db.transaction(async (transaction) => {
|
|
220
227
|
assertEventsBelongToArtifact(record, events);
|
|
221
228
|
const updated = await transaction.update(artifactRecords).set(recordUpdate(record)).where(and(eq(artifactRecords.id, record.id), eq(artifactRecords.ownerId, record.ownerId), eq(artifactRecords.revision, expectedRevision))).returning({ id: artifactRecords.id });
|
package/dist/index.js
CHANGED
|
@@ -471,6 +471,7 @@ var createArtifactService = (options) => {
|
|
|
471
471
|
data: await options.assetStore.read(asset, { artifact })
|
|
472
472
|
};
|
|
473
473
|
},
|
|
474
|
+
purgeOwner: (ownerId) => options.store.purgeOwner(ownerId),
|
|
474
475
|
restore: async (ownerId, artifactId, revision, expectedRevision) => {
|
|
475
476
|
const current = await get(ownerId, artifactId);
|
|
476
477
|
requireCapability(current, "edit");
|
|
@@ -680,6 +681,18 @@ var createMemoryArtifactStore = (initial = []) => {
|
|
|
680
681
|
for (const event of newEvents)
|
|
681
682
|
events.set(event.id, clone(event));
|
|
682
683
|
},
|
|
684
|
+
purgeOwner: async (ownerId) => {
|
|
685
|
+
const artifactIds = [...records.values()].filter((record) => record.ownerId === ownerId).map((record) => record.id);
|
|
686
|
+
for (const artifactId of artifactIds) {
|
|
687
|
+
records.delete(artifactId);
|
|
688
|
+
revisions.delete(artifactId);
|
|
689
|
+
indexing.delete(artifactId);
|
|
690
|
+
}
|
|
691
|
+
for (const [eventId, event] of events)
|
|
692
|
+
if (event.ownerId === ownerId)
|
|
693
|
+
events.delete(eventId);
|
|
694
|
+
return artifactIds.length;
|
|
695
|
+
},
|
|
683
696
|
save: async (record, expectedRevision, newEvents = []) => {
|
|
684
697
|
const current = records.get(record.id);
|
|
685
698
|
if (!current || current.ownerId !== record.ownerId || current.revision !== expectedRevision) {
|
package/dist/src/manifest.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const manifest: Omit<import("@absolutejs/manifest").PackageManife
|
|
|
27
27
|
asset: import("./types").ArtifactAssetReference;
|
|
28
28
|
data: Uint8Array<ArrayBufferLike>;
|
|
29
29
|
}>;
|
|
30
|
+
purgeOwner: (ownerId: string) => Promise<number>;
|
|
30
31
|
restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
|
|
31
32
|
unpublish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
|
|
32
33
|
update: (ownerId: string, artifactId: string, input: import("./types").ArtifactUpdateInput) => Promise<import("./types").ArtifactRecord>;
|
|
@@ -61,6 +62,7 @@ export declare const manifest: Omit<import("@absolutejs/manifest").PackageManife
|
|
|
61
62
|
asset: import("./types").ArtifactAssetReference;
|
|
62
63
|
data: Uint8Array<ArrayBufferLike>;
|
|
63
64
|
}>;
|
|
65
|
+
purgeOwner: (ownerId: string) => Promise<number>;
|
|
64
66
|
restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
|
|
65
67
|
unpublish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
|
|
66
68
|
update: (ownerId: string, artifactId: string, input: import("./types").ArtifactUpdateInput) => Promise<import("./types").ArtifactRecord>;
|
|
@@ -96,6 +98,7 @@ export declare const manifest: Omit<import("@absolutejs/manifest").PackageManife
|
|
|
96
98
|
asset: import("./types").ArtifactAssetReference;
|
|
97
99
|
data: Uint8Array<ArrayBufferLike>;
|
|
98
100
|
}>;
|
|
101
|
+
purgeOwner: (ownerId: string) => Promise<number>;
|
|
99
102
|
restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
|
|
100
103
|
unpublish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
|
|
101
104
|
update: (ownerId: string, artifactId: string, input: import("./types").ArtifactUpdateInput) => Promise<import("./types").ArtifactRecord>;
|
package/dist/src/service.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare const createArtifactService: <TDefinitions extends ArtifactKindDe
|
|
|
53
53
|
asset: ArtifactAssetReference;
|
|
54
54
|
data: Uint8Array<ArrayBufferLike>;
|
|
55
55
|
}>;
|
|
56
|
+
purgeOwner: (ownerId: string) => Promise<number>;
|
|
56
57
|
restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<ArtifactRecord>;
|
|
57
58
|
unpublish: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
|
|
58
59
|
update: (ownerId: string, artifactId: string, input: ArtifactUpdateInput) => Promise<ArtifactRecord>;
|
package/dist/src/store.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export type ArtifactStore = {
|
|
|
31
31
|
listReferencedAssetIds(): Promise<string[]>;
|
|
32
32
|
markEventProcessed(eventId: string, processedAt: string): Promise<boolean>;
|
|
33
33
|
putIndexingState(ownerId: string, state: ArtifactIndexingState, events?: ArtifactEvent[]): Promise<void>;
|
|
34
|
+
/** Permanently remove every artifact and lifecycle row for one host owner. */
|
|
35
|
+
purgeOwner(ownerId: string): Promise<number>;
|
|
34
36
|
/** Compare, replace current state, and append its revision atomically. */
|
|
35
37
|
save(record: ArtifactRecord, expectedRevision: number, events?: ArtifactEvent[]): Promise<boolean>;
|
|
36
38
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/artifacts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Typed, versioned artifacts for AI products — schemas, lifecycle, storage, rendering, publishing, revisions, and agent tools without prescribing a database or host.",
|
|
5
5
|
"author": "Alex Kahn",
|
|
6
6
|
"license": "BUSL-1.1",
|