@contentstack/studio-message-types 2.1.0 → 2.2.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.
@@ -141,6 +141,13 @@ export interface RevealResultPayload {
141
141
  /** Absent when the requested node was the one revealed. */
142
142
  miss: RevealMissKind | null;
143
143
  }
144
+ /**
145
+ * The author pressed undo or redo while focus was inside the canvas. Key
146
+ * presses there never reach Studio's document, so the canvas forwards them.
147
+ */
148
+ export interface HistoryShortcutPayload {
149
+ action: "undo" | "redo";
150
+ }
144
151
  export interface handleFocusedNodePayload {
145
152
  uid?: string;
146
153
  }
@@ -219,7 +226,14 @@ export interface Breakpoint {
219
226
  width: number;
220
227
  height: number;
221
228
  };
229
+ /**
230
+ * Set only on `register-breakpoints` events: `default` is one of the SDK's
231
+ * own breakpoints as shipped, `overridden` an SDK default the app changes,
232
+ * `app` a breakpoint only the app defines.
233
+ */
234
+ origin?: BreakpointOrigin;
222
235
  }
236
+ export type BreakpointOrigin = "default" | "overridden" | "app";
223
237
  export type PreProcessedBreakpoint = Omit<Breakpoint, "displayName"> & {
224
238
  displayName?: string;
225
239
  };
@@ -266,6 +280,11 @@ export interface ShortlistedComposition {
266
280
  url?: string;
267
281
  /** literal-character specificity from URL ranking; absent for non-URL queries */
268
282
  specificity?: number;
283
+ /**
284
+ * The content type this template is linked to. Empty or absent for a freeform
285
+ * template; absent for non-URL resolution and from an older SDK.
286
+ */
287
+ connected_content_type?: string;
269
288
  /**
270
289
  * Why this candidate did or didn't win when a composition is resolved BY URL.
271
290
  *
@@ -284,6 +303,28 @@ export interface ShortlistedComposition {
284
303
  */
285
304
  connectedEntryResult?: "found" | "absent" | "not-checked";
286
305
  }
306
+ /**
307
+ * Which template won a URL fetch, and why. Narrow on `kind`: each variant carries
308
+ * only its own fields.
309
+ *
310
+ * - "none": nothing at this URL has an entry.
311
+ * - "production": the template production renders here.
312
+ * - "preferred-composition": the template the render asked for
313
+ * (`cs-preferred-composition-uid`), picked over `productionUid` because both
314
+ * match this URL equally well and are linked to the same content type. Only
315
+ * happens inside Studio, the Visual Editor or Live Preview.
316
+ */
317
+ export type UrlWinner = {
318
+ readonly kind: "none";
319
+ } | {
320
+ readonly kind: "production";
321
+ readonly uid: string;
322
+ } | {
323
+ readonly kind: "preferred-composition";
324
+ readonly uid: string;
325
+ /** The template production renders here instead. */
326
+ readonly productionUid: string;
327
+ };
287
328
  /** The composition that won resolution (what the component actually rendered). */
