@contentstack/studio-message-types 2.0.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
  }
@@ -166,6 +173,8 @@ export interface ChangeActiveStyleGroupPayload {
166
173
  uid: string;
167
174
  styleGroup: string;
168
175
  }
176
+ /** Which side of its Repeater a permanent drop zone sits on. */
177
+ export type PermanentDropZoneDirection = "top" | "bottom";
169
178
  export type BaseHitboxDetails = {
170
179
  path: Path;
171
180
  direction: "top" | "bottom" | "left" | "right";
@@ -173,12 +182,24 @@ export type BaseHitboxDetails = {
173
182
  };
174
183
  export type RegularNodeHitboxDetails = BaseHitboxDetails & {
175
184
  shouldShowSlotDropzone: false;
185
+ isPermanentDropZone?: false;
176
186
  };
177
187
  export type SlotNodeHitboxDetails = BaseHitboxDetails & {
178
188
  slotUid: string;
179
189
  shouldShowSlotDropzone: true;
190
+ isPermanentDropZone?: false;
191
+ };
192
+ /**
193
+ * A drop on an editor-only permanent drop zone: a sibling drop beside `path`.
194
+ * The zone highlights itself, so Studio draws no drop line; `nodeBoundingBox`
195
+ * is the zone's own box.
196
+ */
197
+ export type PermanentDropZoneHitboxDetails = Omit<BaseHitboxDetails, "direction"> & {
198
+ direction: PermanentDropZoneDirection;
199
+ shouldShowSlotDropzone: false;
200
+ isPermanentDropZone: true;
180
201
  };
181
- export type HitboxDetails = RegularNodeHitboxDetails | SlotNodeHitboxDetails | null;
202
+ export type HitboxDetails = RegularNodeHitboxDetails | SlotNodeHitboxDetails | PermanentDropZoneHitboxDetails | null;
182
203
  export interface SetCursorTypeEventPayload {
183
204
  cursorType: string;
184
205
  }
@@ -205,7 +226,14 @@ export interface Breakpoint {
205
226
  width: number;
206
227
  height: number;
207
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;
208
235
  }
236
+ export type BreakpointOrigin = "default" | "overridden" | "app";
209
237
  export type PreProcessedBreakpoint = Omit<Breakpoint, "displayName"> & {
210
238
  displayName?: string;
211
239
  };
@@ -252,6 +280,11 @@ export interface ShortlistedComposition {
252
280
  url?: string;
253
281
  /** literal-character specificity from URL ranking; absent for non-URL queries */
254
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;
255
288
  /**
256
289
  * Why this candidate did or didn't win when a composition is resolved BY URL.
257
290
  *
@@ -270,6 +303,28 @@ export interface ShortlistedComposition {
270
303
  */
271
304
  connectedEntryResult?: "found" | "absent" | "not-checked";
272
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
+ };
273
328
  /** The composition that won resolution (what the component actually rendered). */
274
329
  export interface ResolvedComposition {
275
330
  composable_uid: string;
@@ -304,6 +359,20 @@ export interface StudioDiagnosticContext {
304
359
  locale?: string;
305
360
  host?: string;
306
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;
307
376
  /** Which service answered: published content, preview, or not knowable. */
308
377
  servedBy?: "cdn" | "preview" | "unknown";
309
378
  sdkVersion?: string;
@@ -312,13 +381,23 @@ export interface StudioDiagnosticContext {
312
381
  export interface StudioDiagnosticFinding {
313
382
  /** Names the diagnosed case. What a surface selects its wording from. */
314
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;
315
389
  /**
316
390
  * Which of the five classes the code belongs to. Carried so a surface that
317
391
  * does not recognise the code can still say something true about it — the
318
392
  * codes a surface knows are fixed the day it ships, and the classes are not.
319
393
  */
320
394
  class?: string;
321
- /** 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
+ */
322
401
  causes?: Array<{
323
402
  cause: string;
324
403
  fix: string;
@@ -326,6 +405,22 @@ export interface StudioDiagnosticFinding {
326
405
  /** What this particular failure established, narrowed by `code`. */
327
406
  findings?: Record<string, unknown>;
328
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
+ }
329
424
  export interface CompositionResolutionDiagnosticEventData {
330
425
  kind: "composition-resolution";
331
426
  /** True for `StudioCanvas` (renders the edited composition by uid), false for regular components. */
@@ -340,16 +435,19 @@ export interface CompositionResolutionDiagnosticEventData {
340
435
  };
341
436
  /** Which identifier the SDK resolved by (composableUid > templateContentTypeUid > url). */
342
437
  prioritizedBy: "composableUid" | "templateContentTypeUid" | "url";
343
- /** 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. */
344
439
  shortlisted?: ShortlistedComposition[];
440
+ /** How the URL fetch picked its winner. Absent when the fetch wasn't by URL. */
441
+ urlWinner?: UrlWinner;
345
442
  /** The winner — present on success. */
346
443
  resolved?: ResolvedComposition;
347
444
  /** Where this request went. Sent on success and on failure alike. */
348
445
  context?: StudioDiagnosticContext;
349
446
  /**
350
- * Present when the page could not be loaded. Its presence means the SDK threw,
351
- * and a throw is what decides the host's HTTP status — so nothing that leaves
352
- * 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
353
451
  * is diagnosed by comparing `context` against what the surface already knows,
354
452
  * the way a content-type mismatch already is.
355
453
  *
@@ -357,6 +455,7 @@ export interface CompositionResolutionDiagnosticEventData {
357
455
  * read `code` for the case.
358
456
  */
359
457
  error?: StudioDiagnosticFinding & {
458
+ /** The full logged text: code, headline and causes in one string. */
360
459
  message: string;
361
460
  };
362
461
  timestamp: number;
@@ -1,7 +1,7 @@
1
- import { HitboxDetails, ValidatePropEventPayload, PreProcessedBreakpoint, SlotNodeHitboxDetails, HighlightNodeEventPayload, RequestHighlightNodeEventPayload, HighlightFocusedNodeEventPayload, HighlightSlotNodeEventPayload, RevealNodePayload, RevealResultPayload, HighlightStyleNodeEventPayload, HighlightActiveNodeEventPayload, BaseHighlightEventPayload, RegularNodeHitboxDetails, 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, 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;
@@ -18,10 +19,13 @@ export type BaseType = {
18
19
  HitboxDetails: HitboxDetails;
19
20
  RegularNodeHitboxDetails: RegularNodeHitboxDetails;
20
21
  SlotNodeHitboxDetails: SlotNodeHitboxDetails;
22
+ PermanentDropZoneDirection: PermanentDropZoneDirection;
23
+ PermanentDropZoneHitboxDetails: PermanentDropZoneHitboxDetails;
21
24
  SerializedEvent: SerializedEvent;
22
25
  UrlChangeEventPayload: UrlChangeEventPayload;
23
26
  ValidatePropEventPayload: ValidatePropEventPayload;
24
27
  Breakpoint: Breakpoint;
28
+ BreakpointOrigin: BreakpointOrigin;
25
29
  PreProcessedBreakpoint: PreProcessedBreakpoint;
26
30
  DefaultBreakpoint: DefaultBreakpoint;
27
31
  BreakpointInput: BreakpointInput;
@@ -43,6 +47,7 @@ export type BaseType = {
43
47
  CompositionSavedEventData: CompositionSavedEventData;
44
48
  PrimaryCompositionDetectedEventData: PrimaryCompositionDetectedEventData;
45
49
  CompositionResolutionDiagnosticEventData: CompositionResolutionDiagnosticEventData;
50
+ SetupCheckEventData: SetupCheckEventData;
46
51
  HiddenElementNotificationEventData: HiddenElementNotificationEventData;
47
52
  GetNodeScreenshotEventData: GetNodeScreenshotEventData;
48
53
  GetNodeScreenshotResponseEventData: GetNodeScreenshotResponseEventData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-message-types",
3
- "version": "2.0.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>",