@authorbot/schemas 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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/dist/annotation.d.ts +172 -0
  3. package/dist/annotation.js +96 -0
  4. package/dist/attribution.d.ts +25 -0
  5. package/dist/attribution.js +19 -0
  6. package/dist/book.d.ts +104 -0
  7. package/dist/book.js +105 -0
  8. package/dist/build.d.ts +44 -0
  9. package/dist/build.js +28 -0
  10. package/dist/chapter.d.ts +37 -0
  11. package/dist/chapter.js +29 -0
  12. package/dist/character.d.ts +15 -0
  13. package/dist/character.js +16 -0
  14. package/dist/decision.d.ts +34 -0
  15. package/dist/decision.js +31 -0
  16. package/dist/index.d.ts +29 -0
  17. package/dist/index.js +15 -0
  18. package/dist/instance.d.ts +260 -0
  19. package/dist/instance.js +101 -0
  20. package/dist/json-schemas.d.ts +455 -0
  21. package/dist/json-schemas.js +61 -0
  22. package/dist/primitives.d.ts +58 -0
  23. package/dist/primitives.js +101 -0
  24. package/dist/release.d.ts +17 -0
  25. package/dist/release.js +19 -0
  26. package/dist/scripts/generate-json-schemas.d.ts +2 -0
  27. package/dist/scripts/generate-json-schemas.js +14 -0
  28. package/dist/story-graph.d.ts +132 -0
  29. package/dist/story-graph.js +56 -0
  30. package/dist/timeline.d.ts +35 -0
  31. package/dist/timeline.js +28 -0
  32. package/dist/work-item.d.ts +75 -0
  33. package/dist/work-item.js +48 -0
  34. package/json/annotation.schema.json +279 -0
  35. package/json/attribution.schema.json +52 -0
  36. package/json/book.schema.json +270 -0
  37. package/json/build.schema.json +84 -0
  38. package/json/chapter.schema.json +89 -0
  39. package/json/character.schema.json +39 -0
  40. package/json/decision.schema.json +69 -0
  41. package/json/instance.schema.json +273 -0
  42. package/json/release.schema.json +52 -0
  43. package/json/reply.schema.json +43 -0
  44. package/json/story-graph.schema.json +159 -0
  45. package/json/timeline.schema.json +91 -0
  46. package/json/work-item.schema.json +78 -0
  47. package/package.json +56 -0
