@yargote/artifacts-contracts 0.1.0-beta.3 → 0.1.0-beta.4

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  `@yargote/artifacts-contracts` contains strict domain schemas, types, `ArtifactError`, snapshot serialization, and pure retained-edit helpers. It has no database, ZIP, server, or CLI dependency. Node 24 or later is required.
4
4
 
5
5
  ```sh
6
- npm install @yargote/artifacts-contracts@0.1.0-beta.3
6
+ npm install @yargote/artifacts-contracts@0.1.0-beta.4
7
7
  ```
8
8
 
9
9
  The root export contains domain schemas and types. `/workflow` contains `prepareArtifactEdit`, revision comparison, and compact projections. `/serialization` contains canonical JSON and SHA-256. `/http` contains HTTP response schemas, identity, canonical resource validation, and route URL helpers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yargote/artifacts-contracts",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Shared schemas and contracts for Artifacts clients.",
package/src/http.d.ts CHANGED
@@ -50,6 +50,7 @@ export declare const revisionSummarySchema: z.ZodObject<{
50
50
  export declare const compactArtifactReadSchema: z.ZodObject<{
51
51
  ownerId: z.ZodString;
52
52
  headRevisionId: z.ZodString;
53
+ project: z.ZodNullable<z.ZodString>;
53
54
  artifactId: z.ZodString;
54
55
  publication: z.ZodNullable<z.ZodObject<{
55
56
  revisionId: z.ZodString;
@@ -93,6 +94,7 @@ export declare const artifactSummarySchema: z.ZodObject<{
93
94
  title: z.ZodString;
94
95
  headRevisionId: z.ZodString;
95
96
  createdAt: z.ZodISODateTime;
97
+ project: z.ZodNullable<z.ZodString>;
96
98
  publication: z.ZodNullable<z.ZodObject<{
97
99
  revisionId: z.ZodString;
98
100
  version: z.ZodNumber;
@@ -105,6 +107,7 @@ export declare const listResultSchema: z.ZodObject<{
105
107
  title: z.ZodString;
106
108
  headRevisionId: z.ZodString;
107
109
  createdAt: z.ZodISODateTime;
110
+ project: z.ZodNullable<z.ZodString>;
108
111
  publication: z.ZodNullable<z.ZodObject<{
109
112
  revisionId: z.ZodString;
110
113
  version: z.ZodNumber;
@@ -113,6 +116,16 @@ export declare const listResultSchema: z.ZodObject<{
113
116
  }, z.core.$strict>>;
114
117
  nextCursor: z.ZodNullable<z.ZodString>;
115
118
  }, z.core.$strict>;
119
+ export declare const projectSummarySchema: z.ZodObject<{
120
+ name: z.ZodString;
121
+ artifactCount: z.ZodNumber;
122
+ }, z.core.$strict>;
123
+ export declare const projectsResultSchema: z.ZodObject<{
124
+ items: z.ZodArray<z.ZodObject<{
125
+ name: z.ZodString;
126
+ artifactCount: z.ZodNumber;
127
+ }, z.core.$strict>>;
128
+ }, z.core.$strict>;
116
129
  export declare const historyResultSchema: z.ZodObject<{
117
130
  items: z.ZodArray<z.ZodObject<{
118
131
  id: z.ZodString;
package/src/http.js CHANGED
@@ -10,8 +10,10 @@ export const revisionSummarySchema = revisionSchema.omit({ snapshot: true }).ext
10
10
  files: z.array(attachmentSummarySchema).max(32),
11
11
  });
12
12
  export const compactArtifactReadSchema = artifactReadSchema.omit({ revision: true }).extend({ revision: revisionSummarySchema });
13
- export const artifactSummarySchema = z.strictObject({ artifactId: identifier, title: z.string(), headRevisionId: identifier, createdAt: z.iso.datetime(), publication: publicationSchema.nullable() });
13
+ export const artifactSummarySchema = z.strictObject({ artifactId: identifier, title: z.string(), headRevisionId: identifier, createdAt: z.iso.datetime(), project: z.string().nullable(), publication: publicationSchema.nullable() });
14
14
  export const listResultSchema = z.strictObject({ items: z.array(artifactSummarySchema).max(100), nextCursor: identifier.nullable() });
15
+ export const projectSummarySchema = z.strictObject({ name: z.string(), artifactCount: z.number().int().positive() });
16
+ export const projectsResultSchema = z.strictObject({ items: z.array(projectSummarySchema) });
15
17
  export const historyResultSchema = z.strictObject({ items: z.array(revisionSchema).max(10), nextBeforeSequence: z.number().int().positive().nullable() });
16
18
  export const summaryHistoryResultSchema = historyResultSchema.extend({ items: z.array(revisionSummarySchema).max(10) });
17
19
  export const httpErrorSchema = z.strictObject({ error: z.strictObject({ code: z.string().min(1), message: z.string(), details: z.record(z.string(), z.unknown()) }) });
package/src/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export declare const snapshotSchema: z.ZodObject<{
23
23
  data: z.ZodString;
24
24
  }, z.core.$strict>>;
25
25
  }, z.core.$strict>;
26
+ export declare const projectNameSchema: z.ZodString;
26
27
  export declare const createSchema: z.ZodObject<{
27
28
  requestId: z.ZodString;
28
29
  snapshot: z.ZodObject<{
@@ -49,6 +50,7 @@ export declare const createSchema: z.ZodObject<{
49
50
  data: z.ZodString;
50
51
  }, z.core.$strict>>;
51
52
  }, z.core.$strict>;
53
+ project: z.ZodOptional<z.ZodString>;
52
54
  response: z.ZodOptional<z.ZodEnum<{
53
55
  full: "full";
54
56
  compact: "compact";
@@ -112,6 +114,16 @@ export declare const deleteResultSchema: z.ZodObject<{
112
114
  }, z.core.$strict>;
113
115
  export type DeleteInput = z.infer<typeof deleteSchema>;
114
116
  export type DeleteResult = z.infer<typeof deleteResultSchema>;
117
+ export declare const moveSchema: z.ZodObject<{
118
+ requestId: z.ZodString;
119
+ artifactId: z.ZodString;
120
+ project: z.ZodNullable<z.ZodString>;
121
+ }, z.core.$strict>;
122
+ export declare const moveResultSchema: z.ZodObject<{
123
+ artifactId: z.ZodString;
124
+ project: z.ZodNullable<z.ZodString>;
125
+ }, z.core.$strict>;
126
+ export type MoveResult = z.infer<typeof moveResultSchema>;
115
127
  export declare const exportSchema: z.ZodObject<{
116
128
  artifactId: z.ZodString;
117
129
  revisionId: z.ZodString;
@@ -119,6 +131,7 @@ export declare const exportSchema: z.ZodObject<{
119
131
  export declare const listSchema: z.ZodObject<{
120
132
  limit: z.ZodDefault<z.ZodNumber>;
121
133
  cursor: z.ZodOptional<z.ZodString>;
134
+ project: z.ZodOptional<z.ZodString>;
122
135
  }, z.core.$strict>;
123
136
  export declare const libraryQuerySchema: z.ZodObject<{
124
137
  q: z.ZodDefault<z.ZodString>;
@@ -128,6 +141,7 @@ export declare const libraryQuerySchema: z.ZodObject<{
128
141
  unpublished: "unpublished";
129
142
  pending: "pending";
130
143
  }>>;
144
+ project: z.ZodOptional<z.ZodString>;
131
145
  cursor: z.ZodOptional<z.ZodString>;
132
146
  }, z.core.$strict>;
133
147
  export declare const historySchema: z.ZodObject<{
@@ -188,8 +202,13 @@ export type ArtifactSummary = {
188
202
  title: string;
189
203
  headRevisionId: string;
190
204
  createdAt: string;
205
+ project: string | null;
191
206
  publication: Publication | null;
192
207
  };
208
+ export type ProjectSummary = {
209
+ name: string;
210
+ artifactCount: number;
211
+ };
193
212
  export type ArtifactLibraryQuery = z.infer<typeof libraryQuerySchema>;
194
213
  export type ArtifactLibraryPage = {
195
214
  items: ArtifactSummary[];
@@ -259,6 +278,7 @@ export declare const artifactReadSchema: z.ZodObject<{
259
278
  artifactId: z.ZodString;
260
279
  ownerId: z.ZodString;
261
280
  headRevisionId: z.ZodString;
281
+ project: z.ZodNullable<z.ZodString>;
262
282
  publication: z.ZodNullable<z.ZodObject<{
263
283
  revisionId: z.ZodString;
264
284
  version: z.ZodNumber;
package/src/index.js CHANGED
@@ -22,18 +22,22 @@ export const snapshotSchema = z.strictObject({
22
22
  if (bytes > 1_048_576)
23
23
  context.addIssue({ code: 'custom', message: 'A revision must fit within 1 MiB of decoded content and metadata' });
24
24
  });
25
+ export const projectNameSchema = z.string().normalize('NFC').trim().min(1).max(80).refine((name) => name.isWellFormed() && !/\p{Cc}/u.test(name), 'Use a project name without control characters');
25
26
  const response = z.enum(['full', 'compact']).optional();
26
- export const createSchema = z.strictObject({ requestId, snapshot: snapshotSchema, response });
27
+ export const createSchema = z.strictObject({ requestId, snapshot: snapshotSchema, project: projectNameSchema.optional(), response });
27
28
  export const readSchema = z.strictObject({ artifactId: identifier, revisionId: identifier.optional(), response });
28
29
  export const updateSchema = z.strictObject({ requestId, artifactId: identifier, expectedRevisionId: identifier, snapshot: snapshotSchema, response });
29
30
  export const publishSchema = z.strictObject({ requestId, artifactId: identifier, revisionId: identifier, expectedPublicationVersion: z.number().int().nonnegative() });
30
31
  export const deleteSchema = z.strictObject({ requestId, artifactId: identifier, expectedRevisionId: identifier, expectedPublicationVersion: z.number().int().nonnegative() });
31
32
  export const deleteResultSchema = z.strictObject({ artifactId: identifier });
33
+ export const moveSchema = z.strictObject({ requestId, artifactId: identifier, project: projectNameSchema.nullable() });
34
+ export const moveResultSchema = z.strictObject({ artifactId: identifier, project: z.string().nullable() });
32
35
  export const exportSchema = z.strictObject({ artifactId: identifier, revisionId: identifier });
33
- export const listSchema = z.strictObject({ limit: z.number().int().min(1).max(100).default(25), cursor: identifier.optional() });
36
+ export const listSchema = z.strictObject({ limit: z.number().int().min(1).max(100).default(25), cursor: identifier.optional(), project: projectNameSchema.optional() });
34
37
  export const libraryQuerySchema = z.strictObject({
35
38
  q: z.string().trim().max(256).default(''),
36
39
  status: z.enum(['all', 'published', 'unpublished', 'pending']).default('all'),
40
+ project: projectNameSchema.optional(),
37
41
  cursor: identifier.optional(),
38
42
  });
39
43
  export const historySchema = z.strictObject({ artifactId: identifier, limit: z.number().int().min(1).max(10).default(5), beforeSequence: z.number().int().positive().optional(), response: z.enum(['full', 'summary']).optional() });
@@ -54,5 +58,5 @@ export function decodeFile(file) {
54
58
  }
55
59
  export const publicationSchema = z.strictObject({ revisionId: identifier, version: z.number().int().positive(), url: z.url() });
56
60
  export const revisionSchema = z.strictObject({ id: identifier, parentRevisionId: identifier.nullable(), sequence: z.number().int().positive(), authorUserId: identifier, authorClientId: identifier, createdAt: z.iso.datetime(), sha256: z.string().regex(/^[a-f0-9]{64}$/), snapshot: snapshotSchema });
57
- export const artifactReadSchema = z.strictObject({ artifactId: identifier, ownerId: identifier, headRevisionId: identifier, publication: publicationSchema.nullable(), revision: revisionSchema });
61
+ export const artifactReadSchema = z.strictObject({ artifactId: identifier, ownerId: identifier, headRevisionId: identifier, project: z.string().nullable(), publication: publicationSchema.nullable(), revision: revisionSchema });
58
62
  export const publishResultSchema = publicationSchema.extend({ artifactId: identifier });