@sentropic/artifacts 0.2.3 → 0.2.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.
@@ -0,0 +1,39 @@
1
+ import { type ArtifactAcl } from './access.js';
2
+ export declare function artifactSummary(input: {
3
+ artifactId: string;
4
+ acl: ArtifactAcl;
5
+ actorId: string;
6
+ state: string;
7
+ current?: {
8
+ releaseId: string;
9
+ manifest: string;
10
+ };
11
+ urls?: (artifactId: string, releaseId: string) => {
12
+ stableUrl: string;
13
+ pinnedUrl: string;
14
+ };
15
+ approved?: (principalId: string) => boolean;
16
+ }): {
17
+ permissions: {
18
+ read: boolean;
19
+ source: boolean;
20
+ write: boolean;
21
+ manage: boolean;
22
+ };
23
+ icon?: string | null | undefined;
24
+ description?: string | undefined;
25
+ title?: string | undefined;
26
+ artifactId: string;
27
+ bindingName: string | null;
28
+ ownerId: string;
29
+ storageScopeId: string | undefined;
30
+ state: string;
31
+ isPublic: boolean;
32
+ withdrawn: boolean;
33
+ createdAt: string | null;
34
+ updatedAt: string | null;
35
+ currentReleaseId: string | null;
36
+ digest: string | null;
37
+ stableUrl: string | null;
38
+ pinnedUrl: string | null;
39
+ };
@@ -0,0 +1,17 @@
1
+ import { parseManifest } from '../codecs.js';
2
+ import { evaluateAccess } from './access.js';
3
+ export function artifactSummary(input) {
4
+ const { artifactId, acl, actorId, state, current } = input;
5
+ const urls = input.urls?.(artifactId, current?.releaseId ?? '');
6
+ const owner = acl.ownerId === actorId;
7
+ return { artifactId, bindingName: acl.bindingName ?? null, ownerId: acl.ownerId,
8
+ storageScopeId: acl.storageScopeId, state, isPublic: acl.isPublic, withdrawn: state === 'withdrawn',
9
+ createdAt: acl.createdAt ?? null, updatedAt: acl.updatedAt ?? null,
10
+ currentReleaseId: current?.releaseId ?? null, digest: current ? parseManifest(current.manifest).digest ?? null : null,
11
+ stableUrl: urls?.stableUrl ?? null, pinnedUrl: current ? urls?.pinnedUrl ?? null : null,
12
+ ...(acl.title === undefined ? {} : { title: acl.title }),
13
+ ...(acl.description === undefined ? {} : { description: acl.description }),
14
+ ...(acl.icon === undefined ? {} : { icon: acl.icon }),
15
+ permissions: { read: evaluateAccess(acl, actorId, 'read', input.approved),
16
+ source: evaluateAccess(acl, actorId, 'source', input.approved), write: owner, manage: owner } };
17
+ }
@@ -0,0 +1,47 @@
1
+ -- Terminal deletion retains the identity and receipts; physical purge remains host policy.
2
+ ALTER TABLE artifacts.artifacts ADD COLUMN IF NOT EXISTS terminal_deleted_at TIMESTAMPTZ;
3
+ ALTER TABLE artifacts.artifacts ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ;
4
+ -- Defaults affect new identities only; historical modification times remain unknown.
5
+ ALTER TABLE artifacts.artifacts ALTER COLUMN updated_at SET DEFAULT now();
6
+
7
+ CREATE OR REPLACE FUNCTION artifacts.reject_terminal_restore() RETURNS trigger LANGUAGE plpgsql AS $$
8
+ BEGIN
9
+ IF TG_OP = 'DELETE' THEN
10
+ IF OLD.terminal_deleted_at IS NOT NULL THEN RAISE EXCEPTION 'terminal artifact' USING ERRCODE = '23514'; END IF;
11
+ RETURN OLD;
12
+ END IF;
13
+ IF OLD.terminal_deleted_at IS NOT NULL AND
14
+ (NEW.terminal_deleted_at IS DISTINCT FROM OLD.terminal_deleted_at OR NEW.lifecycle_state NOT IN ('deleted', 'purged')
15
+ OR NEW.renewed_at IS DISTINCT FROM OLD.renewed_at) THEN
16
+ RAISE EXCEPTION 'terminal artifact' USING ERRCODE = '23514';
17
+ END IF;
18
+ RETURN NEW;
19
+ END $$;
20
+ DROP TRIGGER IF EXISTS terminal_restore_guard ON artifacts.artifacts;
21
+ CREATE TRIGGER terminal_restore_guard BEFORE UPDATE ON artifacts.artifacts
22
+ FOR EACH ROW EXECUTE FUNCTION artifacts.reject_terminal_restore();
23
+ DROP TRIGGER IF EXISTS terminal_identity_guard ON artifacts.artifacts;
24
+ CREATE TRIGGER terminal_identity_guard BEFORE DELETE ON artifacts.artifacts
25
+ FOR EACH ROW EXECUTE FUNCTION artifacts.reject_terminal_restore();
26
+
27
+ CREATE OR REPLACE FUNCTION artifacts.reject_terminal_publication() RETURNS trigger LANGUAGE plpgsql AS $$
28
+ BEGIN
29
+ PERFORM id FROM artifacts.artifacts WHERE id = NEW.artifact_id AND terminal_deleted_at IS NULL FOR KEY SHARE;
30
+ IF NOT FOUND THEN RAISE EXCEPTION 'terminal artifact' USING ERRCODE = '23514'; END IF;
31
+ RETURN NEW;
32
+ END $$;
33
+ DROP TRIGGER IF EXISTS terminal_release_guard ON artifacts.releases;
34
+ CREATE TRIGGER terminal_release_guard BEFORE INSERT ON artifacts.releases
35
+ FOR EACH ROW EXECUTE FUNCTION artifacts.reject_terminal_publication();
36
+
37
+ CREATE OR REPLACE FUNCTION artifacts.record_publication_update() RETURNS trigger LANGUAGE plpgsql AS $$
38
+ BEGIN
39
+ UPDATE artifacts.artifacts SET updated_at = NEW.created_at WHERE id = NEW.artifact_id;
40
+ RETURN NEW;
41
+ END $$;
42
+ DROP TRIGGER IF EXISTS publication_updated_at ON artifacts.releases;
43
+ CREATE TRIGGER publication_updated_at AFTER INSERT ON artifacts.releases
44
+ FOR EACH ROW EXECUTE FUNCTION artifacts.record_publication_update();
45
+ DROP TRIGGER IF EXISTS terminal_pointer_guard ON artifacts.artifact_current;
46
+ CREATE TRIGGER terminal_pointer_guard BEFORE INSERT OR UPDATE ON artifacts.artifact_current
47
+ FOR EACH ROW EXECUTE FUNCTION artifacts.reject_terminal_publication();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentropic/artifacts",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Generic configurable artifacts MCP and artifact service: StorageScope/Artifact/Binding/Release model, canonical manifests, object authorization, idempotent intents (spec-v8 §9).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,6 +45,10 @@
45
45
  "types": "./dist/adapters/postgres-activation.d.ts",
