@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.
- package/LICENSE +21 -0
- package/dist/annotation.d.ts +172 -0
- package/dist/annotation.js +96 -0
- package/dist/attribution.d.ts +25 -0
- package/dist/attribution.js +19 -0
- package/dist/book.d.ts +104 -0
- package/dist/book.js +105 -0
- package/dist/build.d.ts +44 -0
- package/dist/build.js +28 -0
- package/dist/chapter.d.ts +37 -0
- package/dist/chapter.js +29 -0
- package/dist/character.d.ts +15 -0
- package/dist/character.js +16 -0
- package/dist/decision.d.ts +34 -0
- package/dist/decision.js +31 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +15 -0
- package/dist/instance.d.ts +260 -0
- package/dist/instance.js +101 -0
- package/dist/json-schemas.d.ts +455 -0
- package/dist/json-schemas.js +61 -0
- package/dist/primitives.d.ts +58 -0
- package/dist/primitives.js +101 -0
- package/dist/release.d.ts +17 -0
- package/dist/release.js +19 -0
- package/dist/scripts/generate-json-schemas.d.ts +2 -0
- package/dist/scripts/generate-json-schemas.js +14 -0
- package/dist/story-graph.d.ts +132 -0
- package/dist/story-graph.js +56 -0
- package/dist/timeline.d.ts +35 -0
- package/dist/timeline.js +28 -0
- package/dist/work-item.d.ts +75 -0
- package/dist/work-item.js +48 -0
- package/json/annotation.schema.json +279 -0
- package/json/attribution.schema.json +52 -0
- package/json/book.schema.json +270 -0
- package/json/build.schema.json +84 -0
- package/json/chapter.schema.json +89 -0
- package/json/character.schema.json +39 -0
- package/json/decision.schema.json +69 -0
- package/json/instance.schema.json +273 -0
- package/json/release.schema.json +52 -0
- package/json/reply.schema.json +43 -0
- package/json/story-graph.schema.json +159 -0
- package/json/timeline.schema.json +91 -0
- package/json/work-item.schema.json +78 -0
- package/package.json +56 -0
package/dist/chapter.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { actorRefSchema, nodeIdOf, slugSchema, timestampSchema, uuidv7Schema, } from "./primitives.js";
|
|
3
|
+
/** Chapter lifecycle states (contract section 4, design section 9.3). */
|
|
4
|
+
export const CHAPTER_STATUSES = [
|
|
5
|
+
"draft",
|
|
6
|
+
"proposed",
|
|
7
|
+
"published",
|
|
8
|
+
"archived",
|
|
9
|
+
];
|
|
10
|
+
export const chapterStatusSchema = z.enum(CHAPTER_STATUSES);
|
|
11
|
+
/**
|
|
12
|
+
* Chapter frontmatter — `authorbot.chapter/v1` (design section 8.3,
|
|
13
|
+
* contract section 4).
|
|
14
|
+
*/
|
|
15
|
+
export const chapterFrontmatterSchema = z.strictObject({
|
|
16
|
+
schema: z.literal("authorbot.chapter/v1"),
|
|
17
|
+
id: uuidv7Schema,
|
|
18
|
+
slug: slugSchema,
|
|
19
|
+
title: z.string().min(1),
|
|
20
|
+
order: z.number(),
|
|
21
|
+
status: chapterStatusSchema,
|
|
22
|
+
revision: z.number().int().min(1),
|
|
23
|
+
published_at: timestampSchema.optional(),
|
|
24
|
+
authors: z.array(z.strictObject({ actor: actorRefSchema })).min(1),
|
|
25
|
+
summary: z.string().optional(),
|
|
26
|
+
timeline_refs: z.array(nodeIdOf("event")).optional(),
|
|
27
|
+
character_refs: z.array(nodeIdOf("character")).optional(),
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=chapter.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Character frontmatter `story/characters/*.md` — `authorbot.character/v1`
|
|
4
|
+
* (contract section 4).
|
|
5
|
+
*/
|
|
6
|
+
export declare const characterSchema: z.ZodObject<{
|
|
7
|
+
schema: z.ZodLiteral<"authorbot.character/v1">;
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
12
|
+
status: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export type Character = z.infer<typeof characterSchema>;
|
|
15
|
+
//# sourceMappingURL=character.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { nodeIdOf } from "./primitives.js";
|
|
3
|
+
/**
|
|
4
|
+
* Character frontmatter `story/characters/*.md` — `authorbot.character/v1`
|
|
5
|
+
* (contract section 4).
|
|
6
|
+
*/
|
|
7
|
+
export const characterSchema = z.strictObject({
|
|
8
|
+
schema: z.literal("authorbot.character/v1"),
|
|
9
|
+
id: nodeIdOf("character"),
|
|
10
|
+
name: z.string().min(1),
|
|
11
|
+
aliases: z.array(z.string().min(1)).optional(),
|
|
12
|
+
summary: z.string().optional(),
|
|
13
|
+
/** Free-form record status; the contract does not pin an enum. */
|
|
14
|
+
status: z.string().min(1).optional(),
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=character.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Decision results (contract section 4). */
|
|
3
|
+
export declare const DECISION_RESULTS: readonly ["create_work_item", "rejected", "support_changed", "overridden"];
|
|
4
|
+
export declare const decisionResultSchema: z.ZodEnum<{
|
|
5
|
+
rejected: "rejected";
|
|
6
|
+
create_work_item: "create_work_item";
|
|
7
|
+
support_changed: "support_changed";
|
|
8
|
+
overridden: "overridden";
|
|
9
|
+
}>;
|
|
10
|
+
export type DecisionResult = z.infer<typeof decisionResultSchema>;
|
|
11
|
+
/**
|
|
12
|
+
* Decision record `.authorbot/decisions/<id>.yml` — `authorbot.decision/v1`
|
|
13
|
+
* (contract section 4). `effective_at` is required; only `work_item_id` and
|
|
14
|
+
* `override_reason` are optional per the contract wording.
|
|
15
|
+
*/
|
|
16
|
+
export declare const decisionSchema: z.ZodObject<{
|
|
17
|
+
schema: z.ZodLiteral<"authorbot.decision/v1">;
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
source_annotation_id: z.ZodString;
|
|
20
|
+
rule: z.ZodString;
|
|
21
|
+
rule_version: z.ZodNumber;
|
|
22
|
+
metrics: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
23
|
+
result: z.ZodEnum<{
|
|
24
|
+
rejected: "rejected";
|
|
25
|
+
create_work_item: "create_work_item";
|
|
26
|
+
support_changed: "support_changed";
|
|
27
|
+
overridden: "overridden";
|
|
28
|
+
}>;
|
|
29
|
+
work_item_id: z.ZodOptional<z.ZodString>;
|
|
30
|
+
effective_at: z.ZodString;
|
|
31
|
+
override_reason: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
export type Decision = z.infer<typeof decisionSchema>;
|
|
34
|
+
//# sourceMappingURL=decision.d.ts.map
|
package/dist/decision.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { timestampSchema, uuidv7Schema } from "./primitives.js";
|
|
3
|
+
/** Decision results (contract section 4). */
|
|
4
|
+
export const DECISION_RESULTS = [
|
|
5
|
+
"create_work_item",
|
|
6
|
+
"rejected",
|
|
7
|
+
"support_changed",
|
|
8
|
+
"overridden",
|
|
9
|
+
];
|
|
10
|
+
export const decisionResultSchema = z.enum(DECISION_RESULTS);
|
|
11
|
+
/**
|
|
12
|
+
* Decision record `.authorbot/decisions/<id>.yml` — `authorbot.decision/v1`
|
|
13
|
+
* (contract section 4). `effective_at` is required; only `work_item_id` and
|
|
14
|
+
* `override_reason` are optional per the contract wording.
|
|
15
|
+
*/
|
|
16
|
+
export const decisionSchema = z.strictObject({
|
|
17
|
+
schema: z.literal("authorbot.decision/v1"),
|
|
18
|
+
id: uuidv7Schema,
|
|
19
|
+
source_annotation_id: uuidv7Schema,
|
|
20
|
+
rule: z.string().min(1),
|
|
21
|
+
// `rule_version: 0` is reserved for maintainer force-create decisions
|
|
22
|
+
// (contract §4); rule crossings use versions >= 1.
|
|
23
|
+
rule_version: z.number().int().min(0),
|
|
24
|
+
/** Aggregate metric snapshot, e.g. `{ approvals: 3, net_score: 2 }`. */
|
|
25
|
+
metrics: z.record(z.string(), z.number()),
|
|
26
|
+
result: decisionResultSchema,
|
|
27
|
+
work_item_id: uuidv7Schema.optional(),
|
|
28
|
+
effective_at: timestampSchema,
|
|
29
|
+
override_reason: z.string().min(1).optional(),
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=decision.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { ACTOR_NAMESPACES, ISO8601_DURATION_REGEX, NODE_KINDS, RFC3339_UTC_REGEX, SLUG_PATTERN, UUIDV7_REGEX, actorRefSchema, commitShaSchema, isoDurationSchema, nodeIdOf, nodeIdSchema, slugSchema, timestampSchema, uuidv7Schema, } from "./primitives.js";
|
|
2
|
+
export type { ActorNamespace, ActorRef, CommitSha, IsoDuration, NodeId, NodeKind, Slug, Timestamp, UuidV7, } from "./primitives.js";
|
|
3
|
+
export { ANNOTATION_POLICY_MODES, annotationPolicySchema, bookConfigSchema, } from "./book.js";
|
|
4
|
+
export type { AnnotationPolicyMode, BookConfig } from "./book.js";
|
|
5
|
+
export { CHAPTER_STATUSES, chapterFrontmatterSchema, chapterStatusSchema } from "./chapter.js";
|
|
6
|
+
export type { ChapterFrontmatter, ChapterStatus } from "./chapter.js";
|
|
7
|
+
export { STORY_NODE_TYPES, storyGraphChapterNodeSchema, storyGraphLinkSchema, storyGraphNodeSchema, storyGraphSchema, storyGraphStoryNodeSchema, } from "./story-graph.js";
|
|
8
|
+
export type { StoryGraph, StoryGraphChapterNode, StoryGraphLink, StoryGraphNode, StoryGraphStoryNode, StoryNodeType, } from "./story-graph.js";
|
|
9
|
+
export { timelineEventSchema, timelineSchema } from "./timeline.js";
|
|
10
|
+
export type { Timeline, TimelineEvent } from "./timeline.js";
|
|
11
|
+
export { characterSchema } from "./character.js";
|
|
12
|
+
export type { Character } from "./character.js";
|
|
13
|
+
export { ANNOTATION_KINDS, ANNOTATION_STATUSES, MAX_QUOTE_CONTEXT, MAX_QUOTE_EXACT, annotationKindSchema, annotationSchema, annotationStatusSchema, blockTargetSchema, rangeTargetSchema, replySchema, textPositionSchema, textQuoteSchema, } from "./annotation.js";
|
|
14
|
+
export type { Annotation, AnnotationKind, AnnotationStatus, BlockTarget, RangeTarget, Reply, TextPosition, TextQuote, } from "./annotation.js";
|
|
15
|
+
export { DECISION_RESULTS, decisionResultSchema, decisionSchema } from "./decision.js";
|
|
16
|
+
export type { Decision, DecisionResult } from "./decision.js";
|
|
17
|
+
export { WORK_ITEM_PRIORITIES, WORK_ITEM_STATUSES, WORK_ITEM_TYPES, workItemPrioritySchema, workItemSchema, workItemStatusSchema, workItemTypeSchema, } from "./work-item.js";
|
|
18
|
+
export type { WorkItem, WorkItemPriority, WorkItemStatus, WorkItemType, } from "./work-item.js";
|
|
19
|
+
export { attributionEntrySchema, attributionSchema } from "./attribution.js";
|
|
20
|
+
export type { Attribution, AttributionEntry } from "./attribution.js";
|
|
21
|
+
export { releaseSchema } from "./release.js";
|
|
22
|
+
export type { Release } from "./release.js";
|
|
23
|
+
export { buildManifestChapterSchema, buildManifestSchema } from "./build.js";
|
|
24
|
+
export type { BuildManifest, BuildManifestChapter } from "./build.js";
|
|
25
|
+
export { declarativeRuleSchema, instanceConfigSchema, ruleActionSchema, ruleConditionSchema, ruleMetricNameSchema, ruleNameSchema, ruleWhenSchema, rulesMapSchema, } from "./instance.js";
|
|
26
|
+
export type { DeclarativeRule, InstanceConfig, RuleAction, RuleCondition, RulesMap, RuleWhen, } from "./instance.js";
|
|
27
|
+
export { SCHEMA_IDS, artifactSchemas, buildJsonSchemas } from "./json-schemas.js";
|
|
28
|
+
export type { ArtifactName } from "./json-schemas.js";
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { ACTOR_NAMESPACES, ISO8601_DURATION_REGEX, NODE_KINDS, RFC3339_UTC_REGEX, SLUG_PATTERN, UUIDV7_REGEX, actorRefSchema, commitShaSchema, isoDurationSchema, nodeIdOf, nodeIdSchema, slugSchema, timestampSchema, uuidv7Schema, } from "./primitives.js";
|
|
2
|
+
export { ANNOTATION_POLICY_MODES, annotationPolicySchema, bookConfigSchema, } from "./book.js";
|
|
3
|
+
export { CHAPTER_STATUSES, chapterFrontmatterSchema, chapterStatusSchema } from "./chapter.js";
|
|
4
|
+
export { STORY_NODE_TYPES, storyGraphChapterNodeSchema, storyGraphLinkSchema, storyGraphNodeSchema, storyGraphSchema, storyGraphStoryNodeSchema, } from "./story-graph.js";
|
|
5
|
+
export { timelineEventSchema, timelineSchema } from "./timeline.js";
|
|
6
|
+
export { characterSchema } from "./character.js";
|
|
7
|
+
export { ANNOTATION_KINDS, ANNOTATION_STATUSES, MAX_QUOTE_CONTEXT, MAX_QUOTE_EXACT, annotationKindSchema, annotationSchema, annotationStatusSchema, blockTargetSchema, rangeTargetSchema, replySchema, textPositionSchema, textQuoteSchema, } from "./annotation.js";
|
|
8
|
+
export { DECISION_RESULTS, decisionResultSchema, decisionSchema } from "./decision.js";
|
|
9
|
+
export { WORK_ITEM_PRIORITIES, WORK_ITEM_STATUSES, WORK_ITEM_TYPES, workItemPrioritySchema, workItemSchema, workItemStatusSchema, workItemTypeSchema, } from "./work-item.js";
|
|
10
|
+
export { attributionEntrySchema, attributionSchema } from "./attribution.js";
|
|
11
|
+
export { releaseSchema } from "./release.js";
|
|
12
|
+
export { buildManifestChapterSchema, buildManifestSchema } from "./build.js";
|
|
13
|
+
export { declarativeRuleSchema, instanceConfigSchema, ruleActionSchema, ruleConditionSchema, ruleMetricNameSchema, ruleNameSchema, ruleWhenSchema, rulesMapSchema, } from "./instance.js";
|
|
14
|
+
export { SCHEMA_IDS, artifactSchemas, buildJsonSchemas } from "./json-schemas.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Declarative rule shape (design section 11.1). Rules are data; no
|
|
4
|
+
* expressions or code are ever evaluated from configuration.
|
|
5
|
+
*/
|
|
6
|
+
/** Snake_case metric name, e.g. `approvals`, `net_score`, `human_approvals`.
|
|
7
|
+
* The design keeps the metric list "small and explicit" but does not pin it,
|
|
8
|
+
* so the schema constrains the shape rather than an enum. */
|
|
9
|
+
export declare const ruleMetricNameSchema: z.ZodString;
|
|
10
|
+
export declare const ruleConditionSchema: z.ZodObject<{
|
|
11
|
+
metric: z.ZodString;
|
|
12
|
+
operator: z.ZodEnum<{
|
|
13
|
+
gte: "gte";
|
|
14
|
+
gt: "gt";
|
|
15
|
+
lte: "lte";
|
|
16
|
+
lt: "lt";
|
|
17
|
+
eq: "eq";
|
|
18
|
+
neq: "neq";
|
|
19
|
+
}>;
|
|
20
|
+
value: z.ZodNumber;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
export type RuleCondition = z.infer<typeof ruleConditionSchema>;
|
|
23
|
+
/** Condition group: exactly one of `all` / `any` (design shows `all`). */
|
|
24
|
+
export declare const ruleWhenSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
25
|
+
all: z.ZodArray<z.ZodObject<{
|
|
26
|
+
metric: z.ZodString;
|
|
27
|
+
operator: z.ZodEnum<{
|
|
28
|
+
gte: "gte";
|
|
29
|
+
gt: "gt";
|
|
30
|
+
lte: "lte";
|
|
31
|
+
lt: "lt";
|
|
32
|
+
eq: "eq";
|
|
33
|
+
neq: "neq";
|
|
34
|
+
}>;
|
|
35
|
+
value: z.ZodNumber;
|
|
36
|
+
}, z.core.$strict>>;
|
|
37
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
38
|
+
any: z.ZodArray<z.ZodObject<{
|
|
39
|
+
metric: z.ZodString;
|
|
40
|
+
operator: z.ZodEnum<{
|
|
41
|
+
gte: "gte";
|
|
42
|
+
gt: "gt";
|
|
43
|
+
lte: "lte";
|
|
44
|
+
lt: "lt";
|
|
45
|
+
eq: "eq";
|
|
46
|
+
neq: "neq";
|
|
47
|
+
}>;
|
|
48
|
+
value: z.ZodNumber;
|
|
49
|
+
}, z.core.$strict>>;
|
|
50
|
+
}, z.core.$strict>]>;
|
|
51
|
+
export type RuleWhen = z.infer<typeof ruleWhenSchema>;
|
|
52
|
+
export declare const ruleActionSchema: z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"create_work_item">;
|
|
54
|
+
work_type: z.ZodEnum<{
|
|
55
|
+
revise_range: "revise_range";
|
|
56
|
+
revise_block: "revise_block";
|
|
57
|
+
revise_chapter: "revise_chapter";
|
|
58
|
+
write_chapter: "write_chapter";
|
|
59
|
+
resolve_conflict: "resolve_conflict";
|
|
60
|
+
planning: "planning";
|
|
61
|
+
}>;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
export type RuleAction = z.infer<typeof ruleActionSchema>;
|
|
64
|
+
export declare const declarativeRuleSchema: z.ZodObject<{
|
|
65
|
+
version: z.ZodNumber;
|
|
66
|
+
trigger: z.ZodOptional<z.ZodEnum<{
|
|
67
|
+
vote_changed: "vote_changed";
|
|
68
|
+
}>>;
|
|
69
|
+
when: z.ZodUnion<readonly [z.ZodObject<{
|
|
70
|
+
all: z.ZodArray<z.ZodObject<{
|
|
71
|
+
metric: z.ZodString;
|
|
72
|
+
operator: z.ZodEnum<{
|
|
73
|
+
gte: "gte";
|
|
74
|
+
gt: "gt";
|
|
75
|
+
lte: "lte";
|
|
76
|
+
lt: "lt";
|
|
77
|
+
eq: "eq";
|
|
78
|
+
neq: "neq";
|
|
79
|
+
}>;
|
|
80
|
+
value: z.ZodNumber;
|
|
81
|
+
}, z.core.$strict>>;
|
|
82
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
83
|
+
any: z.ZodArray<z.ZodObject<{
|
|
84
|
+
metric: z.ZodString;
|
|
85
|
+
operator: z.ZodEnum<{
|
|
86
|
+
gte: "gte";
|
|
87
|
+
gt: "gt";
|
|
88
|
+
lte: "lte";
|
|
89
|
+
lt: "lt";
|
|
90
|
+
eq: "eq";
|
|
91
|
+
neq: "neq";
|
|
92
|
+
}>;
|
|
93
|
+
value: z.ZodNumber;
|
|
94
|
+
}, z.core.$strict>>;
|
|
95
|
+
}, z.core.$strict>]>;
|
|
96
|
+
action: z.ZodObject<{
|
|
97
|
+
type: z.ZodLiteral<"create_work_item">;
|
|
98
|
+
work_type: z.ZodEnum<{
|
|
99
|
+
revise_range: "revise_range";
|
|
100
|
+
revise_block: "revise_block";
|
|
101
|
+
revise_chapter: "revise_chapter";
|
|
102
|
+
write_chapter: "write_chapter";
|
|
103
|
+
resolve_conflict: "resolve_conflict";
|
|
104
|
+
planning: "planning";
|
|
105
|
+
}>;
|
|
106
|
+
}, z.core.$strict>;
|
|
107
|
+
}, z.core.$strict>;
|
|
108
|
+
export type DeclarativeRule = z.infer<typeof declarativeRuleSchema>;
|
|
109
|
+
/** Rule name: the key of a `rules` mapping (design sections 11.1 / 25). */
|
|
110
|
+
export declare const ruleNameSchema: z.ZodString;
|
|
111
|
+
/**
|
|
112
|
+
* The `rules` mapping — `{ "<rule_name>": { version, when, action } }`.
|
|
113
|
+
*
|
|
114
|
+
* Shared by `authorbot.instance/v1` (`rules`, the bootstrap default carried by
|
|
115
|
+
* the `RULES_JSON` environment variable) and `authorbot.book/v1`
|
|
116
|
+
* (`governance.rules`, the versioned per-book governance a maintainer edits in
|
|
117
|
+
* settings; Phase 6 contract section 3.6 "Amendment to Phase 3 section 3").
|
|
118
|
+
* One schema so the two can never diverge in shape.
|
|
119
|
+
*/
|
|
120
|
+
export declare const rulesMapSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
121
|
+
version: z.ZodNumber;
|
|
122
|
+
trigger: z.ZodOptional<z.ZodEnum<{
|
|
123
|
+
vote_changed: "vote_changed";
|
|
124
|
+
}>>;
|
|
125
|
+
when: z.ZodUnion<readonly [z.ZodObject<{
|
|
126
|
+
all: z.ZodArray<z.ZodObject<{
|
|
127
|
+
metric: z.ZodString;
|
|
128
|
+
operator: z.ZodEnum<{
|
|
129
|
+
gte: "gte";
|
|
130
|
+
gt: "gt";
|
|
131
|
+
lte: "lte";
|
|
132
|
+
lt: "lt";
|
|
133
|
+
eq: "eq";
|
|
134
|
+
neq: "neq";
|
|
135
|
+
}>;
|
|
136
|
+
value: z.ZodNumber;
|
|
137
|
+
}, z.core.$strict>>;
|
|
138
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
139
|
+
any: z.ZodArray<z.ZodObject<{
|
|
140
|
+
metric: z.ZodString;
|
|
141
|
+
operator: z.ZodEnum<{
|
|
142
|
+
gte: "gte";
|
|
143
|
+
gt: "gt";
|
|
144
|
+
lte: "lte";
|
|
145
|
+
lt: "lt";
|
|
146
|
+
eq: "eq";
|
|
147
|
+
neq: "neq";
|
|
148
|
+
}>;
|
|
149
|
+
value: z.ZodNumber;
|
|
150
|
+
}, z.core.$strict>>;
|
|
151
|
+
}, z.core.$strict>]>;
|
|
152
|
+
action: z.ZodObject<{
|
|
153
|
+
type: z.ZodLiteral<"create_work_item">;
|
|
154
|
+
work_type: z.ZodEnum<{
|
|
155
|
+
revise_range: "revise_range";
|
|
156
|
+
revise_block: "revise_block";
|
|
157
|
+
revise_chapter: "revise_chapter";
|
|
158
|
+
write_chapter: "write_chapter";
|
|
159
|
+
resolve_conflict: "resolve_conflict";
|
|
160
|
+
planning: "planning";
|
|
161
|
+
}>;
|
|
162
|
+
}, z.core.$strict>;
|
|
163
|
+
}, z.core.$strict>>;
|
|
164
|
+
export type RulesMap = z.infer<typeof rulesMapSchema>;
|
|
165
|
+
/**
|
|
166
|
+
* Instance (deployment) config — `authorbot.instance/v1` (design section 25).
|
|
167
|
+
* Every section is optional: the file overrides defaults, and defaults are
|
|
168
|
+
* applied by the loader, not by this schema. Secrets never belong here.
|
|
169
|
+
*/
|
|
170
|
+
export declare const instanceConfigSchema: z.ZodObject<{
|
|
171
|
+
schema: z.ZodLiteral<"authorbot.instance/v1">;
|
|
172
|
+
project: z.ZodOptional<z.ZodObject<{
|
|
173
|
+
book_config_path: z.ZodOptional<z.ZodString>;
|
|
174
|
+
default_branch: z.ZodOptional<z.ZodString>;
|
|
175
|
+
}, z.core.$strict>>;
|
|
176
|
+
access: z.ZodOptional<z.ZodObject<{
|
|
177
|
+
public_read: z.ZodOptional<z.ZodBoolean>;
|
|
178
|
+
public_annotations: z.ZodOptional<z.ZodBoolean>;
|
|
179
|
+
writes_require_membership: z.ZodOptional<z.ZodBoolean>;
|
|
180
|
+
}, z.core.$strict>>;
|
|
181
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
182
|
+
context_characters: z.ZodOptional<z.ZodNumber>;
|
|
183
|
+
range_scope: z.ZodOptional<z.ZodEnum<{
|
|
184
|
+
single_block: "single_block";
|
|
185
|
+
}>>;
|
|
186
|
+
allow_range_comments: z.ZodOptional<z.ZodBoolean>;
|
|
187
|
+
allow_chapter_comments: z.ZodOptional<z.ZodBoolean>;
|
|
188
|
+
}, z.core.$strict>>;
|
|
189
|
+
votes: z.ZodOptional<z.ZodObject<{
|
|
190
|
+
values: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
191
|
+
approve: "approve";
|
|
192
|
+
reject: "reject";
|
|
193
|
+
abstain: "abstain";
|
|
194
|
+
}>>>;
|
|
195
|
+
export: z.ZodOptional<z.ZodEnum<{
|
|
196
|
+
aggregate: "aggregate";
|
|
197
|
+
named: "named";
|
|
198
|
+
pseudonymous: "pseudonymous";
|
|
199
|
+
}>>;
|
|
200
|
+
}, z.core.$strict>>;
|
|
201
|
+
rules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
202
|
+
version: z.ZodNumber;
|
|
203
|
+
trigger: z.ZodOptional<z.ZodEnum<{
|
|
204
|
+
vote_changed: "vote_changed";
|
|
205
|
+
}>>;
|
|
206
|
+
when: z.ZodUnion<readonly [z.ZodObject<{
|
|
207
|
+
all: z.ZodArray<z.ZodObject<{
|
|
208
|
+
metric: z.ZodString;
|
|
209
|
+
operator: z.ZodEnum<{
|
|
210
|
+
gte: "gte";
|
|
211
|
+
gt: "gt";
|
|
212
|
+
lte: "lte";
|
|
213
|
+
lt: "lt";
|
|
214
|
+
eq: "eq";
|
|
215
|
+
neq: "neq";
|
|
216
|
+
}>;
|
|
217
|
+
value: z.ZodNumber;
|
|
218
|
+
}, z.core.$strict>>;
|
|
219
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
220
|
+
any: z.ZodArray<z.ZodObject<{
|
|
221
|
+
metric: z.ZodString;
|
|
222
|
+
operator: z.ZodEnum<{
|
|
223
|
+
gte: "gte";
|
|
224
|
+
gt: "gt";
|
|
225
|
+
lte: "lte";
|
|
226
|
+
lt: "lt";
|
|
227
|
+
eq: "eq";
|
|
228
|
+
neq: "neq";
|
|
229
|
+
}>;
|
|
230
|
+
value: z.ZodNumber;
|
|
231
|
+
}, z.core.$strict>>;
|
|
232
|
+
}, z.core.$strict>]>;
|
|
233
|
+
action: z.ZodObject<{
|
|
234
|
+
type: z.ZodLiteral<"create_work_item">;
|
|
235
|
+
work_type: z.ZodEnum<{
|
|
236
|
+
revise_range: "revise_range";
|
|
237
|
+
revise_block: "revise_block";
|
|
238
|
+
revise_chapter: "revise_chapter";
|
|
239
|
+
write_chapter: "write_chapter";
|
|
240
|
+
resolve_conflict: "resolve_conflict";
|
|
241
|
+
planning: "planning";
|
|
242
|
+
}>;
|
|
243
|
+
}, z.core.$strict>;
|
|
244
|
+
}, z.core.$strict>>>;
|
|
245
|
+
leases: z.ZodOptional<z.ZodObject<{
|
|
246
|
+
duration: z.ZodOptional<z.ZodString>;
|
|
247
|
+
renewal_prompt_before: z.ZodOptional<z.ZodString>;
|
|
248
|
+
renewal_duration: z.ZodOptional<z.ZodString>;
|
|
249
|
+
maximum_total_duration: z.ZodOptional<z.ZodString>;
|
|
250
|
+
}, z.core.$strict>>;
|
|
251
|
+
publishing: z.ZodOptional<z.ZodObject<{
|
|
252
|
+
collaboration_data: z.ZodOptional<z.ZodEnum<{
|
|
253
|
+
dynamic: "dynamic";
|
|
254
|
+
static: "static";
|
|
255
|
+
}>>;
|
|
256
|
+
static_snapshot_on_release: z.ZodOptional<z.ZodBoolean>;
|
|
257
|
+
}, z.core.$strict>>;
|
|
258
|
+
}, z.core.$strict>;
|
|
259
|
+
export type InstanceConfig = z.infer<typeof instanceConfigSchema>;
|
|
260
|
+
//# sourceMappingURL=instance.d.ts.map
|
package/dist/instance.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isoDurationSchema } from "./primitives.js";
|
|
3
|
+
import { workItemTypeSchema } from "./work-item.js";
|
|
4
|
+
/**
|
|
5
|
+
* Declarative rule shape (design section 11.1). Rules are data; no
|
|
6
|
+
* expressions or code are ever evaluated from configuration.
|
|
7
|
+
*/
|
|
8
|
+
/** Snake_case metric name, e.g. `approvals`, `net_score`, `human_approvals`.
|
|
9
|
+
* The design keeps the metric list "small and explicit" but does not pin it,
|
|
10
|
+
* so the schema constrains the shape rather than an enum. */
|
|
11
|
+
export const ruleMetricNameSchema = z
|
|
12
|
+
.string()
|
|
13
|
+
.regex(/^[a-z][a-z0-9_]*$/, "must be a snake_case metric name");
|
|
14
|
+
export const ruleConditionSchema = z.strictObject({
|
|
15
|
+
metric: ruleMetricNameSchema,
|
|
16
|
+
operator: z.enum(["gte", "gt", "lte", "lt", "eq", "neq"]),
|
|
17
|
+
value: z.number(),
|
|
18
|
+
});
|
|
19
|
+
/** Condition group: exactly one of `all` / `any` (design shows `all`). */
|
|
20
|
+
export const ruleWhenSchema = z.union([
|
|
21
|
+
z.strictObject({ all: z.array(ruleConditionSchema).min(1) }),
|
|
22
|
+
z.strictObject({ any: z.array(ruleConditionSchema).min(1) }),
|
|
23
|
+
]);
|
|
24
|
+
export const ruleActionSchema = z.strictObject({
|
|
25
|
+
type: z.literal("create_work_item"),
|
|
26
|
+
work_type: workItemTypeSchema,
|
|
27
|
+
});
|
|
28
|
+
export const declarativeRuleSchema = z.strictObject({
|
|
29
|
+
version: z.number().int().min(1),
|
|
30
|
+
/** `vote_changed` is the only trigger defined for v0.1 (design 11.1). */
|
|
31
|
+
trigger: z.enum(["vote_changed"]).optional(),
|
|
32
|
+
when: ruleWhenSchema,
|
|
33
|
+
action: ruleActionSchema,
|
|
34
|
+
});
|
|
35
|
+
/** Rule name: the key of a `rules` mapping (design sections 11.1 / 25). */
|
|
36
|
+
export const ruleNameSchema = z
|
|
37
|
+
.string()
|
|
38
|
+
.regex(/^[a-z][a-z0-9_]*$/, "must be a snake_case rule name");
|
|
39
|
+
/**
|
|
40
|
+
* The `rules` mapping — `{ "<rule_name>": { version, when, action } }`.
|
|
41
|
+
*
|
|
42
|
+
* Shared by `authorbot.instance/v1` (`rules`, the bootstrap default carried by
|
|
43
|
+
* the `RULES_JSON` environment variable) and `authorbot.book/v1`
|
|
44
|
+
* (`governance.rules`, the versioned per-book governance a maintainer edits in
|
|
45
|
+
* settings; Phase 6 contract section 3.6 "Amendment to Phase 3 section 3").
|
|
46
|
+
* One schema so the two can never diverge in shape.
|
|
47
|
+
*/
|
|
48
|
+
export const rulesMapSchema = z.record(ruleNameSchema, declarativeRuleSchema);
|
|
49
|
+
/**
|
|
50
|
+
* Instance (deployment) config — `authorbot.instance/v1` (design section 25).
|
|
51
|
+
* Every section is optional: the file overrides defaults, and defaults are
|
|
52
|
+
* applied by the loader, not by this schema. Secrets never belong here.
|
|
53
|
+
*/
|
|
54
|
+
export const instanceConfigSchema = z.strictObject({
|
|
55
|
+
schema: z.literal("authorbot.instance/v1"),
|
|
56
|
+
project: z
|
|
57
|
+
.strictObject({
|
|
58
|
+
book_config_path: z.string().min(1).optional(),
|
|
59
|
+
default_branch: z.string().min(1).optional(),
|
|
60
|
+
})
|
|
61
|
+
.optional(),
|
|
62
|
+
access: z
|
|
63
|
+
.strictObject({
|
|
64
|
+
public_read: z.boolean().optional(),
|
|
65
|
+
public_annotations: z.boolean().optional(),
|
|
66
|
+
writes_require_membership: z.boolean().optional(),
|
|
67
|
+
})
|
|
68
|
+
.optional(),
|
|
69
|
+
annotations: z
|
|
70
|
+
.strictObject({
|
|
71
|
+
context_characters: z.number().int().min(0).optional(),
|
|
72
|
+
/** v0.1 restriction: range selections stay in one block (design 8.4). */
|
|
73
|
+
range_scope: z.enum(["single_block"]).optional(),
|
|
74
|
+
allow_range_comments: z.boolean().optional(),
|
|
75
|
+
allow_chapter_comments: z.boolean().optional(),
|
|
76
|
+
})
|
|
77
|
+
.optional(),
|
|
78
|
+
votes: z
|
|
79
|
+
.strictObject({
|
|
80
|
+
values: z.array(z.enum(["approve", "reject", "abstain"])).min(1).optional(),
|
|
81
|
+
/** Vote export mode (design sections 25 and 26). */
|
|
82
|
+
export: z.enum(["aggregate", "named", "pseudonymous"]).optional(),
|
|
83
|
+
})
|
|
84
|
+
.optional(),
|
|
85
|
+
rules: rulesMapSchema.optional(),
|
|
86
|
+
leases: z
|
|
87
|
+
.strictObject({
|
|
88
|
+
duration: isoDurationSchema.optional(),
|
|
89
|
+
renewal_prompt_before: isoDurationSchema.optional(),
|
|
90
|
+
renewal_duration: isoDurationSchema.optional(),
|
|
91
|
+
maximum_total_duration: isoDurationSchema.optional(),
|
|
92
|
+
})
|
|
93
|
+
.optional(),
|
|
94
|
+
publishing: z
|
|
95
|
+
.strictObject({
|
|
96
|
+
collaboration_data: z.enum(["dynamic", "static"]).optional(),
|
|
97
|
+
static_snapshot_on_release: z.boolean().optional(),
|
|
98
|
+
})
|
|
99
|
+
.optional(),
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=instance.js.map
|