@sonordev/contracts 2.15.0 → 2.17.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.
@@ -16,14 +16,7 @@
16
16
  * must carry, and which numbers may headline. The Sonor API applies the same
17
17
  * rules.
18
18
  */
19
- /** The message a cross-origin-framed site-kit page posts to its embedder once it has painted. */
20
- export declare const FRAME_READY_MESSAGE: 'sonor:frame-ready';
21
- export interface FrameReadyMessage {
22
- type: typeof FRAME_READY_MESSAGE;
23
- v: 1;
24
- }
25
- /** True for a {@link FrameReadyMessage}, for the embedder's message handler. */
26
- export declare function isFrameReadyMessage(data: unknown): data is FrameReadyMessage;
19
+ export { FRAME_READY_MESSAGE, isFrameReadyMessage, type FrameReadyMessage } from './frame-ready';
27
20
  /** Bump on breaking changes to the collapse policy. */
28
21
  export declare const PORTFOLIO_CONTRACT_VERSION: 1;
29
22
  /** The four beats, in reading order. */
@@ -57,7 +50,7 @@ export declare function stageName(names: CaseStudyStageNames | null | undefined,
57
50
  * sections of the story (SEO metadata, the closing CTA). This is THE list;
58
51
  * the Sonor API and agency-site-kit import it rather than keeping their own.
59
52
  */
60
- export declare const PORTFOLIO_SECTION_TYPES: readonly ['portfolioHero', 'portfolioChallenges', 'portfolioBeforeAfter', 'portfolioStrategy', 'portfolioSiteArchitecture', 'portfolioDesignSystem', 'portfolioFeatureSpotlight', 'portfolioGallery', 'portfolioVideo', 'portfolioTechStack', 'portfolioPerformance', 'portfolioSpeedComparison', 'portfolioResults', 'portfolioMetricsTimeline', 'portfolioConversionFunnel', 'portfolioServices', 'portfolioTeam', 'portfolioTestimonial', 'portfolioDetails', 'portfolioSeo', 'portfolioCTA'];
53
+ export declare const PORTFOLIO_SECTION_TYPES: readonly ['portfolioHero', 'portfolioChallenges', 'portfolioBeforeAfter', 'portfolioStrategy', 'portfolioSiteArchitecture', 'portfolioDesignSystem', 'portfolioFeatureSpotlight', 'portfolioGallery', 'portfolioVideo', 'portfolioTechStack', 'portfolioPerformance', 'portfolioSpeedComparison', 'portfolioVerification', 'portfolioResults', 'portfolioMetricsTimeline', 'portfolioConversionFunnel', 'portfolioServices', 'portfolioTeam', 'portfolioTestimonial', 'portfolioDetails', 'portfolioSeo', 'portfolioCTA'];
61
54
  export type PortfolioSectionType = (typeof PORTFOLIO_SECTION_TYPES)[number];
62
55
  export declare function isPortfolioSectionType(value: unknown): value is PortfolioSectionType;
63
56
  /**
@@ -70,20 +63,42 @@ export declare const SECTION_STAGE: Record<PortfolioSectionType, CaseStudyStage
70
63
  /** The stage a section type belongs to, or null when it sits outside the story. Unknown types are null. */
71
64
  export declare function sectionStage(type: string): CaseStudyStage | null;
72
65
  /**
73
- * The one section each stage can't do without. A stage with other sections
74
- * but not this one is told so by {@link caseStudyStageStatus}: a proof stage
75
- * that's only a speed comparison has no measurement of the finished build.
66
+ * The one section each stage can't do without, and the one an editor offers
67
+ * to add when the stage has nothing. A stage with other sections but not its
68
+ * core (or a stand-in, {@link STAGE_CORE_ALTERNATES}) is told so by
69
+ * {@link caseStudyStageStatus}: a proof stage that's only a speed comparison
70
+ * has no measurement of the finished build.
76
71
  */
77
72
  export declare const STAGE_CORE_SECTION: Record<CaseStudyStage, PortfolioSectionType>;
73
+ /**
74
+ * Sections that stand in for a stage's core. A Lighthouse run can only score
75
+ * what a browser can reach without signing in, so an app whose screens sit
76
+ * behind a login has no honest Performance section; its proof is a
77
+ * verification: checks that each say what they cover and what they don't.
78
+ * Either one completes the proof stage. This is deliberately not gated on
79
+ * the kind of project: the status below only sees section types, and the
80
+ * rule for "is this an app" lives with each caller's own data. A verification
81
+ * is a measurement of the finished build with its limits stated, which is
82
+ * what the stage asks for. Single source of truth for what completes a stage.
83
+ */
84
+ export declare const STAGE_CORE_ALTERNATES: Partial<Record<CaseStudyStage, readonly PortfolioSectionType[]>>;
85
+ /** Every section type that completes a stage: its core first, then its stand-ins. */
86
+ export declare function stageCoreSections(stage: CaseStudyStage): PortfolioSectionType[];
78
87
  /**
79
88
  * Canonical display order, derived from the list above so it can't disagree
80
89
  * with the stages. Renderers sort by this when nobody has reordered; the
81
90
  * dashboard's stored order only ever moves a section within its stage.
82
91
  */
83
92
  export declare const PORTFOLIO_SECTION_ORDER: Record<PortfolioSectionType, number>;
84
- /** The least a section needs for the ordering helpers: its type. Anything else rides along. */
93
+ /**
94
+ * The least a section needs for the ordering helpers: its type. Anything else
95
+ * rides along. `data` is optional for them and needed by
96
+ * {@link caseStudyStageStatus}, which won't count a stand-in section for a
97
+ * stage's core (a verification) unless its data shows something.
98
+ */
85
99
  export interface SectionLike {
86
100
  sectionType: string;
101
+ data?: unknown;
87
102
  }
88
103
  /**
89
104
  * The sections in the order the case study reads.
@@ -120,7 +135,11 @@ export interface CaseStudyStageStatus {
120
135
  stage: CaseStudyStage;
121
136
  /** The section types present, in reading order. */
122
137
  present: PortfolioSectionType[];
123
- /** True when the stage's core section ({@link STAGE_CORE_SECTION}) is present. */
138
+ /**
139
+ * True when the stage's core section ({@link STAGE_CORE_SECTION}) is present, or a stand-in for it
140
+ * ({@link STAGE_CORE_ALTERNATES}) is present with something a page can show. Pass each section's `data`:
141
+ * a stand-in without it doesn't count.
142
+ */
124
143
  complete: boolean;
125
144
  /** Null when complete; otherwise one sentence on what the stage is missing. */
126
145
  missing: string | null;
@@ -129,6 +148,10 @@ export interface CaseStudyStageStatus {
129
148
  * Each stage's status, all four, in order, whether or not the case study has
130
149
  * sections in it. The dashboard shows these beside the editor so an empty
131
150
  * proof stage is seen before the case study is published, not after.
151
+ *
152
+ * A stage's core section completes it by type. A stand-in for the core (a
153
+ * verification) completes it only when its `data` holds something a page can
154
+ * show, so pass `data`; without it a stand-in reads as empty, never as done.
132
155
  */
133
156
  export declare function caseStudyStageStatus(sections: readonly SectionLike[] | null | undefined): CaseStudyStageStatus[];
134
157
  export interface CaseStudyNarrative {
@@ -196,6 +219,166 @@ export declare function caseStudyFlowProblems(input: {
196
219
  phases?: readonly PhaseLike[] | null;
197
220
  results?: readonly ResultLike[] | null;
198
221
  }): string[];
222
+ /**
223
+ * True for a real calendar day written YYYY-MM-DD. "2026-02-31" is not (Date.parse
224
+ * rolls it into March), and neither is a year under 100 (Date.UTC maps those into
225
+ * the 1900s). Single source of truth for what counts as a day.
226
+ */
227
+ export declare function isRealDay(value: string): boolean;
228
+ /** The most checks one verification lists. It's a short list; the case study isn't an audit report. */
229
+ export declare const VERIFICATION_MAX_CHECKS = 8;
230
+ /** Every field of a check, in the order a renderer reads them. */
231
+ export declare const VERIFICATION_CHECK_FIELDS: readonly ['label', 'result', 'measured', 'where', 'method', 'date', 'scope'];
232
+ export type VerificationCheckField = (typeof VERIFICATION_CHECK_FIELDS)[number];
233
+ /** The longest each text field may run. Each is a line, not a paragraph. `date` is a day, not text. */
234
+ export declare const VERIFICATION_FIELD_MAX_CHARS: {
235
+ readonly label: 80;
236
+ readonly result: 120;
237
+ readonly measured: 200;
238
+ readonly where: 200;
239
+ readonly method: 240;
240
+ readonly scope: 240;
241
+ };
242
+ /** One thing we checked on the finished build. Every field is required. */
243
+ export interface VerificationCheck {
244
+ /** What the check is called: "Sign-in page, mobile speed". */
245
+ label: string;
246
+ /** What came out: "Performance 89", "42 of 42 tables have row-level security". */
247
+ result: string;
248
+ /** What was measured: "Lighthouse performance score of the page a visitor sees before signing in". */
249
+ measured: string;
250
+ /** Where: a URL, or the screen or file. "https://example.com/login", "the migrations in the repository". */
251
+ where: string;
252
+ /** The tool and settings: "Lighthouse 13, mobile preset, median of 3 runs". */
253
+ method: string;
254
+ /** The day it was checked, YYYY-MM-DD. */
255
+ date: string;
256
+ /** What the check does NOT cover, as a limit: "The sign-in page only; the screens behind it weren't measured." */
257
+ scope: string;
258
+ }
259
+ /** The `data` of a `portfolioVerification` section. */
260
+ export interface PortfolioVerificationData {
261
+ checks: VerificationCheck[];
262
+ }
263
+ /** The earliest day a check may carry. An earlier date is a typo, not a check of this build. */
264
+ export declare const VERIFICATION_EARLIEST_DAY = "2000-01-01";
265
+ /**
266
+ * The latest day a check may carry: tomorrow in UTC. A check run today anywhere
267
+ * on earth is dated no later than that (the furthest-ahead zone is UTC+14), so a
268
+ * server's clock can't drop a check dated "today" where the person ran it, and a
269
+ * date further out is a check that hasn't happened. Single source of truth for
270
+ * the allowance: writers and readers both use it, so no one keeps a second one.
271
+ * `now` is for tests and for callers with a clock of their own.
272
+ */
273
+ export declare function latestVerificationDay(now?: Date): string;
274
+ export interface VerificationOptions {
275
+ /**
276
+ * The latest day a check may carry, YYYY-MM-DD; a later one is a problem. Leave it out to use
277
+ * {@link latestVerificationDay}, which is what a page and a write path both want. Pass one for a fixed clock.
278
+ */
279
+ latestDay?: string;
280
+ }
281
+ /**
282
+ * True when a line says nothing: it has no words, or every word is a
283
+ * placeholder or filler ("N/A", "n/a n/a", "TBD", "see above", "none at all").
284
+ */
285
+ export declare function isPlaceholderText(text: string): boolean;
286
+ /**
287
+ * True when a scope line doesn't state a limit. A scope is "what this check
288
+ * does NOT cover", so it has to be a sentence that uses a word marking where
289
+ * coverage stops ("only", "not", "except", "without", "n't") and says
290
+ * something beyond that word. A coverage claim ("All screens", "Fully
291
+ * tested"), a placeholder ("N/A", "None at all", "Not applicable") and a
292
+ * denied limit ("No restrictions", "Nothing excluded") fail. "Desktop only",
293
+ * "Counted, not exercised" and "No queries ran as a signed-in user" pass.
294
+ *
295
+ * It reads English. It can't judge whether a limit is true or useful, only
296
+ * that one was written; a person still reads the scope.
297
+ */
298
+ export declare function isVacuousScope(scope: string): boolean;
299
+ /**
300
+ * What's wrong with a verification section's data, or an empty list. The
301
+ * section needs between one and {@link VERIFICATION_MAX_CHECKS} checks, and
302
+ * every field of every check is required, the scope most of all. Whatever
303
+ * stores a verification should run this first. The contract can't make it:
304
+ * until a write path calls it, stored data can hold anything, and
305
+ * {@link readVerificationChecks} is what keeps a bad check off the page.
306
+ */
307
+ export declare function verificationProblems(data: unknown, options?: VerificationOptions): string[];
308
+ /**
309
+ * The checks a renderer may show: the ones with every field present, within
310
+ * the limits, with a real day and a scope that states a limit, trimmed, in their
311
+ * stored order and no more than {@link VERIFICATION_MAX_CHECKS}. A check that
312
+ * fails is left out, so one with no scope line (or a placeholder for one) never
313
+ * prints. That's all it can promise: whether a scope is true is a person's call.
314
+ * Empty when the data is anything else. Single source of truth for what a case
315
+ * study prints from this section.
316
+ */
317
+ export declare function readVerificationChecks(data: unknown, options?: VerificationOptions): VerificationCheck[];
318
+ /**
319
+ * The link for a check's `where`: the address when it is exactly one http or
320
+ * https URL with no credentials in it and a public host, else null. A screen
321
+ * name or a file path is printed as text; nothing else is ever made into a link.
322
+ */
323
+ export declare function verificationLink(where: string): string | null;
324
+ /** Agent-native contract: JSON Schema for {@link PortfolioVerificationData}. What a scope or a where says, and whether a date is a real day in range, are checked by {@link verificationProblems}. */
325
+ export declare const PORTFOLIO_VERIFICATION_JSON_SCHEMA: {
326
+ readonly $schema: 'http://json-schema.org/draft-07/schema#';
327
+ readonly $id: 'https://sonor.io/schemas/portfolio-verification.v1.json';
328
+ readonly title: 'PortfolioVerificationData';
329
+ readonly description: 'A short list of checks on the finished build. Each says what was checked, where, how, when, what came out, and what it does not cover.';
330
+ readonly type: 'object';
331
+ readonly required: readonly ['checks'];
332
+ readonly properties: {
333
+ readonly checks: {
334
+ readonly type: 'array';
335
+ readonly minItems: 1;
336
+ readonly maxItems: 8;
337
+ readonly items: {
338
+ readonly type: 'object';
339
+ readonly required: readonly ["label", "result", "measured", "where", "method", "date", "scope"];
340
+ readonly properties: {
341
+ readonly label: {
342
+ readonly type: 'string';
343
+ readonly minLength: 1;
344
+ readonly maxLength: 80;
345
+ };
346
+ readonly result: {
347
+ readonly type: 'string';
348
+ readonly minLength: 1;
349
+ readonly maxLength: 120;
350
+ };
351
+ readonly measured: {
352
+ readonly type: 'string';
353
+ readonly minLength: 1;
354
+ readonly maxLength: 200;
355
+ };
356
+ readonly where: {
357
+ readonly type: 'string';
358
+ readonly minLength: 1;
359
+ readonly maxLength: 200;
360
+ };
361
+ readonly method: {
362
+ readonly type: 'string';
363
+ readonly minLength: 1;
364
+ readonly maxLength: 240;
365
+ };
366
+ readonly date: {
367
+ readonly type: 'string';
368
+ readonly pattern: '^\\d{4}-\\d{2}-\\d{2}$';
369
+ };
370
+ readonly scope: {
371
+ readonly type: 'string';
372
+ readonly minLength: 1;
373
+ readonly maxLength: 240;
374
+ };
375
+ };
376
+ readonly additionalProperties: false;
377
+ };
378
+ };
379
+ };
380
+ readonly additionalProperties: false;
381
+ };
199
382
  /** Minimal KPI shape the policy reads — callers pass their own richer tiles. */
200
383
  export interface KpiLike {
201
384
  label: string;