@camox/api-contract 0.78.0 → 0.79.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/src/voice.ts ADDED
@@ -0,0 +1,229 @@
1
+ // The Voice (GLOSSARY: Voice, Voice Axis): how a website speaks, as one chosen step on each of six
2
+ // Voice Axes. The axes, their steps in order and each step's one-line definition are fixed here,
3
+ // the same for every project: members pick a step, writers and the Voice Check read the
4
+ // definitions, and the API stores a step by its key.
5
+
6
+ /**
7
+ * The Voice Axes, each with its steps in order and each step's one-line definition. The Voice is
8
+ * a limit, not a target, and each axis's `limit` says how: under a `ceiling`, copy may sit at any
9
+ * step below the chosen one, never above; in a `band`, within one step of it either way.
10
+ */
11
+ export const VOICE_AXES = [
12
+ {
13
+ key: "formality",
14
+ limit: "band",
15
+ name: "Formality",
16
+ about: "register, grammar, vocabulary",
17
+ steps: [
18
+ {
19
+ key: "ceremonial",
20
+ name: "Ceremonial",
21
+ definition: "elevated, ritual register; no contractions; set phrases and honorifics.",
22
+ },
23
+ {
24
+ key: "formal",
25
+ name: "Formal",
26
+ definition: "correct and impersonal; no contractions or slang; complete sentences.",
27
+ },
28
+ {
29
+ key: "neutral",
30
+ name: "Neutral",
31
+ definition: "standard written register; contractions allowed; no slang.",
32
+ },
33
+ {
34
+ key: "conversational",
35
+ name: "Conversational",
36
+ definition:
37
+ "as spoken to a customer; contractions, short sentences, questions to the reader.",
38
+ },
39
+ {
40
+ key: "colloquial",
41
+ name: "Colloquial",
42
+ definition: "as spoken among friends; slang, fragments, loose grammar.",
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ key: "humor",
48
+ limit: "ceiling",
49
+ name: "Humor",
50
+ about: null,
51
+ steps: [
52
+ {
53
+ key: "grave",
54
+ name: "Grave",
55
+ definition: "solemn and weighty; treats its subject with gravity, beyond having no jokes.",
56
+ },
57
+ { key: "earnest", name: "Earnest", definition: "sincere and straightforward; no jokes." },
58
+ {
59
+ key: "light",
60
+ name: "Light",
61
+ definition: "warm, with an occasional light touch; no set-up jokes.",
62
+ },
63
+ { key: "witty", name: "Witty", definition: "jokes, irony or playful exaggeration recur." },
64
+ {
65
+ key: "irreverent",
66
+ name: "Irreverent",
67
+ definition: "mocks conventions, the industry or itself; jokes over sincerity.",
68
+ },
69
+ ],
70
+ },
71
+ {
72
+ key: "claimStrength",
73
+ limit: "ceiling",
74
+ name: "Claim strength",
75
+ about:
76
+ "how strongly copy praises and promises, backed or not; calls to action count only when they push urgency",
77
+ steps: [
78
+ {
79
+ key: "understated",
80
+ name: "Understated",
81
+ definition: "states facts only; no praise words; qualifies claims.",
82
+ },
83
+ { key: "measured", name: "Measured", definition: "modest claims; praise words are rare." },
84
+ {
85
+ key: "confident",
86
+ name: "Confident",
87
+ definition: "states benefits plainly; few praise words, no superlatives.",
88
+ },
89
+ {
90
+ key: "assertive",
91
+ name: "Assertive",
92
+ definition: "praise words throughout; strong claims and comparisons.",
93
+ },
94
+ {
95
+ key: "bold",
96
+ name: "Bold",
97
+ definition: "superlatives, sweeping promises, urgency, exclamations.",
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ key: "expertise",
103
+ limit: "ceiling",
104
+ name: "Expertise",
105
+ about: "what the reader is assumed to know",
106
+ steps: [
107
+ { key: "plain", name: "Plain", definition: "everyday words only; no terms of the trade." },
108
+ {
109
+ key: "accessible",
110
+ name: "Accessible",
111
+ definition: "terms of the trade only when explained.",
112
+ },
113
+ { key: "informed", name: "Informed", definition: "common terms of the trade, unexplained." },
114
+ {
115
+ key: "technical",
116
+ name: "Technical",
117
+ definition: "precise terms, specifications and figures for practitioners.",
118
+ },
119
+ {
120
+ key: "specialist",
121
+ name: "Specialist",
122
+ definition: "dense jargon and references only experts follow.",
123
+ },
124
+ ],
125
+ },
126
+ {
127
+ key: "density",
128
+ limit: "ceiling",
129
+ name: "Density",
130
+ about: "words per idea, not page length",
131
+ steps: [
132
+ {
133
+ key: "telegraphic",
134
+ name: "Telegraphic",
135
+ definition: "fragments and lists; articles and transitions dropped where possible.",
136
+ },
137
+ {
138
+ key: "concise",
139
+ name: "Concise",
140
+ definition: "one idea per short sentence; nothing restated.",
141
+ },
142
+ {
143
+ key: "balanced",
144
+ name: "Balanced",
145
+ definition: "each idea gets the sentence it needs, with transitions.",
146
+ },
147
+ {
148
+ key: "descriptive",
149
+ name: "Descriptive",
150
+ definition: "ideas get detail, qualification and imagery.",
151
+ },
152
+ {
153
+ key: "expansive",
154
+ name: "Expansive",
155
+ definition: "ideas developed at length, with asides and restatement.",
156
+ },
157
+ ],
158
+ },
159
+ {
160
+ key: "distance",
161
+ limit: "band",
162
+ name: "Distance",
163
+ about: "who speaks, how close",
164
+ steps: [
165
+ {
166
+ key: "institutional",
167
+ name: "Institutional",
168
+ definition:
169
+ "the organization speaks of itself by name, in the third person, and doesn't address the reader.",
170
+ },
171
+ { key: "collective", name: "Collective", definition: '"we" speak about readers in general.' },
172
+ { key: "direct", name: "Direct", definition: '"we" speak to "you".' },
173
+ {
174
+ key: "personal",
175
+ name: "Personal",
176
+ definition: '"we" speak to "you" one to one, sharing opinions and feelings.',
177
+ },
178
+ { key: "solo", name: "Solo", definition: 'one person speaks as "I".' },
179
+ ],
180
+ },
181
+ ] as const;
182
+
183
+ /** One Voice Axis, with its steps in order. */
184
+ export type VoiceAxis = (typeof VOICE_AXES)[number];
185
+ export type VoiceAxisKey = VoiceAxis["key"];
186
+ /** A step of the axis `A`. */
187
+ export type VoiceStep<A extends VoiceAxisKey = VoiceAxisKey> = Extract<
188
+ VoiceAxis,
189
+ { key: A }
190
+ >["steps"][number];
191
+ /** The key of a step of the axis `A`. */
192
+ export type VoiceStepKey<A extends VoiceAxisKey = VoiceAxisKey> = VoiceStep<A>["key"];
193
+
194
+ /** A Voice: the chosen step on each axis. */
195
+ export type Voice = { [A in VoiceAxisKey]: VoiceStepKey<A> };
196
+
197
+ /** The Voice a new project starts with: no hype, no wordiness, no forced jokes. */
198
+ export const DEFAULT_VOICE: Voice = {
199
+ formality: "conversational",
200
+ humor: "earnest",
201
+ claimStrength: "confident",
202
+ expertise: "accessible",
203
+ density: "concise",
204
+ distance: "direct",
205
+ };
206
+
207
+ /** The axis with this key. */
208
+ export const voiceAxis = <A extends VoiceAxisKey>(key: A) =>
209
+ VOICE_AXES.find((axis) => axis.key === key) as Extract<VoiceAxis, { key: A }>;
210
+
211
+ /** Whether `key` names a step of the axis `axis`. */
212
+ export const isVoiceStep = <A extends VoiceAxisKey>(
213
+ axis: A,
214
+ key: string,
215
+ ): key is VoiceStepKey<A> => {
216
+ const steps: readonly VoiceStep[] = voiceAxis(axis).steps;
217
+ return steps.some((step) => step.key === key);
218
+ };
219
+
220
+ /** The step with this key on the axis `axis`. */
221
+ export const voiceStep = <A extends VoiceAxisKey>(axis: A, key: VoiceStepKey<A>) => {
222
+ const steps: readonly VoiceStep[] = voiceAxis(axis).steps;
223
+ return steps.find((step) => step.key === key) as VoiceStep<A>;
224
+ };
225
+
226
+ /** An axis a draft moves: from Live's step to the draft's. */
227
+ export type VoiceChange = {
228
+ [A in VoiceAxisKey]: { axis: A; before: VoiceStepKey<A>; after: VoiceStepKey<A> };
229
+ }[VoiceAxisKey];