@@ -0,0 +1,455 @@
1
+ import { z } from "zod";
2
+ /** All artifact schemas keyed by the JSON Schema output file basename. */
3
+ export declare const artifactSchemas: {
4
+ readonly book: z.ZodObject<{
5
+ schema: z.ZodLiteral<"authorbot.book/v1">;
6
+ id: z.ZodString;
7
+ title: z.ZodString;
8
+ slug: z.ZodString;
9
+ language: z.ZodString;
10
+ license: z.ZodOptional<z.ZodString>;
11
+ repository: z.ZodOptional<z.ZodObject<{
12
+ default_branch: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strict>>;
14
+ content: z.ZodOptional<z.ZodObject<{
15
+ chapters_glob: z.ZodOptional<z.ZodString>;
16
+ raw_html: z.ZodOptional<z.ZodBoolean>;
17
+ }, z.core.$strict>>;
18
+ planning: z.ZodOptional<z.ZodObject<{
19
+ method: z.ZodOptional<z.ZodString>;
20
+ outline: z.ZodOptional<z.ZodString>;
21
+ timeline: z.ZodOptional<z.ZodString>;
22
+ characters_glob: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strict>>;
24
+ publication: z.ZodOptional<z.ZodObject<{
25
+ chapter_url: z.ZodOptional<z.ZodString>;
26
+ api_url: z.ZodOptional<z.ZodString>;
27
+ show_revision: z.ZodOptional<z.ZodBoolean>;
28
+ show_attribution: z.ZodOptional<z.ZodBoolean>;
29
+ show_public_annotations: z.ZodOptional<z.ZodBoolean>;
30
+ }, z.core.$strict>>;
31
+ collaboration: z.ZodOptional<z.ZodObject<{
32
+ annotation_policy: z.ZodOptional<z.ZodEnum<{
33
+ open: "open";
34
+ "approval-gated": "approval-gated";
35
+ "collaborators-only": "collaborators-only";
36
+ locked: "locked";
37
+ }>>;
38
+ }, z.core.$strict>>;
39
+ governance: z.ZodOptional<z.ZodObject<{
40
+ rules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
41
+ version: z.ZodNumber;
42
+ trigger: z.ZodOptional<z.ZodEnum<{
43
+ vote_changed: "vote_changed";
44
+ }>>;
45
+ when: z.ZodUnion<readonly [z.ZodObject<{
46
+ all: z.ZodArray<z.ZodObject<{
47
+ metric: z.ZodString;
48
+ operator: z.ZodEnum<{
49
+ gte: "gte";
50
+ gt: "gt";
51
+ lte: "lte";
52
+ lt: "lt";
53
+ eq: "eq";
54
+ neq: "neq";
55
+ }>;
56
+ value: z.ZodNumber;
57
+ }, z.core.$strict>>;
58
+ }, z.core.$strict>, z.ZodObject<{
59
+ any: z.ZodArray<z.ZodObject<{
60
+ metric: z.ZodString;
61
+ operator: z.ZodEnum<{
62
+ gte: "gte";
63
+ gt: "gt";
64
+ lte: "lte";
65
+ lt: "lt";
66
+ eq: "eq";
67
+ neq: "neq";
68
+ }>;
69
+ value: z.ZodNumber;
70
+ }, z.core.$strict>>;
71
+ }, z.core.$strict>]>;
72
+ action: z.ZodObject<{
73
+ type: z.ZodLiteral<"create_work_item">;
74
+ work_type: z.ZodEnum<{
75
+ revise_range: "revise_range";
76
+ revise_block: "revise_block";
77
+ revise_chapter: "revise_chapter";
78
+ write_chapter: "write_chapter";
79
+ resolve_conflict: "resolve_conflict";
80
+ planning: "planning";
81
+ }>;
82
+ }, z.core.$strict>;
83
+ }, z.core.$strict>>>;
84
+ }, z.core.$strict>>;
85
+ }, z.core.$strict>;
86
+ readonly chapter: z.ZodObject<{
87
+ schema: z.ZodLiteral<"authorbot.chapter/v1">;
88
+ id: z.ZodString;
89
+ slug: z.ZodString;
90
+ title: z.ZodString;
91
+ order: z.ZodNumber;
92
+ status: z.ZodEnum<{
93
+ draft: "draft";
94
+ proposed: "proposed";
95
+ published: "published";
96
+ archived: "archived";
97
+ }>;
98
+ revision: z.ZodNumber;
99
+ published_at: z.ZodOptional<z.ZodString>;
100
+ authors: z.ZodArray<z.ZodObject<{
101
+ actor: z.ZodString;
102
+ }, z.core.$strict>>;
103
+ summary: z.ZodOptional<z.ZodString>;
104
+ timeline_refs: z.ZodOptional<z.ZodArray<z.ZodString>>;
105
+ character_refs: z.ZodOptional<z.ZodArray<z.ZodString>>;
106
+ }, z.core.$strict>;
107
+ readonly "story-graph": z.ZodObject<{
108
+ schema: z.ZodLiteral<"authorbot.story-graph/v1">;
109
+ nodes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
110
+ type: z.ZodLiteral<"chapter">;
111
+ chapter_id: z.ZodString;
112
+ status: z.ZodOptional<z.ZodEnum<{
113
+ draft: "draft";
114
+ proposed: "proposed";
115
+ published: "published";
116
+ archived: "archived";
117
+ }>>;
118
+ id: z.ZodString;
119
+ title: z.ZodOptional<z.ZodString>;
120
+ summary: z.ZodOptional<z.ZodString>;
121
+ parent: z.ZodOptional<z.ZodString>;
122
+ order: z.ZodNumber;
123
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
124
+ }, z.core.$strict>, z.ZodObject<{
125
+ type: z.ZodEnum<{
126
+ premise: "premise";
127
+ arc: "arc";
128
+ part: "part";
129
+ scene: "scene";
130
+ beat: "beat";
131
+ custom: "custom";
132
+ }>;
133
+ goal: z.ZodOptional<z.ZodString>;
134
+ conflict: z.ZodOptional<z.ZodString>;
135
+ outcome: z.ZodOptional<z.ZodString>;
136
+ id: z.ZodString;
137
+ title: z.ZodOptional<z.ZodString>;
138
+ summary: z.ZodOptional<z.ZodString>;
139
+ parent: z.ZodOptional<z.ZodString>;
140
+ order: z.ZodNumber;
141
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
142
+ }, z.core.$strict>], "type">>;
143
+ links: z.ZodOptional<z.ZodArray<z.ZodObject<{
144
+ from: z.ZodString;
145
+ to: z.ZodString;
146
+ type: z.ZodString;
147
+ }, z.core.$strict>>>;
148
+ }, z.core.$strict>;
149
+ readonly timeline: z.ZodObject<{
150
+ schema: z.ZodLiteral<"authorbot.timeline/v1">;
151
+ calendar: z.ZodOptional<z.ZodObject<{
152
+ type: z.ZodString;
153
+ epoch_label: z.ZodOptional<z.ZodString>;
154
+ }, z.core.$strict>>;
155
+ events: z.ZodArray<z.ZodObject<{
156
+ id: z.ZodString;
157
+ sort_key: z.ZodNumber;
158
+ display_time: z.ZodString;
159
+ title: z.ZodString;
160
+ participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
161
+ locations: z.ZodOptional<z.ZodArray<z.ZodString>>;
162
+ chapter_refs: z.ZodOptional<z.ZodArray<z.ZodString>>;
163
+ facts: z.ZodOptional<z.ZodArray<z.ZodString>>;
164
+ }, z.core.$strict>>;
165
+ }, z.core.$strict>;
166
+ readonly character: z.ZodObject<{
167
+ schema: z.ZodLiteral<"authorbot.character/v1">;
168
+ id: z.ZodString;
169
+ name: z.ZodString;
170
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
171
+ summary: z.ZodOptional<z.ZodString>;
172
+ status: z.ZodOptional<z.ZodString>;
173
+ }, z.core.$strict>;
174
+ readonly annotation: z.ZodDiscriminatedUnion<[z.ZodObject<{
175
+ scope: z.ZodLiteral<"range">;
176
+ target: z.ZodObject<{
177
+ blockId: z.ZodString;
178
+ textPosition: z.ZodObject<{
179
+ start: z.ZodNumber;
180
+ end: z.ZodNumber;
181
+ }, z.core.$strict>;
182
+ textQuote: z.ZodObject<{
183
+ exact: z.ZodString;
184
+ prefix: z.ZodOptional<z.ZodString>;
185
+ suffix: z.ZodOptional<z.ZodString>;
186
+ }, z.core.$strict>;
187
+ }, z.core.$strict>;
188
+ schema: z.ZodLiteral<"authorbot.annotation/v1">;
189
+ id: z.ZodString;
190
+ kind: z.ZodEnum<{
191
+ comment: "comment";
192
+ suggestion: "suggestion";
193
+ }>;
194
+ chapter_id: z.ZodString;
195
+ chapter_revision: z.ZodNumber;
196
+ author: z.ZodString;
197
+ status: z.ZodEnum<{
198
+ open: "open";
199
+ work_item_created: "work_item_created";
200
+ accepted: "accepted";
201
+ resolved: "resolved";
202
+ rejected: "rejected";
203
+ withdrawn: "withdrawn";
204
+ superseded: "superseded";
205
+ orphaned: "orphaned";
206
+ needs_reanchor: "needs_reanchor";
207
+ }>;
208
+ created_at: z.ZodString;
209
+ }, z.core.$strict>, z.ZodObject<{
210
+ scope: z.ZodLiteral<"block">;
211
+ target: z.ZodObject<{
212
+ blockId: z.ZodString;
213
+ }, z.core.$strict>;
214
+ schema: z.ZodLiteral<"authorbot.annotation/v1">;
215
+ id: z.ZodString;
216
+ kind: z.ZodEnum<{
217
+ comment: "comment";
218
+ suggestion: "suggestion";
219
+ }>;
220
+ chapter_id: z.ZodString;
221
+ chapter_revision: z.ZodNumber;
222
+ author: z.ZodString;
223
+ status: z.ZodEnum<{
224
+ open: "open";
225
+ work_item_created: "work_item_created";
226
+ accepted: "accepted";
227
+ resolved: "resolved";
228
+ rejected: "rejected";
229
+ withdrawn: "withdrawn";
230
+ superseded: "superseded";
231
+ orphaned: "orphaned";
232
+ needs_reanchor: "needs_reanchor";
233
+ }>;
234
+ created_at: z.ZodString;
235
+ }, z.core.$strict>, z.ZodObject<{
236
+ scope: z.ZodLiteral<"chapter">;
237
+ schema: z.ZodLiteral<"authorbot.annotation/v1">;
238
+ id: z.ZodString;
239
+ kind: z.ZodEnum<{
240
+ comment: "comment";
241
+ suggestion: "suggestion";
242
+ }>;
243
+ chapter_id: z.ZodString;
244
+ chapter_revision: z.ZodNumber;
245
+ author: z.ZodString;
246
+ status: z.ZodEnum<{
247
+ open: "open";
248
+ work_item_created: "work_item_created";
249
+ accepted: "accepted";
250
+ resolved: "resolved";
251
+ rejected: "rejected";
252
+ withdrawn: "withdrawn";
253
+ superseded: "superseded";
254
+ orphaned: "orphaned";
255
+ needs_reanchor: "needs_reanchor";
256
+ }>;
257
+ created_at: z.ZodString;
258
+ }, z.core.$strict>], "scope">;
259
+ readonly reply: z.ZodObject<{
260
+ schema: z.ZodLiteral<"authorbot.reply/v1">;
261
+ id: z.ZodString;
262
+ annotation_id: z.ZodString;
263
+ parent_reply_id: z.ZodOptional<z.ZodString>;
264
+ author: z.ZodString;
265
+ created_at: z.ZodString;
266
+ updated_at: z.ZodOptional<z.ZodString>;
267
+ }, z.core.$strict>;
268
+ readonly decision: z.ZodObject<{
269
+ schema: z.ZodLiteral<"authorbot.decision/v1">;
270
+ id: z.ZodString;
271
+ source_annotation_id: z.ZodString;
272
+ rule: z.ZodString;
273
+ rule_version: z.ZodNumber;
274
+ metrics: z.ZodRecord<z.ZodString, z.ZodNumber>;
275
+ result: z.ZodEnum<{
276
+ rejected: "rejected";
277
+ create_work_item: "create_work_item";
278
+ support_changed: "support_changed";
279
+ overridden: "overridden";
280
+ }>;
281
+ work_item_id: z.ZodOptional<z.ZodString>;
282
+ effective_at: z.ZodString;
283
+ override_reason: z.ZodOptional<z.ZodString>;
284
+ }, z.core.$strict>;
285
+ readonly "work-item": z.ZodObject<{
286
+ schema: z.ZodLiteral<"authorbot.work-item/v1">;
287
+ id: z.ZodString;
288
+ type: z.ZodEnum<{
289
+ revise_range: "revise_range";
290
+ revise_block: "revise_block";
291
+ revise_chapter: "revise_chapter";
292
+ write_chapter: "write_chapter";
293
+ resolve_conflict: "resolve_conflict";
294
+ planning: "planning";
295
+ }>;
296
+ status: z.ZodEnum<{
297
+ ready: "ready";
298
+ leased: "leased";
299
+ submitted: "submitted";
300
+ applying: "applying";
301
+ completed: "completed";
302
+ conflict: "conflict";
303
+ failed: "failed";
304
+ cancelled: "cancelled";
305
+ }>;
306
+ source_annotation_id: z.ZodOptional<z.ZodString>;
307
+ chapter_id: z.ZodOptional<z.ZodString>;
308
+ base_revision: z.ZodOptional<z.ZodNumber>;
309
+ priority: z.ZodEnum<{
310
+ low: "low";
311
+ normal: "normal";
312
+ high: "high";
313
+ }>;
314
+ created_by: z.ZodString;
315
+ created_at: z.ZodString;
316
+ }, z.core.$strict>;
317
+ readonly attribution: z.ZodObject<{
318
+ schema: z.ZodLiteral<"authorbot.attribution/v1">;
319
+ chapter_id: z.ZodString;
320
+ entries: z.ZodArray<z.ZodObject<{
321
+ revision: z.ZodNumber;
322
+ actor: z.ZodString;
323
+ work_item_id: z.ZodOptional<z.ZodString>;
324
+ commit: z.ZodOptional<z.ZodString>;
325
+ }, z.core.$strict>>;
326
+ }, z.core.$strict>;
327
+ readonly release: z.ZodObject<{
328
+ schema: z.ZodLiteral<"authorbot.release/v1">;
329
+ id: z.ZodString;
330
+ created_at: z.ZodString;
331
+ chapters: z.ZodArray<z.ZodObject<{
332
+ chapter_id: z.ZodString;
333
+ revision: z.ZodNumber;
334
+ }, z.core.$strict>>;
335
+ notes: z.ZodOptional<z.ZodString>;
336
+ }, z.core.$strict>;
337
+ readonly instance: z.ZodObject<{
338
+ schema: z.ZodLiteral<"authorbot.instance/v1">;
339
+ project: z.ZodOptional<z.ZodObject<{
340
+ book_config_path: z.ZodOptional<z.ZodString>;
341
+ default_branch: z.ZodOptional<z.ZodString>;
342
+ }, z.core.$strict>>;
343
+ access: z.ZodOptional<z.ZodObject<{
344
+ public_read: z.ZodOptional<z.ZodBoolean>;
345
+ public_annotations: z.ZodOptional<z.ZodBoolean>;
346
+ writes_require_membership: z.ZodOptional<z.ZodBoolean>;
347
+ }, z.core.$strict>>;
348
+ annotations: z.ZodOptional<z.ZodObject<{
349
+ context_characters: z.ZodOptional<z.ZodNumber>;
350
+ range_scope: z.ZodOptional<z.ZodEnum<{
351
+ single_block: "single_block";
352
+ }>>;
353
+ allow_range_comments: z.ZodOptional<z.ZodBoolean>;
354
+ allow_chapter_comments: z.ZodOptional<z.ZodBoolean>;
355
+ }, z.core.$strict>>;
356
+ votes: z.ZodOptional<z.ZodObject<{
357
+ values: z.ZodOptional<z.ZodArray<z.ZodEnum<{
358
+ approve: "approve";
359
+ reject: "reject";
360
+ abstain: "abstain";
361
+ }>>>;
362
+ export: z.ZodOptional<z.ZodEnum<{
363
+ aggregate: "aggregate";
364
+ named: "named";
365
+ pseudonymous: "pseudonymous";
366
+ }>>;
367
+ }, z.core.$strict>>;
368
+ rules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
369
+ version: z.ZodNumber;
370
+ trigger: z.ZodOptional<z.ZodEnum<{
371
+ vote_changed: "vote_changed";
372
+ }>>;
373
+ when: z.ZodUnion<readonly [z.ZodObject<{
374
+ all: z.ZodArray<z.ZodObject<{
375
+ metric: z.ZodString;
376
+ operator: z.ZodEnum<{
377
+ gte: "gte";
378
+ gt: "gt";
379
+ lte: "lte";
380
+ lt: "lt";
381
+ eq: "eq";
382
+ neq: "neq";
383
+ }>;
384
+ value: z.ZodNumber;
385
+ }, z.core.$strict>>;
386
+ }, z.core.$strict>, z.ZodObject<{
387
+ any: z.ZodArray<z.ZodObject<{
388
+ metric: z.ZodString;
389
+ operator: z.ZodEnum<{
390
+ gte: "gte";
391
+ gt: "gt";
392
+ lte: "lte";
393
+ lt: "lt";
394
+ eq: "eq";
395
+ neq: "neq";
396
+ }>;
397
+ value: z.ZodNumber;
398
+ }, z.core.$strict>>;
399
+ }, z.core.$strict>]>;
400
+ action: z.ZodObject<{
401
+ type: z.ZodLiteral<"create_work_item">;
402
+ work_type: z.ZodEnum<{
403
+ revise_range: "revise_range";
404
+ revise_block: "revise_block";
405
+ revise_chapter: "revise_chapter";
406
+ write_chapter: "write_chapter";
407
+ resolve_conflict: "resolve_conflict";
408
+ planning: "planning";
409
+ }>;
410
+ }, z.core.$strict>;
411
+ }, z.core.$strict>>>;
412
+ leases: z.ZodOptional<z.ZodObject<{
413
+ duration: z.ZodOptional<z.ZodString>;
414
+ renewal_prompt_before: z.ZodOptional<z.ZodString>;
415
+ renewal_duration: z.ZodOptional<z.ZodString>;
416
+ maximum_total_duration: z.ZodOptional<z.ZodString>;
417
+ }, z.core.$strict>>;
418
+ publishing: z.ZodOptional<z.ZodObject<{
419
+ collaboration_data: z.ZodOptional<z.ZodEnum<{
420
+ dynamic: "dynamic";
421
+ static: "static";
422
+ }>>;
423
+ static_snapshot_on_release: z.ZodOptional<z.ZodBoolean>;
424
+ }, z.core.$strict>>;
425
+ }, z.core.$strict>;
426
+ readonly build: z.ZodObject<{
427
+ schema: z.ZodLiteral<"authorbot.build/v1">;
428
+ commit: z.ZodNullable<z.ZodString>;
429
+ built_at: z.ZodString;
430
+ publisher_version: z.ZodString;
431
+ base_url: z.ZodOptional<z.ZodString>;
432
+ chapters: z.ZodArray<z.ZodObject<{
433
+ id: z.ZodString;
434
+ slug: z.ZodString;
435
+ revision: z.ZodNumber;
436
+ title: z.ZodString;
437
+ status: z.ZodEnum<{
438
+ draft: "draft";
439
+ proposed: "proposed";
440
+ published: "published";
441
+ archived: "archived";
442
+ }>;
443
+ }, z.core.$strict>>;
444
+ }, z.core.$strict>;
445
+ };
446
+ export type ArtifactName = keyof typeof artifactSchemas;
447
+ /** Schema discriminator IDs (contract section 4 table). */
448
+ export declare const SCHEMA_IDS: Record<ArtifactName, string>;
449
+ /**
450
+ * Generate the draft 2020-12 JSON Schema document for every artifact, keyed
451
+ * by output file basename (`<name>.schema.json`). `$id` is the artifact's
452
+ * schema discriminator.
453
+ */
454
+ export declare function buildJsonSchemas(): Record<ArtifactName, Record<string, unknown>>;
455
+ //# sourceMappingURL=json-schemas.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { z } from "zod";
2
+ import { annotationSchema, replySchema } from "./annotation.js";
3
+ import { attributionSchema } from "./attribution.js";
4
+ import { bookConfigSchema } from "./book.js";
5
+ import { buildManifestSchema } from "./build.js";
6
+ import { chapterFrontmatterSchema } from "./chapter.js";
7
+ import { characterSchema } from "./character.js";
8
+ import { decisionSchema } from "./decision.js";
9
+ import { instanceConfigSchema } from "./instance.js";
10
+ import { releaseSchema } from "./release.js";
11
+ import { storyGraphSchema } from "./story-graph.js";
12
+ import { timelineSchema } from "./timeline.js";
13
+ import { workItemSchema } from "./work-item.js";
14
+ /** All artifact schemas keyed by the JSON Schema output file basename. */
15
+ export const artifactSchemas = {
16
+ book: bookConfigSchema,
17
+ chapter: chapterFrontmatterSchema,
18
+ "story-graph": storyGraphSchema,
19
+ timeline: timelineSchema,
20
+ character: characterSchema,
21
+ annotation: annotationSchema,
22
+ reply: replySchema,
23
+ decision: decisionSchema,
24
+ "work-item": workItemSchema,
25
+ attribution: attributionSchema,
26
+ release: releaseSchema,
27
+ instance: instanceConfigSchema,
28
+ build: buildManifestSchema,
29
+ };
30
+ /** Schema discriminator IDs (contract section 4 table). */
31
+ export const SCHEMA_IDS = {
32
+ book: "authorbot.book/v1",
33
+ chapter: "authorbot.chapter/v1",
34
+ "story-graph": "authorbot.story-graph/v1",
35
+ timeline: "authorbot.timeline/v1",
36
+ character: "authorbot.character/v1",
37
+ annotation: "authorbot.annotation/v1",
38
+ reply: "authorbot.reply/v1",
39
+ decision: "authorbot.decision/v1",
40
+ "work-item": "authorbot.work-item/v1",
41
+ attribution: "authorbot.attribution/v1",
42
+ release: "authorbot.release/v1",
43
+ instance: "authorbot.instance/v1",
44
+ build: "authorbot.build/v1",
45
+ };
46
+ /**
47
+ * Generate the draft 2020-12 JSON Schema document for every artifact, keyed
48
+ * by output file basename (`<name>.schema.json`). `$id` is the artifact's
49
+ * schema discriminator.
50
+ */
51
+ export function buildJsonSchemas() {
52
+ const out = {};
53
+ for (const name of Object.keys(artifactSchemas)) {
54
+ const generated = z.toJSONSchema(artifactSchemas[name], {
55
+ target: "draft-2020-12",
56
+ });
57
+ out[name] = { $id: SCHEMA_IDS[name], ...generated };
58
+ }
59
+ return out;
60
+ }
61
+ //# sourceMappingURL=json-schemas.js.map
@@ -0,0 +1,58 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Shared identifier and reference primitives (Phase 0 contract section 2).
4
+ */
5
+ /** Story node / timeline / bible ID kinds (contract section 2). */
6
+ export declare const NODE_KINDS: readonly ["premise", "arc", "part", "chapter", "scene", "beat", "event", "character", "location", "concept", "rule"];
7
+ export type NodeKind = (typeof NODE_KINDS)[number];
8
+ /** Actor reference namespaces (contract section 2). */
9
+ export declare const ACTOR_NAMESPACES: readonly ["github", "agent", "system"];
10
+ export type ActorNamespace = (typeof ACTOR_NAMESPACES)[number];
11
+ /** Slug source pattern: `[a-z0-9][a-z0-9-]*` (contract section 2). */
12
+ export declare const SLUG_PATTERN = "[a-z0-9][a-z0-9-]*";
13
+ /**
14
+ * Lowercase UUIDv7 (contract section 2): version nibble must be `7`, variant
15
+ * nibble must be RFC 4122 (`8`, `9`, `a`, or `b`).
16
+ */
17
+ export declare const UUIDV7_REGEX: RegExp;
18
+ export declare const uuidv7Schema: z.ZodString;
19
+ export type UuidV7 = z.infer<typeof uuidv7Schema>;
20
+ /** Path-traversal-safe slug (contract section 2). */
21
+ export declare const slugSchema: z.ZodString;
22
+ export type Slug = z.infer<typeof slugSchema>;
23
+ /** `<kind>:<slug>` node ID for any known kind (contract section 2). */
24
+ export declare const nodeIdSchema: z.ZodString;
25
+ export type NodeId = z.infer<typeof nodeIdSchema>;
26
+ /** `<kind>:<slug>` node ID restricted to one specific kind. */
27
+ export declare function nodeIdOf<K extends NodeKind>(kind: K): z.ZodString;
28
+ /**
29
+ * Actor reference `<namespace>:<identifier>` (contract section 2).
30
+ * The identifier charset is not pinned by the contract; this package accepts
31
+ * `[A-Za-z0-9][A-Za-z0-9._-]*` (covers GitHub logins, agent names, and system
32
+ * components) and rejects whitespace, colons, and leading punctuation.
33
+ */
34
+ export declare const actorRefSchema: z.ZodString;
35
+ export type ActorRef = z.infer<typeof actorRefSchema>;
36
+ /**
37
+ * RFC 3339 UTC timestamp (contract section 2), e.g. `2026-07-19T18:00:00Z`.
38
+ * Seconds are mandatory, fractional seconds optional, offset must be `Z`.
39
+ * Field ranges (month 01-12, day 01-31, hour 00-23, leap second 60) are
40
+ * enforced by the pattern so the schema stays fully JSON-Schema representable.
41
+ */
42
+ export declare const RFC3339_UTC_REGEX: RegExp;
43
+ /**
44
+ * Stricter than the generated JSON Schema: the `.refine` below rejects
45
+ * calendar-invalid dates (e.g. `2026-02-30`) and misplaced leap seconds,
46
+ * while `z.toJSONSchema` emits only the pattern (refinements are not
47
+ * JSON-Schema representable).
48
+ */
49
+ export declare const timestampSchema: z.ZodString;
50
+ export type Timestamp = z.infer<typeof timestampSchema>;
51
+ /** ISO 8601 duration, e.g. `PT30M` (design section 25 lease settings). */
52
+ export declare const ISO8601_DURATION_REGEX: RegExp;
53
+ export declare const isoDurationSchema: z.ZodString;
54
+ export type IsoDuration = z.infer<typeof isoDurationSchema>;
55
+ /** Git commit SHA (abbreviated 7 chars up to SHA-256 64 chars). */
56
+ export declare const commitShaSchema: z.ZodString;
57
+ export type CommitSha = z.infer<typeof commitShaSchema>;
58
+ //# sourceMappingURL=primitives.d.ts.map
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Shared identifier and reference primitives (Phase 0 contract section 2).
4
+ */
5
+ /** Story node / timeline / bible ID kinds (contract section 2). */
6
+ export const NODE_KINDS = [
7
+ "premise",
8
+ "arc",
9
+ "part",
10
+ "chapter",
11
+ "scene",
12
+ "beat",
13
+ "event",
14
+ "character",
15
+ "location",
16
+ "concept",
17
+ "rule",
18
+ ];
19
+ /** Actor reference namespaces (contract section 2). */
20
+ export const ACTOR_NAMESPACES = ["github", "agent", "system"];
21
+ /** Slug source pattern: `[a-z0-9][a-z0-9-]*` (contract section 2). */
22
+ export const SLUG_PATTERN = "[a-z0-9][a-z0-9-]*";
23
+ /**
24
+ * Lowercase UUIDv7 (contract section 2): version nibble must be `7`, variant
25
+ * nibble must be RFC 4122 (`8`, `9`, `a`, or `b`).
26
+ */
27
+ export const UUIDV7_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
28
+ export const uuidv7Schema = z
29
+ .string()
30
+ .regex(UUIDV7_REGEX, "must be a lowercase UUIDv7 (version nibble 7)");
31
+ /** Path-traversal-safe slug (contract section 2). */
32
+ export const slugSchema = z
33
+ .string()
34
+ .regex(new RegExp(`^${SLUG_PATTERN}$`), "must match [a-z0-9][a-z0-9-]*");
35
+ /** `<kind>:<slug>` node ID for any known kind (contract section 2). */
36
+ export const nodeIdSchema = z
37
+ .string()
38
+ .regex(new RegExp(`^(?:${NODE_KINDS.join("|")}):${SLUG_PATTERN}$`), `must be <kind>:<slug> with kind one of ${NODE_KINDS.join("|")}`);
39
+ /** `<kind>:<slug>` node ID restricted to one specific kind. */
40
+ export function nodeIdOf(kind) {
41
+ return z
42
+ .string()
43
+ .regex(new RegExp(`^${kind}:${SLUG_PATTERN}$`), `must be a "${kind}:<slug>" id`);
44
+ }
45
+ /**
46
+ * Actor reference `<namespace>:<identifier>` (contract section 2).
47
+ * The identifier charset is not pinned by the contract; this package accepts
48
+ * `[A-Za-z0-9][A-Za-z0-9._-]*` (covers GitHub logins, agent names, and system
49
+ * components) and rejects whitespace, colons, and leading punctuation.
50
+ */
51
+ export const actorRefSchema = z
52
+ .string()
53
+ .regex(new RegExp(`^(?:${ACTOR_NAMESPACES.join("|")}):[A-Za-z0-9][A-Za-z0-9._-]*$`), `must be <namespace>:<identifier> with namespace one of ${ACTOR_NAMESPACES.join("|")}`);
54
+ /**
55
+ * RFC 3339 UTC timestamp (contract section 2), e.g. `2026-07-19T18:00:00Z`.
56
+ * Seconds are mandatory, fractional seconds optional, offset must be `Z`.
57
+ * Field ranges (month 01-12, day 01-31, hour 00-23, leap second 60) are
58
+ * enforced by the pattern so the schema stays fully JSON-Schema representable.
59
+ */
60
+ export const RFC3339_UTC_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3]):[0-5]\d:(?:[0-5]\d|60)(?:\.\d{1,9})?Z$/;
61
+ const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
62
+ /**
63
+ * Calendar rules the pattern cannot express (RFC 3339 section 5.7): the
64
+ * day-of-month must exist for the month/year, and second `60` is only legal
65
+ * at a leap-second instant (`23:59:60` UTC). Assumes the pattern already
66
+ * matched; safe on arbitrary strings.
67
+ */
68
+ function isCalendarValid(value) {
69
+ const year = Number(value.slice(0, 4));
70
+ const month = Number(value.slice(5, 7));
71
+ const day = Number(value.slice(8, 10));
72
+ const isLeapYear = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
73
+ const maxDay = month === 2 && isLeapYear ? 29 : (DAYS_IN_MONTH[month - 1] ?? 0);
74
+ if (day > maxDay) {
75
+ return false;
76
+ }
77
+ if (value.slice(17, 19) === "60" && value.slice(11, 16) !== "23:59") {
78
+ return false;
79
+ }
80
+ return true;
81
+ }
82
+ /**
83
+ * Stricter than the generated JSON Schema: the `.refine` below rejects
84
+ * calendar-invalid dates (e.g. `2026-02-30`) and misplaced leap seconds,
85
+ * while `z.toJSONSchema` emits only the pattern (refinements are not
86
+ * JSON-Schema representable).
87
+ */
88
+ export const timestampSchema = z
89
+ .string()
90
+ .regex(RFC3339_UTC_REGEX, "must be an RFC 3339 UTC timestamp like 2026-07-19T18:00:00Z")
91
+ .refine(isCalendarValid, "must be a real calendar date/time (RFC 3339)");
92
+ /** ISO 8601 duration, e.g. `PT30M` (design section 25 lease settings). */
93
+ export const ISO8601_DURATION_REGEX = /^P(?!$)(?:\d+Y)?(?:\d+M)?(?:\d+W)?(?:\d+D)?(?:T(?=\d)(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?$/;
94
+ export const isoDurationSchema = z
95
+ .string()
96
+ .regex(ISO8601_DURATION_REGEX, "must be an ISO 8601 duration like PT30M");
97
+ /** Git commit SHA (abbreviated 7 chars up to SHA-256 64 chars). */
98
+ export const commitShaSchema = z
99
+ .string()
100
+ .regex(/^[0-9a-f]{7,64}$/, "must be a lowercase hex commit SHA");
101
+ //# sourceMappingURL=primitives.js.map