46
46
  "import": "./dist/adapters/postgres-activation.js"
47
47
  },
48
+ "./adapters/postgres-activation/vectors": {
49
+ "types": "./dist/adapters/postgres-activation-vectors.d.ts",
50
+ "import": "./dist/adapters/postgres-activation-vectors.js"
51
+ },
48
52
  "./sql/*": "./sql/*",
49
53
  "./migrations/*": "./migrations/*",
50
54
  "./server/ports": {
@@ -99,6 +103,18 @@
99
103
  "types": "./dist/server/sources.d.ts",
100
104
  "import": "./dist/server/sources.js"
101
105
  },
106
+ "./server/source-read": {
107
+ "types": "./dist/server/source-read.d.ts",
108
+ "import": "./dist/server/source-read.js"
109
+ },
110
+ "./server/management": {
111
+ "types": "./dist/server/management.d.ts",
112
+ "import": "./dist/server/management.js"
113
+ },
114
+ "./adapters/postgres-management": {
115
+ "types": "./dist/adapters/postgres-management.d.ts",
116
+ "import": "./dist/adapters/postgres-management.js"
117
+ },
102
118
  "./server/fork": {
103
119
  "types": "./dist/server/fork.d.ts",
104
120
  "import": "./dist/server/fork.js"
@@ -177,6 +193,7 @@
177
193
  "docs/migration-l6.md",
178
194
  "examples/radar-commit-setup.ts",
179
195
  "README.md",
196
+ "CHANGELOG.md",
180
197
  "LICENSE"
181
198
  ],
182
199
  "publishConfig": {