@sentropic/artifacts 0.0.0-stage → 0.1.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.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -2
  3. package/dist/adapters/postgres.d.ts +35 -0
  4. package/dist/adapters/postgres.js +301 -0
  5. package/dist/adapters/s3.d.ts +19 -0
  6. package/dist/adapters/s3.js +70 -0
  7. package/dist/client.d.ts +23 -0
  8. package/dist/client.js +44 -0
  9. package/dist/codecs.d.ts +12 -0
  10. package/dist/codecs.js +77 -0
  11. package/dist/content/api-profile.d.ts +38 -0
  12. package/dist/content/api-profile.js +40 -0
  13. package/dist/content/grants.d.ts +59 -0
  14. package/dist/content/grants.js +134 -0
  15. package/dist/content/handler.d.ts +34 -0
  16. package/dist/content/handler.js +127 -0
  17. package/dist/content/headers.d.ts +25 -0
  18. package/dist/content/headers.js +56 -0
  19. package/dist/content/routing.d.ts +13 -0
  20. package/dist/content/routing.js +59 -0
  21. package/dist/contracts.d.ts +102 -0
  22. package/dist/contracts.js +25 -0
  23. package/dist/http.d.ts +43 -0
  24. package/dist/http.js +502 -0
  25. package/dist/index.d.ts +25 -0
  26. package/dist/index.js +29 -0
  27. package/dist/mcp.d.ts +68 -0
  28. package/dist/mcp.js +293 -0
  29. package/dist/parameters.d.ts +29 -0
  30. package/dist/parameters.js +65 -0
  31. package/dist/provider-definition.d.ts +36 -0
  32. package/dist/provider-definition.js +45 -0
  33. package/dist/server/access.d.ts +39 -0
  34. package/dist/server/access.js +53 -0
  35. package/dist/server/authorization.d.ts +17 -0
  36. package/dist/server/authorization.js +12 -0
  37. package/dist/server/bindings.d.ts +34 -0
  38. package/dist/server/bindings.js +60 -0
  39. package/dist/server/fork.d.ts +51 -0
  40. package/dist/server/fork.js +75 -0
  41. package/dist/server/gc.d.ts +24 -0
  42. package/dist/server/gc.js +90 -0
  43. package/dist/server/idempotency.d.ts +23 -0
  44. package/dist/server/idempotency.js +38 -0
  45. package/dist/server/lifecycle.d.ts +57 -0
  46. package/dist/server/lifecycle.js +184 -0
  47. package/dist/server/object-intents.d.ts +41 -0
  48. package/dist/server/object-intents.js +62 -0
  49. package/dist/server/ports.d.ts +34 -0
  50. package/dist/server/ports.js +50 -0
  51. package/dist/server/publication.d.ts +67 -0
  52. package/dist/server/publication.js +154 -0
  53. package/dist/server/reader-profile.d.ts +27 -0
  54. package/dist/server/reader-profile.js +18 -0
  55. package/dist/server/runtime.d.ts +33 -0
  56. package/dist/server/runtime.js +44 -0
  57. package/dist/server/service.d.ts +19 -0
  58. package/dist/server/service.js +32 -0
  59. package/dist/server/sources.d.ts +27 -0
  60. package/dist/server/sources.js +56 -0
  61. package/dist/server/templates.d.ts +33 -0
  62. package/dist/server/templates.js +86 -0
  63. package/dist/server/uploads.d.ts +29 -0
  64. package/dist/server/uploads.js +86 -0
  65. package/package.json +162 -4
