@clossys/writer 0.3.9 → 0.5.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/README.md +647 -6
- package/dist/addressability.d.ts +11 -1
- package/dist/addressability.d.ts.map +1 -1
- package/dist/addressability.js +169 -3
- package/dist/addressability.js.map +1 -1
- package/dist/approval-bypass.d.ts +120 -0
- package/dist/approval-bypass.d.ts.map +1 -0
- package/dist/approval-bypass.js +2318 -0
- package/dist/approval-bypass.js.map +1 -0
- package/dist/approval.d.ts +62 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +421 -0
- package/dist/approval.js.map +1 -0
- package/dist/approve-cli.d.ts +82 -0
- package/dist/approve-cli.d.ts.map +1 -0
- package/dist/approve-cli.js +430 -0
- package/dist/approve-cli.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +264 -22
- package/dist/cli.js.map +1 -1
- package/dist/field-options.d.ts +59 -0
- package/dist/field-options.d.ts.map +1 -0
- package/dist/field-options.js +109 -0
- package/dist/field-options.js.map +1 -0
- package/dist/fold-wallpaper-gate.d.ts +7 -0
- package/dist/fold-wallpaper-gate.d.ts.map +1 -0
- package/dist/fold-wallpaper-gate.js +29 -0
- package/dist/fold-wallpaper-gate.js.map +1 -0
- package/dist/front-door.check.d.ts +2 -0
- package/dist/front-door.check.d.ts.map +1 -0
- package/dist/front-door.check.js +8 -0
- package/dist/front-door.check.js.map +1 -0
- package/dist/front-door.d.ts +82 -0
- package/dist/front-door.d.ts.map +1 -0
- package/dist/front-door.js +271 -0
- package/dist/front-door.js.map +1 -0
- package/dist/generated/advisor-plan-contract.generated.d.ts +3 -0
- package/dist/generated/advisor-plan-contract.generated.d.ts.map +1 -0
- package/dist/generated/advisor-plan-contract.generated.js +430 -0
- package/dist/generated/advisor-plan-contract.generated.js.map +1 -0
- package/dist/generated/contract-schema.generated.d.ts +97 -0
- package/dist/generated/contract-schema.generated.d.ts.map +1 -0
- package/dist/generated/contract-schema.generated.js +496 -0
- package/dist/generated/contract-schema.generated.js.map +1 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/live-copy-gate.d.ts +16 -0
- package/dist/live-copy-gate.d.ts.map +1 -0
- package/dist/live-copy-gate.js +135 -0
- package/dist/live-copy-gate.js.map +1 -0
- package/dist/messaging-kit.d.ts +113 -0
- package/dist/messaging-kit.d.ts.map +1 -0
- package/dist/messaging-kit.js +121 -0
- package/dist/messaging-kit.js.map +1 -0
- package/dist/passage.d.ts +2 -1
- package/dist/passage.d.ts.map +1 -1
- package/dist/passage.js +2 -1
- package/dist/passage.js.map +1 -1
- package/dist/plan-authority.d.ts +73 -0
- package/dist/plan-authority.d.ts.map +1 -0
- package/dist/plan-authority.js +126 -0
- package/dist/plan-authority.js.map +1 -0
- package/dist/plan-contract.d.ts +16 -0
- package/dist/plan-contract.d.ts.map +1 -0
- package/dist/plan-contract.js +33 -0
- package/dist/plan-contract.js.map +1 -0
- package/dist/plan-digest.d.ts +23 -0
- package/dist/plan-digest.d.ts.map +1 -0
- package/dist/plan-digest.js +82 -0
- package/dist/plan-digest.js.map +1 -0
- package/dist/plan-rules.d.ts +54 -0
- package/dist/plan-rules.d.ts.map +1 -0
- package/dist/plan-rules.js +145 -0
- package/dist/plan-rules.js.map +1 -0
- package/dist/render-registry-parity.d.ts +20 -0
- package/dist/render-registry-parity.d.ts.map +1 -0
- package/dist/render-registry-parity.js +45 -0
- package/dist/render-registry-parity.js.map +1 -0
- package/dist/resolve.d.ts +40 -6
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +144 -18
- package/dist/resolve.js.map +1 -1
- package/dist/scan.d.ts +32 -0
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +67 -6
- package/dist/scan.js.map +1 -1
- package/dist/schema.d.ts +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +231 -5
- package/dist/schema.js.map +1 -1
- package/dist/site-identity.d.ts +88 -0
- package/dist/site-identity.d.ts.map +1 -0
- package/dist/site-identity.js +82 -0
- package/dist/site-identity.js.map +1 -0
- package/dist/treatment-word-budget.d.ts +31 -0
- package/dist/treatment-word-budget.d.ts.map +1 -0
- package/dist/treatment-word-budget.js +80 -0
- package/dist/treatment-word-budget.js.map +1 -0
- package/dist/types.d.ts +76 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +9 -7
- package/dist/types.js.map +1 -1
- package/fit-signals.json +11 -0
- package/package.json +201 -11
- package/skill/SKILL.md +49 -0
- package/src/addressability.ts +186 -4
- package/src/approval-bypass.ts +2263 -0
- package/src/approval.ts +491 -0
- package/src/approve-cli.ts +474 -0
- package/src/cli.ts +274 -22
- package/src/field-options.ts +134 -0
- package/src/fold-wallpaper-gate.ts +29 -0
- package/src/front-door.check.ts +10 -0
- package/src/front-door.ts +312 -0
- package/src/generated/advisor-plan-contract.generated.ts +430 -0
- package/src/generated/contract-schema.generated.ts +520 -0
- package/src/index.ts +107 -1
- package/src/live-copy-gate.ts +150 -0
- package/src/messaging-kit.ts +195 -0
- package/src/passage.ts +2 -1
- package/src/plan-authority.ts +160 -0
- package/src/plan-contract.ts +45 -0
- package/src/plan-digest.ts +81 -0
- package/src/plan-rules.ts +179 -0
- package/src/render-registry-parity.ts +65 -0
- package/src/resolve.ts +185 -19
- package/src/scan.ts +97 -6
- package/src/schema.ts +247 -5
- package/src/site-identity.ts +125 -0
- package/src/treatment-word-budget.ts +100 -0
- package/src/types.ts +83 -7
- package/templates/front-door.en.json +426 -0
- package/CHANGELOG.md +0 -330
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The site-identity copy kind: a site's name and tagline, resolved from a
|
|
3
|
+
* `CopyRegistry` under two reserved entry ids.
|
|
4
|
+
*
|
|
5
|
+
* A page-metadata consumer needs exactly two short strings — what the site
|
|
6
|
+
* is called and one line about it — and needs them to carry the same
|
|
7
|
+
* approval evidence as any other rendered copy. This module does not add a
|
|
8
|
+
* second approval path for them. It asks `resolveCopyRef` for
|
|
9
|
+
* `"site.name"` and `"site.tagline"`, so whatever that resolver refuses
|
|
10
|
+
* (a draft entry, an approval record that no longer matches its text, an
|
|
11
|
+
* expired delegate approval, a delegate approval on `"production"` without
|
|
12
|
+
* the caller's opt-in, a locale mismatch, an unknown id, an invalid
|
|
13
|
+
* registry or options object) is refused here for the same reason.
|
|
14
|
+
*
|
|
15
|
+
* On top of that resolver this module adds two refusals of its own,
|
|
16
|
+
* because a name and a tagline are literal text rather than templates: an
|
|
17
|
+
* entry that declares placeholders (or whose text the resolver would
|
|
18
|
+
* rewrite), and a resolved text that is blank after trimming.
|
|
19
|
+
*
|
|
20
|
+
* The result is all-or-nothing. Both fields are always attempted so a
|
|
21
|
+
* caller sees every problem at once, but `identity` and `resolutions` are
|
|
22
|
+
* present only when both fields resolved — there is no partial identity.
|
|
23
|
+
* Nothing here throws for any input; malformed input yields a result with
|
|
24
|
+
* `complete: false` and an issue. Nothing here reads a brand-facts record
|
|
25
|
+
* or consumes the result; wiring it into a page-metadata builder is a
|
|
26
|
+
* separate change.
|
|
27
|
+
*
|
|
28
|
+
* No real copy ships here. The ids are reserved names; the words are the
|
|
29
|
+
* consumer's own.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { prepareOptions, resolveField } from "./field-options.js";
|
|
33
|
+
import type { FieldLabels } from "./field-options.js";
|
|
34
|
+
import type { CopyResolveIssue, CopyResolveIssueReason, CopyResolveOptions } from "./resolve.js";
|
|
35
|
+
import type { CopyRegistry, CopyResolution } from "./types.js";
|
|
36
|
+
|
|
37
|
+
/** Reserved copy id for the site's name. */
|
|
38
|
+
export const SITE_NAME_COPY_ID = "site.name";
|
|
39
|
+
|
|
40
|
+
/** Reserved copy id for the site's tagline. */
|
|
41
|
+
export const SITE_TAGLINE_COPY_ID = "site.tagline";
|
|
42
|
+
|
|
43
|
+
/** Both reserved site-identity copy ids, name first. */
|
|
44
|
+
export const SITE_IDENTITY_COPY_IDS = [SITE_NAME_COPY_ID, SITE_TAGLINE_COPY_ID] as const;
|
|
45
|
+
|
|
46
|
+
/** Which half of the site identity an issue is about. */
|
|
47
|
+
export type SiteIdentityField = "name" | "tagline";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Every reason `resolveSiteIdentity` can report: whatever `resolveCopyRef`
|
|
51
|
+
* refuses, plus the two refusals specific to site identity.
|
|
52
|
+
* `"site-identity-blank"` means the resolved text was empty after trimming;
|
|
53
|
+
* `"site-identity-placeholder"` means the entry declares placeholders or
|
|
54
|
+
* its text is one the resolver would rewrite.
|
|
55
|
+
*/
|
|
56
|
+
export type SiteIdentityIssueReason = CopyResolveIssueReason | "site-identity-blank" | "site-identity-placeholder";
|
|
57
|
+
|
|
58
|
+
/** One reason a site identity could not be resolved, tagged with its field. */
|
|
59
|
+
export interface SiteIdentityIssue extends Omit<CopyResolveIssue, "reason"> {
|
|
60
|
+
reason: SiteIdentityIssueReason;
|
|
61
|
+
field: SiteIdentityField;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The outcome of `resolveSiteIdentity`. `identity` and `resolutions` are
|
|
66
|
+
* present only when `complete` is `true`; `issues` is empty exactly then.
|
|
67
|
+
*/
|
|
68
|
+
export interface SiteIdentityResolution {
|
|
69
|
+
complete: boolean;
|
|
70
|
+
identity?: { name: string; tagline: string };
|
|
71
|
+
resolutions?: { name: CopyResolution; tagline: CopyResolution };
|
|
72
|
+
issues: SiteIdentityIssue[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** `CopyResolveOptions` plus the requested locale, which is a ref field for the underlying resolver. */
|
|
76
|
+
export type SiteIdentityOptions = CopyResolveOptions & { locale?: string };
|
|
77
|
+
|
|
78
|
+
const FIELDS: readonly { field: SiteIdentityField; id: string }[] = [
|
|
79
|
+
{ field: "name", id: SITE_NAME_COPY_ID },
|
|
80
|
+
{ field: "tagline", id: SITE_TAGLINE_COPY_ID },
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const LABELS: FieldLabels<"site-identity-placeholder" | "site-identity-blank"> = {
|
|
84
|
+
optionsSubject: "Site identity",
|
|
85
|
+
entrySubject: (id) => `Site identity "${id}"`,
|
|
86
|
+
placeholderReason: "site-identity-placeholder",
|
|
87
|
+
blankReason: "site-identity-blank",
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Resolves the site's name and tagline from `registry`, under
|
|
92
|
+
* `"site.name"` and `"site.tagline"`. Both are attempted on every call and
|
|
93
|
+
* every issue is reported, tagged with its `field`; `identity` and
|
|
94
|
+
* `resolutions` are returned only when both resolved.
|
|
95
|
+
*
|
|
96
|
+
* `options` are `resolveCopyRef`'s (`target`, `acceptDelegateInProduction`,
|
|
97
|
+
* `now`) plus an optional `locale`, which is forwarded as the ref's locale
|
|
98
|
+
* rather than as an option. Malformed options (including a blank or
|
|
99
|
+
* non-string `locale`) produce an `"invalid-options"` issue per field. Pure
|
|
100
|
+
* apart from the clock read that `now` defaults to; the registry is not
|
|
101
|
+
* modified and no input makes this throw.
|
|
102
|
+
*/
|
|
103
|
+
export function resolveSiteIdentity(
|
|
104
|
+
registry: CopyRegistry | unknown,
|
|
105
|
+
options?: SiteIdentityOptions | unknown,
|
|
106
|
+
): SiteIdentityResolution {
|
|
107
|
+
const prepared = prepareOptions(options);
|
|
108
|
+
const issues: SiteIdentityIssue[] = [];
|
|
109
|
+
const resolved: Partial<Record<SiteIdentityField, CopyResolution>> = {};
|
|
110
|
+
for (const { field, id } of FIELDS) {
|
|
111
|
+
const outcome = resolveField(registry, field, id, prepared, LABELS);
|
|
112
|
+
issues.push(...outcome.issues);
|
|
113
|
+
if (outcome.resolution) resolved[field] = outcome.resolution;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const name = resolved.name;
|
|
117
|
+
const tagline = resolved.tagline;
|
|
118
|
+
if (issues.length > 0 || !name || !tagline) return { complete: false, issues };
|
|
119
|
+
return {
|
|
120
|
+
complete: true,
|
|
121
|
+
identity: { name: name.text, tagline: tagline.text },
|
|
122
|
+
resolutions: { name, tagline },
|
|
123
|
+
issues: [],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Treatment-level word budgets for registry entries — display headings,
|
|
3
|
+
* eyebrows, button labels, and other short treatments that are not body
|
|
4
|
+
* measure. Pure gate: takes an already-validated `CopyRegistry`, never I/O.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { CopyEntryId, CopyRegistry, CopyRegistryEntry } from "./types.js";
|
|
8
|
+
|
|
9
|
+
/** Known slot treatments with a default maximum word count when the entry omits `maxWords`. */
|
|
10
|
+
export const DEFAULT_TREATMENT_WORD_BUDGETS: Readonly<Record<string, number>> = {
|
|
11
|
+
"display-heading": 12,
|
|
12
|
+
eyebrow: 8,
|
|
13
|
+
button: 6,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type TreatmentWordBudgetRule = "word-budget-exceeded" | "unknown-treatment";
|
|
17
|
+
|
|
18
|
+
export interface TreatmentWordBudgetFinding {
|
|
19
|
+
rule: TreatmentWordBudgetRule;
|
|
20
|
+
severity: "error";
|
|
21
|
+
entryId: CopyEntryId;
|
|
22
|
+
treatment: string;
|
|
23
|
+
maxWords: number;
|
|
24
|
+
actualWords: number;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TreatmentWordBudgetResult {
|
|
29
|
+
entriesChecked: number;
|
|
30
|
+
findings: TreatmentWordBudgetFinding[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Counts words in resolved copy text (whitespace-separated tokens). */
|
|
34
|
+
export function countCopyWords(text: string): number {
|
|
35
|
+
const trimmed = text.trim();
|
|
36
|
+
if (trimmed.length === 0) return 0;
|
|
37
|
+
return trimmed.split(/\s+/u).length;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function budgetForEntry(entry: CopyRegistryEntry): { treatment: string; maxWords: number } | undefined {
|
|
41
|
+
const treatment = entry.treatment;
|
|
42
|
+
if (typeof treatment !== "string" || treatment.trim().length === 0) return undefined;
|
|
43
|
+
const normalized = treatment.trim();
|
|
44
|
+
if (entry.maxWords !== undefined) {
|
|
45
|
+
if (typeof entry.maxWords !== "number" || !Number.isFinite(entry.maxWords) || entry.maxWords < 1) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return { treatment: normalized, maxWords: Math.floor(entry.maxWords) };
|
|
49
|
+
}
|
|
50
|
+
const defaultMax = DEFAULT_TREATMENT_WORD_BUDGETS[normalized];
|
|
51
|
+
if (defaultMax === undefined) return undefined;
|
|
52
|
+
return { treatment: normalized, maxWords: defaultMax };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Fails when an approved entry declares a `treatment` (or `maxWords`) and
|
|
57
|
+
* its `text` exceeds the applicable budget. Draft and retired entries are
|
|
58
|
+
* skipped — only copy that can resolve at render is measured.
|
|
59
|
+
*/
|
|
60
|
+
export function checkTreatmentWordBudgets(registry: CopyRegistry): TreatmentWordBudgetResult {
|
|
61
|
+
const findings: TreatmentWordBudgetFinding[] = [];
|
|
62
|
+
let entriesChecked = 0;
|
|
63
|
+
|
|
64
|
+
for (const entry of registry.entries) {
|
|
65
|
+
if (entry.status !== "approved") continue;
|
|
66
|
+
const budget = budgetForEntry(entry);
|
|
67
|
+
if (!budget) {
|
|
68
|
+
if (typeof entry.treatment === "string" && entry.treatment.trim().length > 0) {
|
|
69
|
+
const normalized = entry.treatment.trim();
|
|
70
|
+
if (entry.maxWords === undefined && DEFAULT_TREATMENT_WORD_BUDGETS[normalized] === undefined) {
|
|
71
|
+
findings.push({
|
|
72
|
+
rule: "unknown-treatment",
|
|
73
|
+
severity: "error",
|
|
74
|
+
entryId: entry.id,
|
|
75
|
+
treatment: normalized,
|
|
76
|
+
maxWords: 0,
|
|
77
|
+
actualWords: countCopyWords(entry.text),
|
|
78
|
+
message: `Entry "${entry.id}" declares treatment "${normalized}" with no maxWords and no built-in default — add maxWords or use a known treatment (${Object.keys(DEFAULT_TREATMENT_WORD_BUDGETS).join(", ")}).`,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
entriesChecked++;
|
|
85
|
+
const actualWords = countCopyWords(entry.text);
|
|
86
|
+
if (actualWords > budget.maxWords) {
|
|
87
|
+
findings.push({
|
|
88
|
+
rule: "word-budget-exceeded",
|
|
89
|
+
severity: "error",
|
|
90
|
+
entryId: entry.id,
|
|
91
|
+
treatment: budget.treatment,
|
|
92
|
+
maxWords: budget.maxWords,
|
|
93
|
+
actualWords,
|
|
94
|
+
message: `Entry "${entry.id}" (${budget.treatment}) has ${actualWords} word(s) but the budget is ${budget.maxWords}.`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return { entriesChecked, findings };
|
|
100
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -28,13 +28,15 @@
|
|
|
28
28
|
* This file ships no example content of anyone's real copy. Every field
|
|
29
29
|
* here is either required-and-generic or a structural placeholder —
|
|
30
30
|
* filling in an actual product's actual sentences is a consumer's job.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
31
|
+
* The one exemption is the shipped US English front-door defaults
|
|
32
|
+
* (`front-door.ts`, `FRONT_DOOR_COPY_EN`, and the README's "Front-door
|
|
33
|
+
* copy" section): a closed, reserved set of ids, owned by this package, whose
|
|
34
|
+
* words ship as data so every sign-in surface need not carry its own. Outside
|
|
35
|
+
* that set this package is to `@clossys/writer/voice` what `@example/ui` is
|
|
36
|
+
* to `@example/ui/tokens` — a vocabulary layer over a contract layer, never a
|
|
37
|
+
* source of real words. If a doc comment, a test fixture, or a README example
|
|
38
|
+
* outside the front-door set ever reads like something a product would
|
|
39
|
+
* actually show a user, that is a bug in this package, not a feature of it.
|
|
38
40
|
*/
|
|
39
41
|
|
|
40
42
|
// ---------------------------------------------------------------------------
|
|
@@ -166,6 +168,17 @@ export interface CopyEntry {
|
|
|
166
168
|
* same seam, one layer over).
|
|
167
169
|
*/
|
|
168
170
|
factRef?: string;
|
|
171
|
+
/**
|
|
172
|
+
* Named slot treatment for word-budget governance — e.g. `display-heading`,
|
|
173
|
+
* `eyebrow`, `button`. When set on an approved registry entry, `writer-check`
|
|
174
|
+
* applies `maxWords` or the built-in default for that treatment.
|
|
175
|
+
*/
|
|
176
|
+
treatment?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Maximum word count for this entry's `text` when `treatment` is set.
|
|
179
|
+
* Overrides the built-in default table when present.
|
|
180
|
+
*/
|
|
181
|
+
maxWords?: number;
|
|
169
182
|
}
|
|
170
183
|
|
|
171
184
|
/**
|
|
@@ -211,6 +224,47 @@ export interface CopyTranslationProvenance {
|
|
|
211
224
|
reviewedBy?: string;
|
|
212
225
|
}
|
|
213
226
|
|
|
227
|
+
// ---------------------------------------------------------------------------
|
|
228
|
+
// CopyApproval — who approved an entry, and exactly which text they approved
|
|
229
|
+
// ---------------------------------------------------------------------------
|
|
230
|
+
|
|
231
|
+
/** Who recorded an approval: the copy owner, or a delegate acting for them. */
|
|
232
|
+
export type CopyApprover = "owner" | "delegate";
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The delegate an approval was recorded by, and the entry-id namespaces they
|
|
236
|
+
* may approve. `id` is an opaque identifier, never a personal name. Each
|
|
237
|
+
* `scope` item is a dot-separated namespace with no wildcard; an entry is in
|
|
238
|
+
* scope when its id equals an item or starts with `item + "."`.
|
|
239
|
+
*/
|
|
240
|
+
export interface CopyDelegateScope {
|
|
241
|
+
id: string;
|
|
242
|
+
scope: string[];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The recorded approval of one registry entry, written by
|
|
247
|
+
* `writer-check approve` rather than by hand. `textFingerprint` pins the
|
|
248
|
+
* approval to the exact text that was approved: once `text` changes, the
|
|
249
|
+
* record no longer matches and the resolver refuses the entry
|
|
250
|
+
* (`approval-stale`) until it is approved again.
|
|
251
|
+
*/
|
|
252
|
+
export interface CopyApproval {
|
|
253
|
+
approvedBy: CopyApprover;
|
|
254
|
+
/** ISO 8601 UTC timestamp of the approval. */
|
|
255
|
+
approvedAt: string;
|
|
256
|
+
/** `computeCopyFingerprint(entry.text)` at the moment of approval. */
|
|
257
|
+
textFingerprint: string;
|
|
258
|
+
/** The algorithm `textFingerprint` was computed with — `COPY_FINGERPRINT_ALGORITHM`. */
|
|
259
|
+
fingerprintAlgorithm: string;
|
|
260
|
+
/** Required when `approvedBy` is `"delegate"`; forbidden for `"owner"`. */
|
|
261
|
+
delegate?: CopyDelegateScope;
|
|
262
|
+
/** Required when `approvedBy` is `"delegate"`; forbidden for `"owner"`. */
|
|
263
|
+
pendingOwnerReview?: boolean;
|
|
264
|
+
/** Delegate records only: ISO 8601 UTC expiry, strictly after `approvedAt`. */
|
|
265
|
+
expiresAt?: string;
|
|
266
|
+
}
|
|
267
|
+
|
|
214
268
|
/** A `CopyEntry` that is eligible to participate in a rendered registry. */
|
|
215
269
|
export interface CopyRegistryEntry extends CopyEntry {
|
|
216
270
|
status: CopyEntryStatus;
|
|
@@ -227,6 +281,12 @@ export interface CopyRegistryEntry extends CopyEntry {
|
|
|
227
281
|
* never collapsed into one signal.
|
|
228
282
|
*/
|
|
229
283
|
translation?: CopyTranslationProvenance;
|
|
284
|
+
/**
|
|
285
|
+
* The approval record, present only on an `approved` entry that has one.
|
|
286
|
+
* Optional: an `approved` entry without a record keeps resolving exactly
|
|
287
|
+
* as it did before this field existed. See `CopyApproval`.
|
|
288
|
+
*/
|
|
289
|
+
approval?: CopyApproval;
|
|
230
290
|
}
|
|
231
291
|
|
|
232
292
|
// ---------------------------------------------------------------------------
|
|
@@ -257,6 +317,20 @@ export interface CopyRegistry extends CopyRecord {
|
|
|
257
317
|
entries: CopyRegistryEntry[];
|
|
258
318
|
}
|
|
259
319
|
|
|
320
|
+
/** The approval facts a resolution carries (`CopyResolution.approval`). */
|
|
321
|
+
export type CopyResolutionApproval =
|
|
322
|
+
| { approvedBy: "owner"; pendingOwnerReview: false }
|
|
323
|
+
| {
|
|
324
|
+
approvedBy: "delegate";
|
|
325
|
+
pendingOwnerReview: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Present only when this delegate-approved entry resolved on "production"
|
|
328
|
+
* because the `approvalPlan` authorized it: that plan's canonical digest.
|
|
329
|
+
* Absent when `acceptDelegateInProduction` authorized it, and on "preview".
|
|
330
|
+
*/
|
|
331
|
+
authorizingPlanDigest?: string;
|
|
332
|
+
};
|
|
333
|
+
|
|
260
334
|
/** A successful, fully traced resolution of one copy reference. */
|
|
261
335
|
export interface CopyResolution {
|
|
262
336
|
ref: CopyRef;
|
|
@@ -266,6 +340,8 @@ export interface CopyResolution {
|
|
|
266
340
|
locale: CopyLocale;
|
|
267
341
|
source: CopySource;
|
|
268
342
|
entryId: CopyEntryId;
|
|
343
|
+
/** Present only when the resolved entry carries an approval record. */
|
|
344
|
+
approval?: CopyResolutionApproval;
|
|
269
345
|
}
|
|
270
346
|
|
|
271
347
|
/** Resolver shape for callers that need rendered audience text. */
|