288
329
  export interface ResolvedComposition {
289
330
  composable_uid: string;
@@ -318,6 +359,20 @@ export interface StudioDiagnosticContext {
318
359
  locale?: string;
319
360
  host?: string;
320
361
  livePreviewEnabled?: boolean;
362
+ /**
363
+ * Whether the stack that made this request had a preview token. A boolean, never
364
+ * the token. Read where the request ran, which on a server-rendered site is the
365
+ * server — the browser's handshake cannot speak for a token kept server-side.
366
+ */
367
+ hasPreviewToken?: boolean;
368
+ /** The address live preview is pointed at on the stack that made this request. */
369
+ previewHost?: string;
370
+ /**
371
+ * Whether a usable preview hash reached this request, captured with `servedBy`.
372
+ * Its own fact because `servedBy` alone cannot say why published content came
373
+ * back: live preview switched off and a hash that never arrived both read "cdn".
374
+ */
375
+ hasPreviewHash?: boolean;
321
376
  /** Which service answered: published content, preview, or not knowable. */
322
377
  servedBy?: "cdn" | "preview" | "unknown";
323
378
  sdkVersion?: string;
@@ -326,13 +381,23 @@ export interface StudioDiagnosticContext {
326
381
  export interface StudioDiagnosticFinding {
327
382
  /** Names the diagnosed case. What a surface selects its wording from. */
328
383
  code?: string;
384
+ /**
385
+ * What happened, in one sentence, apart from the code and causes the logged
386
+ * message wraps around it. Set together with `code`.
387
+ */
388
+ headline?: string;
329
389
  /**
330
390
  * Which of the five classes the code belongs to. Carried so a surface that
331
391
  * does not recognise the code can still say something true about it — the
332
392
  * codes a surface knows are fixed the day it ships, and the classes are not.
333
393
  */
334
394
  class?: string;
335
- /** Ordered, most likely first. Developer-facing English: never rendered to an author. */
395
+ /**
396
+ * Ordered, most likely first. Developer-facing English, not translated for an
397
+ * author: a Studio surface words a case from `code`. The one place they are
398
+ * shown as written is the SDK's canvas failure card, which may be the only
399
+ * explanation on screen.
400
+ */
336
401
  causes?: Array<{
337
402
  cause: string;
338
403
  fix: string;
@@ -340,6 +405,22 @@ export interface StudioDiagnosticFinding {
340
405
  /** What this particular failure established, narrowed by `code`. */
341
406
  findings?: Record<string, unknown>;
342
407
  }
408
+ /**
409
+ * The one request that tests the site's own delivery setup, and its answer.
410
+ *
411
+ * Sent once per page load from inside Studio. `ok: false` carries the same
412
+ * finding a failed page request would, so a surface reads it with the rules it
413
+ * already has. Absence says nothing: an older SDK never sends it.
414
+ */
415
+ export interface SetupCheckEventData {
416
+ kind: "setup-check";
417
+ /** Whether Contentstack accepted the setup. An empty list counts as a yes. */
418
+ ok: boolean;
419
+ /** Why it did not, when it did not. */
420
+ error?: StudioDiagnosticFinding;
421
+ /** Where the request went and what it was built from. Never a token. */
422
+ context?: StudioDiagnosticContext;
423
+ }
343
424
  export interface CompositionResolutionDiagnosticEventData {
344
425
  kind: "composition-resolution";
345
426
  /** True for `StudioCanvas` (renders the edited composition by uid), false for regular components. */
@@ -354,16 +435,19 @@ export interface CompositionResolutionDiagnosticEventData {
354
435
  };
355
436
  /** Which identifier the SDK resolved by (composableUid > templateContentTypeUid > url). */
356
437
  prioritizedBy: "composableUid" | "templateContentTypeUid" | "url";
357
- /** Candidates considered (all URL-ranking tiers). Single entry for uid/ct queries; absent for custom fetchers / legacy path. */
438
+ /** Candidates considered (all URL-ranking tiers). Single entry for uid/ct queries; absent for the legacy path. */
358
439
  shortlisted?: ShortlistedComposition[];
440
+ /** How the URL fetch picked its winner. Absent when the fetch wasn't by URL. */
441
+ urlWinner?: UrlWinner;
359
442
  /** The winner — present on success. */
360
443
  resolved?: ResolvedComposition;
361
444
  /** Where this request went. Sent on success and on failure alike. */
362
445
  context?: StudioDiagnosticContext;
363
446
  /**
364
- * Present when the page could not be loaded. Its presence means the SDK threw,
365
- * and a throw is what decides the host's HTTP status — so nothing that leaves
366
- * a working page belongs here. A page that rendered with something wrong on it
447
+ * Present when the page could not be loaded. Its presence means the fetch
448
+ * failed — thrown to a visitor, where it decides the host's HTTP status, or
449
+ * rendered as a failure inside Studio's canvas — so nothing that leaves a
450
+ * working page belongs here. A page that rendered with something wrong on it
367
451
  * is diagnosed by comparing `context` against what the surface already knows,
368
452
  * the way a content-type mismatch already is.
369
453
  *
@@ -371,6 +455,7 @@ export interface CompositionResolutionDiagnosticEventData {
371
455
  * read `code` for the case.
372
456
  */
373
457
  error?: StudioDiagnosticFinding & {
458
+ /** The full logged text: code, headline and causes in one string. */
374
459
  message: string;
375
460
  };
376
461
  timestamp: number;
@@ -1,7 +1,7 @@
1
- import { HitboxDetails, ValidatePropEventPayload, PreProcessedBreakpoint, SlotNodeHitboxDetails, HighlightNodeEventPayload, RequestHighlightNodeEventPayload, HighlightFocusedNodeEventPayload, HighlightSlotNodeEventPayload, RevealNodePayload, RevealResultPayload, HighlightStyleNodeEventPayload, HighlightActiveNodeEventPayload, BaseHighlightEventPayload, RegularNodeHitboxDetails, PermanentDropZoneDirection, PermanentDropZoneHitboxDetails, SerializedEvent, UrlChangeEventPayload, Breakpoint, HighlightAncestorsEventPayload, InitMessage, DefaultBreakpoint, ActiveBreakpointEventPayload, BreakpointInput, RegisterBreakpointsEventPayload, SetCursorTypeEventPayload, UpdateStyleEventPayload, ComputedStyleSection, ChangeActiveStyleGroupPayload, handleActiveNodePayload, handleFocusedNodePayload, handleActiveSlotNode, MouseMoveEventPayload, MouseUpEventPayload, DraggerPosition, UpdateBindingErrorsEventPayload, OpenComposableStudioFromVBEventData, OpenComposableStudioFromStudioEventData, CompositionSavedEventData, PrimaryCompositionDetectedEventData, CompositionResolutionDiagnosticEventData, HiddenElementNotificationEventData, GetNodeScreenshotEventData, GetNodeScreenshotResponseEventData, RefetchSpecEventData, TARGET_NODE } from "./client.js";
1
+ import { HitboxDetails, ValidatePropEventPayload, PreProcessedBreakpoint, SlotNodeHitboxDetails, HighlightNodeEventPayload, RequestHighlightNodeEventPayload, HighlightFocusedNodeEventPayload, HighlightSlotNodeEventPayload, RevealNodePayload, RevealResultPayload, HistoryShortcutPayload, HighlightStyleNodeEventPayload, HighlightActiveNodeEventPayload, BaseHighlightEventPayload, RegularNodeHitboxDetails, PermanentDropZoneDirection, PermanentDropZoneHitboxDetails, SerializedEvent, UrlChangeEventPayload, Breakpoint, BreakpointOrigin, HighlightAncestorsEventPayload, InitMessage, DefaultBreakpoint, ActiveBreakpointEventPayload, BreakpointInput, RegisterBreakpointsEventPayload, SetCursorTypeEventPayload, UpdateStyleEventPayload, ComputedStyleSection, ChangeActiveStyleGroupPayload, handleActiveNodePayload, handleFocusedNodePayload, handleActiveSlotNode, MouseMoveEventPayload, MouseUpEventPayload, DraggerPosition, UpdateBindingErrorsEventPayload, OpenComposableStudioFromVBEventData, OpenComposableStudioFromStudioEventData, CompositionSavedEventData, PrimaryCompositionDetectedEventData, CompositionResolutionDiagnosticEventData, SetupCheckEventData, HiddenElementNotificationEventData, GetNodeScreenshotEventData, GetNodeScreenshotResponseEventData, RefetchSpecEventData, TARGET_NODE } from "./client.js";
2
2
  import type { CompositionQuery } from "./composition-query.js";
3
3
  export type { CompositionQuery };
4
- export type { InitMessage, HighlightActiveNodeEventPayload, HighlightAncestorsEventPayload, HighlightStyleNodeEventPayload, HighlightSlotNodeEventPayload, RevealMissKind, RevealNodePayload, RevealResultPayload, HighlightFocusedNodeEventPayload, HighlightNodeEventPayload, RequestHighlightNodeEventPayload, BaseHighlightEventPayload, HitboxDetails, RegularNodeHitboxDetails, SlotNodeHitboxDetails, PermanentDropZoneDirection, PermanentDropZoneHitboxDetails, SerializedEvent, UrlChangeEventPayload, ValidatePropEventPayload, Breakpoint, PreProcessedBreakpoint, DefaultBreakpoint, BreakpointInput, ActiveBreakpointEventPayload, RegisterBreakpointsEventPayload, SetCursorTypeEventPayload, UpdateStyleEventPayload, ComputedStyleSection, ChangeActiveStyleGroupPayload, handleActiveNodePayload, handleFocusedNodePayload, handleActiveSlotNode, MouseMoveEventPayload, MouseUpEventPayload, DraggerPosition, UpdateBindingErrorsEventPayload, OpenComposableStudioFromVBEventData, OpenComposableStudioFromStudioEventData, CompositionSavedEventData, PrimaryCompositionDetectedEventData, CompositionResolutionDiagnosticEventData, ShortlistedComposition, ResolvedComposition, HiddenElementNotificationEventData, GetNodeScreenshotEventData, GetNodeScreenshotResponseEventData, RefetchSpecEventData, } from "./client.js";
4
+ export type { InitMessage, HighlightActiveNodeEventPayload, HighlightAncestorsEventPayload, HighlightStyleNodeEventPayload, HighlightSlotNodeEventPayload, RevealMissKind, RevealNodePayload, RevealResultPayload, HistoryShortcutPayload, HighlightFocusedNodeEventPayload, HighlightNodeEventPayload, RequestHighlightNodeEventPayload, BaseHighlightEventPayload, HitboxDetails, RegularNodeHitboxDetails, SlotNodeHitboxDetails, PermanentDropZoneDirection, PermanentDropZoneHitboxDetails, SerializedEvent, UrlChangeEventPayload, ValidatePropEventPayload, Breakpoint, BreakpointOrigin, PreProcessedBreakpoint, DefaultBreakpoint, BreakpointInput, ActiveBreakpointEventPayload, RegisterBreakpointsEventPayload, SetCursorTypeEventPayload, UpdateStyleEventPayload, ComputedStyleSection, ChangeActiveStyleGroupPayload, handleActiveNodePayload, handleFocusedNodePayload, handleActiveSlotNode, MouseMoveEventPayload, MouseUpEventPayload, DraggerPosition, UpdateBindingErrorsEventPayload, OpenComposableStudioFromVBEventData, OpenComposableStudioFromStudioEventData, CompositionSavedEventData, PrimaryCompositionDetectedEventData, CompositionResolutionDiagnosticEventData, SetupCheckEventData, ShortlistedComposition, ResolvedComposition, UrlWinner, HiddenElementNotificationEventData, GetNodeScreenshotEventData, GetNodeScreenshotResponseEventData, RefetchSpecEventData, } from "./client.js";
5
5
  export { TARGET_NODE } from "./client.js";
6
6
  export type BaseType = {
7
7
  InitMessage: InitMessage;
@@ -11,6 +11,7 @@ export type BaseType = {
11
11
  HighlightSlotNodeEventPayload: HighlightSlotNodeEventPayload;
12
12
  RevealNodePayload: RevealNodePayload;
13
13
  RevealResultPayload: RevealResultPayload;
14
+ HistoryShortcutPayload: HistoryShortcutPayload;
14
15
  HighlightFocusedNodeEventPayload: HighlightFocusedNodeEventPayload;
15
16
  HighlightNodeEventPayload: HighlightNodeEventPayload;
16
17
  RequestHighlightNodeEventPayload: RequestHighlightNodeEventPayload;
@@ -24,6 +25,7 @@ export type BaseType = {
24
25
  UrlChangeEventPayload: UrlChangeEventPayload;
25
26
  ValidatePropEventPayload: ValidatePropEventPayload;
26
27
  Breakpoint: Breakpoint;
28
+ BreakpointOrigin: BreakpointOrigin;
27
29
  PreProcessedBreakpoint: PreProcessedBreakpoint;
28
30
  DefaultBreakpoint: DefaultBreakpoint;
29
31
  BreakpointInput: BreakpointInput;
@@ -45,6 +47,7 @@ export type BaseType = {
45
47
  CompositionSavedEventData: CompositionSavedEventData;
46
48
  PrimaryCompositionDetectedEventData: PrimaryCompositionDetectedEventData;
47
49
  CompositionResolutionDiagnosticEventData: CompositionResolutionDiagnosticEventData;
50
+ SetupCheckEventData: SetupCheckEventData;
48
51
  HiddenElementNotificationEventData: HiddenElementNotificationEventData;
49
52
  GetNodeScreenshotEventData: GetNodeScreenshotEventData;
50
53
  GetNodeScreenshotResponseEventData: GetNodeScreenshotResponseEventData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-message-types",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "description": "Shared message types for communication between Studio platform and SDKs",
6
6
  "author": "RavenColEvol <ravilamkoti@gmail.com>",