@@ -0,0 +1,102 @@
1
+ /**
2
+ * L-5a — artifact domain contracts (spec-v8 §9).
3
+ *
4
+ * Generic, host-independent state: StorageScope, Artifact, Binding, Release,
5
+ * File/BlobRef, Source, ACL, hostname reservation, Upload, BlobPin,
6
+ * ObjectIntent and operation idempotency. Schema types are independent of
7
+ * ORM rows; no server, driver or cluster-mesh imports; no eager storage
8
+ * connections or DDL on import. Identities are server-allocated UUIDs.
9
+ */
10
+ export declare const ARTIFACT_SCHEMA_VERSIONS: readonly ["artifacts/v1"];
11
+ export type ArtifactSchemaVersion = (typeof ARTIFACT_SCHEMA_VERSIONS)[number];
12
+ /** Refuse unknown schema versions (fail-closed on version skew). */
13
+ export declare function assertKnownSchemaVersion(version: unknown): asserts version is ArtifactSchemaVersion;
14
+ /** True for server-allocated UUID identities. */
15
+ export declare function isArtifactId(value: unknown): value is string;
16
+ /** JSON value (undefined only as an absent property, never serialized). */
17
+ export type JsonValue = string | number | boolean | null | JsonObject | JsonValue[];
18
+ export interface JsonObject {
19
+ [key: string]: JsonValue | undefined;
20
+ }
21
+ /**
22
+ * Content-addressed manifest: canonical bytes + SHA-256 digest, versioned
23
+ * schema. `digest` is optional: construction precedes sealing, so working
24
+ * documents carry no digest and sealed documents must verify against it.
25
+ */
26
+ export interface CanonicalManifest {
27
+ schemaVersion: string;
28
+ digest?: string;
29
+ [key: string]: unknown;
30
+ }
31
+ /** Allocate a server-side identity (UUID v4). */
32
+ export declare function createArtifactId(): string;
33
+ /** Opaque storage scope isolating physical keys from org reindexing. */
34
+ export interface StorageScope {
35
+ readonly storageScopeId: string;
36
+ readonly createdAt: string;
37
+ }
38
+ /** An artifact: one logical view across releases. */
39
+ export interface Artifact {
40
+ readonly id: string;
41
+ readonly schemaVersion: ArtifactSchemaVersion;
42
+ readonly storageScopeId: string;
43
+ readonly ownerId: string;
44
+ readonly createdAt: string;
45
+ readonly deletedAt?: string;
46
+ }
47
+ /** A stable owner-scoped binding resolving to one artifact. */
48
+ export interface Binding {
49
+ readonly binding: string;
50
+ readonly artifactId: string;
51
+ readonly ownerId: string;
52
+ }
53
+ /** An immutable release of an artifact's manifest + bytes. */
54
+ export interface Release {
55
+ readonly id: string;
56
+ readonly artifactId: string;
57
+ readonly manifestDigest: string;
58
+ readonly createdAt: string;
59
+ readonly state: 'pending' | 'ready' | 'withdrawn' | 'purged';
60
+ }
61
+ /** A content blob referenced by digest. */
62
+ export interface BlobRef {
63
+ readonly digest: string;
64
+ readonly size: number;
65
+ readonly mimeType: string;
66
+ }
67
+ /** Provenance of a release's sources. */
68
+ export type ArtifactSource = {
69
+ readonly kind: 'inline-original';
70
+ } | {
71
+ readonly kind: 'recipe';
72
+ readonly baseCommit: string;
73
+ readonly recipe: string;
74
+ };
75
+ /** Object-level access grant. */
76
+ export interface AccessGrant {
77
+ readonly artifactId: string;
78
+ readonly subjectId: string;
79
+ readonly rights: readonly ('read' | 'source-export' | 'write')[];
80
+ }
81
+ /** A bounded upload session staging bytes before commit. */
82
+ export interface Upload {
83
+ readonly id: string;
84
+ readonly artifactId: string;
85
+ readonly prefix: string;
86
+ readonly createdAt: string;
87
+ readonly state: 'open' | 'committed' | 'aborted';
88
+ }
89
+ /** A pin retaining a blob against concurrent GC. */
90
+ export interface BlobPin {
91
+ readonly digest: string;
92
+ readonly artifactId: string;
93
+ readonly reason: 'release' | 'fork' | 'upload';
94
+ }
95
+ /** Recorded intent before every external object operation. */
96
+ export interface ObjectIntent {
97
+ readonly idempotencyKey: string;
98
+ readonly artifactId: string;
99
+ readonly operation: string;
100
+ readonly recordedAt: string;
101
+ readonly state: 'recorded' | 'applied' | 'failed';
102
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * L-5a — artifact domain contracts (spec-v8 §9).
3
+ *
4
+ * Generic, host-independent state: StorageScope, Artifact, Binding, Release,
5
+ * File/BlobRef, Source, ACL, hostname reservation, Upload, BlobPin,
6
+ * ObjectIntent and operation idempotency. Schema types are independent of
7
+ * ORM rows; no server, driver or cluster-mesh imports; no eager storage
8
+ * connections or DDL on import. Identities are server-allocated UUIDs.
9
+ */
10
+ export const ARTIFACT_SCHEMA_VERSIONS = ['artifacts/v1'];
11
+ /** Refuse unknown schema versions (fail-closed on version skew). */
12
+ export function assertKnownSchemaVersion(version) {
13
+ if (!ARTIFACT_SCHEMA_VERSIONS.includes(version)) {
14
+ throw new Error(`unknown artifact schema version: ${String(version)}`);
15
+ }
16
+ }
17
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
18
+ /** True for server-allocated UUID identities. */
19
+ export function isArtifactId(value) {
20
+ return typeof value === 'string' && UUID_PATTERN.test(value);
21
+ }
22
+ /** Allocate a server-side identity (UUID v4). */
23
+ export function createArtifactId() {
24
+ return crypto.randomUUID();
25
+ }
package/dist/http.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ import type { ParameterSchema } from './parameters.js';
2
+ import type { ArtifactService } from './server/service.js';
3
+ import type { PublicationBlobStore, PublicationService } from './server/publication.js';
4
+ import type { LifecycleService } from './server/lifecycle.js';
5
+ import type { ForkService } from './server/fork.js';
6
+ import { type AclStore } from './server/access.js';
7
+ import { type SourceStore } from './server/sources.js';
8
+ import type { StagingStore, UploadService } from './server/uploads.js';
9
+ import type { TemplateCatalogPort } from './server/templates.js';
10
+ export interface HttpRequest {
11
+ method: string;
12
+ path: string;
13
+ body: unknown;
14
+ actorId: string;
15
+ }
16
+ export interface HttpResponse {
17
+ status: number;
18
+ body: unknown;
19
+ }
20
+ export interface HttpAppDeps {
21
+ parameterSchema: ParameterSchema;
22
+ artifacts: ArtifactService;
23
+ publication: PublicationService;
24
+ lifecycle: LifecycleService;
25
+ forks: ForkService;
26
+ acls: AclStore;
27
+ sources: SourceStore;
28
+ blobs: PublicationBlobStore;
29
+ isApprovedAccount?: (principalId: string) => boolean;
30
+ /** Bounded upload sessions (L-5e); upload routes refuse when unwired. */
31
+ uploads?: UploadService;
32
+ staging?: StagingStore;
33
+ /** Template kit + API guide catalog (L-5e); refuses when unwired. */
34
+ templates?: TemplateCatalogPort;
35
+ }
36
+ /** Stable error body for one status; internal messages never leave the app. */
37
+ export declare function errorBody(status: number): {
38
+ error: string;
39
+ };
40
+ /** Create the HTTP app over injected services (no server, no fetch). */
41
+ export declare function createHttpArtifactApp(deps: HttpAppDeps): {
42
+ handle(request: HttpRequest): Promise<HttpResponse>;
43
+ };