@contentstack/studio-client 1.2.0 → 1.4.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.
Files changed (41) hide show
  1. package/dist/breakpoints/BreakpointManager.js +0 -1
  2. package/dist/breakpoints/BreakpointManager.js.map +1 -1
  3. package/dist/breakpoints/breakpoint.js +1 -0
  4. package/dist/breakpoints/breakpoint.js.map +1 -1
  5. package/dist/composable-studio/initializer-sdk.js +0 -1
  6. package/dist/composable-studio/initializer-sdk.js.map +1 -1
  7. package/dist/composable-studio/sdk.js +223 -46
  8. package/dist/composable-studio/sdk.js.map +1 -1
  9. package/dist/config/config.schema.js +1 -0
  10. package/dist/config/config.schema.js.map +1 -1
  11. package/dist/config/default-config.js +1 -0
  12. package/dist/config/default-config.js.map +1 -1
  13. package/dist/config/process-user-config.js +4 -1
  14. package/dist/config/process-user-config.js.map +1 -1
  15. package/dist/config/stack-sdk-wrapper.js +52 -12
  16. package/dist/config/stack-sdk-wrapper.js.map +1 -1
  17. package/dist/context-menu/context-menu.js +0 -1
  18. package/dist/context-menu/context-menu.js.map +1 -1
  19. package/dist/design/fonts/index.js +143 -2
  20. package/dist/design/fonts/index.js.map +1 -1
  21. package/dist/design/handle-active-style-change.js +0 -1
  22. package/dist/design/handle-active-style-change.js.map +1 -1
  23. package/dist/dnd/dnd-manager.js +2 -3
  24. package/dist/dnd/dnd-manager.js.map +1 -1
  25. package/dist/highlight-node/highlight-node-manager.js +0 -1
  26. package/dist/highlight-node/highlight-node-manager.js.map +1 -1
  27. package/dist/highlight-node/highlight-node.js +0 -1
  28. package/dist/highlight-node/highlight-node.js.map +1 -1
  29. package/dist/index.d.ts +67 -19
  30. package/dist/index.js +1 -1
  31. package/dist/utils/composable-studio-error.js +9 -7
  32. package/dist/utils/composable-studio-error.js.map +1 -1
  33. package/dist/utils/error-messages.default.js +141 -0
  34. package/dist/utils/error-messages.default.js.map +1 -0
  35. package/dist/utils/error-messages.js +47 -0
  36. package/dist/utils/error-messages.js.map +1 -0
  37. package/dist/utils/get-url-patterns.js +0 -1
  38. package/dist/utils/get-url-patterns.js.map +1 -1
  39. package/dist/utils/http-error.constants.js +96 -0
  40. package/dist/utils/http-error.constants.js.map +1 -0
  41. package/package.json +9 -8
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _contentstack_studio_internal from '@contentstack/studio-internal';
2
- import { Node, PathNode, Path, Descendant, Operation, BindingType, Condition } from '@contentstack/studio-internal';
2
+ import { Node, PathNode, Path, Descendant, Operation, BindingType, Condition, NodeStyles } from '@contentstack/studio-internal';
3
3
  import * as _contentstack_studio_registry from '@contentstack/studio-registry';
4
4
  import { StudioSpecData, RawStaticValue, ICSEntryReference, StaticValue, BreakpointInput, Breakpoint } from '@contentstack/studio-registry';
5
5
  export { Breakpoint } from '@contentstack/studio-registry';
@@ -25,6 +25,7 @@ declare const userConfigSchema: z.ZodObject<{
25
25
  */
26
26
  contentTypeUid: z.ZodOptional<z.ZodString>;
27
27
  stackSdk: z.ZodType<any, z.ZodTypeDef, any>;
28
+ locale: z.ZodOptional<z.ZodString>;
28
29
  cslp: z.ZodOptional<z.ZodObject<{
29
30
  appendTags: z.ZodOptional<z.ZodBoolean>;
30
31
  }, "strip", z.ZodTypeAny, {
@@ -45,6 +46,7 @@ declare const userConfigSchema: z.ZodObject<{
45
46
  }, "strip", z.ZodTypeAny, {
46
47
  contentTypeUid?: string | undefined;
47
48
  stackSdk?: any;
49
+ locale?: string | undefined;
48
50
  cslp?: {
49
51
  appendTags?: boolean | undefined;
50
52
  } | undefined;
@@ -55,6 +57,7 @@ declare const userConfigSchema: z.ZodObject<{
55
57
  }, {
56
58
  contentTypeUid?: string | undefined;
57
59
  stackSdk?: any;
60
+ locale?: string | undefined;
58
61
  cslp?: {
59
62
  appendTags?: boolean | undefined;
60
63
  } | undefined;
@@ -68,7 +71,8 @@ type JSStack = Stack;
68
71
  type TSStack = ReturnType<(typeof deliverySdk)["stack"]>;
69
72
  declare class StackSDK {
70
73
  sdk: JSStack | TSStack;
71
- constructor(sdk: JSStack | TSStack);
74
+ private _locale?;
75
+ constructor(sdk: JSStack | TSStack, locale?: string);
72
76
  isJavaScriptSDK(sdk: Stack | ReturnType<(typeof deliverySdk)["stack"]>): sdk is Stack;
73
77
  livePreviewQuery(livePreviewHash: string): void;
74
78
  ctQuery(contentTypeUid: string, options?: {
@@ -77,11 +81,13 @@ declare class StackSDK {
77
81
  references?: string[];
78
82
  only?: [string, string][];
79
83
  variantAlias?: string;
84
+ locale?: string;
80
85
  query?: Record<string, any>;
81
86
  }): any;
82
87
  entryQuery(contentTypeUid: string, entryUID: string, options?: {
83
88
  only?: [string, string][];
84
89
  variantAlias?: string;
90
+ locale?: string;
85
91
  }): any;
86
92
  private isJsQuery;
87
93
  where(query: ReturnType<StackSDK["ctQuery"]>, field: string, value: any): any;
@@ -91,10 +97,12 @@ declare class StackSDK {
91
97
  preview_token?: string;
92
98
  enable?: boolean;
93
99
  } | undefined;
100
+ get locale(): string | undefined;
94
101
  }
95
102
 
96
- interface Config extends DeepRequired<Omit<UserConfig, "stackSdk">> {
103
+ interface Config extends DeepRequired<Omit<UserConfig, "stackSdk" | "locale">> {
97
104
  stackSdk: StackSDK;
105
+ locale?: string;
98
106
  }
99
107
  type LightConfig = Pick<Config, "openInStudioButton" | "contentTypeUid" | "cslp">;
100
108
  type UserConfig = z.infer<typeof userConfigSchema>;
@@ -157,6 +165,7 @@ interface CompositionEntry {
157
165
  created_at: string;
158
166
  updated_at: string;
159
167
  url?: string;
168
+ place_composition_as?: "page" | "section";
160
169
  ui: CompositionEntryIncompleteUi;
161
170
  data_sources: string;
162
171
  static_value?: RawStaticValue;
@@ -201,6 +210,18 @@ type CompositionQueryOptions = {
201
210
  * Support for fetching data of a specified variant.
202
211
  */
203
212
  variantAlias?: string;
213
+ /**
214
+ * Override the default stack locale for this specific query.
215
+ * If provided, this locale will be used instead of the stack config locale.
216
+ * Automatically includes fallback support via Contentstack's native fallback mechanism.
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * // Fetch composition in French instead of default locale
221
+ * useCompositionData({ compositionUid: "blt123" }, { locale: "fr" })
222
+ * ```
223
+ */
224
+ locale?: string;
204
225
  extendQuery?: {
205
226
  [ct_uid: string]: {
206
227
  includeReferences?: string[];
@@ -270,6 +291,7 @@ declare const studioSdk: {
270
291
  getConfig(): Config;
271
292
  isInsideStudioFrame: () => boolean;
272
293
  fetchSpec: (queryOptions: _contentstack_studio_messenger.CompositionQuery, options?: CompositionQueryOptions) => Promise<StudioSpec>;
294
+ fetchData: (compositionEntry: CompositionEntry, queryOptions: _contentstack_studio_messenger.CompositionQuery, options?: CompositionQueryOptions) => Promise<_contentstack_studio_registry.StudioSpecData>;
273
295
  fetchTemplateEntry: (options: {
274
296
  connected_content_type: string;
275
297
  compositionQuery: _contentstack_studio_messenger.CompositionQuery;
@@ -277,6 +299,7 @@ declare const studioSdk: {
277
299
  onlyQueries: [string, string][];
278
300
  composableUid: string;
279
301
  variantAlias?: string;
302
+ locale?: string;
280
303
  }, data: _contentstack_studio_registry.StudioSpecData) => Promise<void>;
281
304
  getSeoMetadata: (ui: _contentstack_studio_internal.Node) => SeoMetadata;
282
305
  };
@@ -366,8 +389,8 @@ declare class DNDManager {
366
389
  hasMoved: boolean;
367
390
  mouseDown: boolean;
368
391
  constructor();
369
- handleMouseDown(e: MouseEvent): void;
370
- handleMouseUp(e: MouseEvent): void;
392
+ handleMouseDown(_e: MouseEvent): void;
393
+ handleMouseUp(_e: MouseEvent): void;
371
394
  handleMouseLeave(e: MouseEvent): void;
372
395
  start(e: MouseEvent): void;
373
396
  startParent(): void;
@@ -543,24 +566,49 @@ declare const isInsideVisualBuilderFrame: () => boolean;
543
566
 
544
567
  declare const ComposableStudioErrors: {
545
568
  readonly COMPOSITION_NOT_FOUND: "COMPOSITION_NOT_FOUND";
569
+ readonly COMPOSITION_NOT_FOUND_BY_URL: "COMPOSITION_NOT_FOUND_BY_URL";
570
+ readonly PREVIEW_ENTRY_NOT_FOUND: "PREVIEW_ENTRY_NOT_FOUND";
546
571
  readonly FETCHING_CONNECTED_DATA_FAILED: "FETCHING_CONNECTED_DATA_FAILED";
547
572
  readonly RESOLVING_DATA_SOURCES_FAILED: "RESOLVING_DATA_SOURCES_FAILED";
548
573
  readonly STACK_SDK_NOT_AVAILABLE: "STACK_SDK_NOT_AVAILABLE";
549
574
  readonly INVALID_FETCH_SPEC_OPTIONS: "INVALID_FETCH_SPEC_OPTIONS";
575
+ readonly MISSING_COMPOSITION_IDENTIFIER: "MISSING_COMPOSITION_IDENTIFIER";
576
+ readonly UI_PARSING_ERROR: "UI_PARSING_ERROR";
577
+ readonly SPEC_DATA_INVALID: "SPEC_DATA_INVALID";
578
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
579
+ readonly AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR";
580
+ readonly SERVER_ERROR: "SERVER_ERROR";
550
581
  };
551
- declare class ComposableStudioError extends Error {
552
- id: keyof typeof ComposableStudioErrors;
553
- details: any;
554
- constructor(id: keyof typeof ComposableStudioErrors, message: string, details?: any);
555
- canFallback(): boolean;
582
+ /**
583
+ * Information about a possible cause of an error and how to fix it
584
+ */
585
+ interface TroubleshootingInfo {
586
+ /**
587
+ * Description of the possible cause of the error
588
+ */
589
+ cause: string;
590
+ /**
591
+ * Suggested fix or resolution for this cause
592
+ */
593
+ fix: string;
556
594
  }
557
- declare const FALLBACK_POSSIBLE_ERRORS: readonly ["COMPOSITION_NOT_FOUND"];
558
- type TFallbackError = (typeof FALLBACK_POSSIBLE_ERRORS)[number];
559
- interface ComposableStudioClientError extends ComposableStudioError {
560
- id: Exclude<keyof typeof ComposableStudioErrors, TFallbackError>;
595
+ /**
596
+ * Type definition for error details that can be passed to ComposableStudioError
597
+ */
598
+ interface ComposableStudioErrorDetails {
599
+ /**
600
+ * Array of troubleshooting information with causes and fixes
601
+ */
602
+ troubleshootingInfo?: TroubleshootingInfo[];
603
+ /**
604
+ * Additional error context and metadata
605
+ */
606
+ [key: string]: any;
561
607
  }
562
- interface ComposableStudioFallbackError extends ComposableStudioError {
563
- id: TFallbackError;
608
+ declare class ComposableStudioError extends Error {
609
+ id: keyof typeof ComposableStudioErrors;
610
+ details?: ComposableStudioErrorDetails;
611
+ constructor(id: keyof typeof ComposableStudioErrors, message: string, details?: ComposableStudioErrorDetails);
564
612
  }
565
613
 
566
614
  declare const evaluateCondition: (condition: Condition, data: any) => boolean;
@@ -628,7 +676,7 @@ interface FontVariants {
628
676
  italic: boolean;
629
677
  }
630
678
 
631
- declare function loadGoogleFont(fontFamily: string, fontVariants: FontVariants): Promise<void>;
679
+ declare function loadGoogleFont(fontFamily: string, fontVariants: FontVariants, nodeStyles: NodeStyles, nodeUid: string): Promise<void>;
632
680
 
633
681
  declare const GOOGLE_FONT_API = "https://fonts.googleapis.com/css2";
634
682
 
@@ -713,5 +761,5 @@ declare function getNodeScreenshotEvent(): {
713
761
  unregister: () => void;
714
762
  } | undefined;
715
763
 
716
- export { BreakpointManager, COMPOSABLE_DATA_ATTRIBUTES, COMPOSABLE_STUDIO_EMITTED_EVENTS, ComposableStudioError, ComposableStudioErrors, DEFAULT_BREAKPOINTS, EDGE_PADDING, ELEMENT_TO_NODE, FALLBACK_POSSIBLE_ERRORS, GOOGLE_FONT_API, INCLUDE_DEPTH_COUNT, MAX_SCROLL_SPEED, NODE_TO_ELEMENT, NODE_TO_PARENT, NODE_TO_PATH_NODE, RendererMode, RendererModeUtil, SCROLL_INTERVAL, addBreakpointEventListeners, addContextMenuEventListeners, addHighlightNodeEventListeners, addHighlightSpacingEventListeners, applyOperation, batchFetchEntries, calculateDynamicSpeed, clientRendererModeUtil, closeHiddenElementNotification, composableStudioEventEmitter, compositionSaveEventListener, createClassNameUid, studioSdk as default, dndEventListener, dndManager, entriesFromResponse, evaluateCondition, findNearestBuilderNode, findNearestSlotNode, findPath, findPathForElement, getBindingStringForCS, getComposableElement, getComputedStyles, getDefaultConfig, getHitboxDetails, getHitboxDirection, getJSONRTE, getNodeScreenshotEvent, getScrollContainer, getScrollContainerRect, getScrollableParent, handleOnScroll, handleResize, hasSlotDropzone, hiddenElementNotificationEventEmitter, highlightNodeManager, isBrowser, isCompositionBeingEdited, isInsideVisualBuilderFrame, loadGoogleFont, onlyParmasGenerator, openHiddenElementNotification, parseStringValue, preProcessStaticValues, queryParam, registerJSONRTE, sendInitMessage, serializeComputedStyles, serializeEvent, setStaticEntryInDS, setTemplateEntryInDS, studioSdk, toggleNodeVisible, updateStyleOnStyleNodeChange };
717
- export type { ClientEditableNodeInternalAttributes, ClientPreviewNodeInternalAttributes, ComposableStudioClientError, ComposableStudioFallbackError, ComposableStudioLightSdk, CompositionEntry, CompositionEntryIncompleteUi, CompositionQueryForSSR, CompositionQueryForSSRInput, CompositionQueryOptions, Config, EmittedEvents, FontVariants, GoogleFont, HiddenElementNotificationHandler, LightConfig, MetaProp, ParsedStringResult, SearchQueryInput, SeoMetadata, StudioComponentFetchOptions, StudioComponentSpecOptions, StudioSdk, StudioSpec, SymbolEntry, URLSearchParamsString, UserConfig };
764
+ export { BreakpointManager, COMPOSABLE_DATA_ATTRIBUTES, COMPOSABLE_STUDIO_EMITTED_EVENTS, ComposableStudioError, ComposableStudioErrors, DEFAULT_BREAKPOINTS, EDGE_PADDING, ELEMENT_TO_NODE, GOOGLE_FONT_API, INCLUDE_DEPTH_COUNT, MAX_SCROLL_SPEED, NODE_TO_ELEMENT, NODE_TO_PARENT, NODE_TO_PATH_NODE, RendererMode, RendererModeUtil, SCROLL_INTERVAL, addBreakpointEventListeners, addContextMenuEventListeners, addHighlightNodeEventListeners, addHighlightSpacingEventListeners, applyOperation, batchFetchEntries, calculateDynamicSpeed, clientRendererModeUtil, closeHiddenElementNotification, composableStudioEventEmitter, compositionSaveEventListener, createClassNameUid, studioSdk as default, dndEventListener, dndManager, entriesFromResponse, evaluateCondition, findNearestBuilderNode, findNearestSlotNode, findPath, findPathForElement, getBindingStringForCS, getComposableElement, getComputedStyles, getDefaultConfig, getHitboxDetails, getHitboxDirection, getJSONRTE, getNodeScreenshotEvent, getScrollContainer, getScrollContainerRect, getScrollableParent, handleOnScroll, handleResize, hasSlotDropzone, hiddenElementNotificationEventEmitter, highlightNodeManager, isBrowser, isCompositionBeingEdited, isInsideVisualBuilderFrame, loadGoogleFont, onlyParmasGenerator, openHiddenElementNotification, parseStringValue, preProcessStaticValues, queryParam, registerJSONRTE, sendInitMessage, serializeComputedStyles, serializeEvent, setStaticEntryInDS, setTemplateEntryInDS, studioSdk, toggleNodeVisible, updateStyleOnStyleNodeChange };
765
+ export type { ClientEditableNodeInternalAttributes, ClientPreviewNodeInternalAttributes, ComposableStudioErrorDetails, ComposableStudioLightSdk, CompositionEntry, CompositionEntryIncompleteUi, CompositionQueryForSSR, CompositionQueryForSSRInput, CompositionQueryOptions, Config, EmittedEvents, FontVariants, GoogleFont, HiddenElementNotificationHandler, LightConfig, MetaProp, ParsedStringResult, SearchQueryInput, SeoMetadata, StudioComponentFetchOptions, StudioComponentSpecOptions, StudioSdk, StudioSpec, SymbolEntry, TroubleshootingInfo, URLSearchParamsString, UserConfig };
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ export { isCompositionBeingEdited } from './utils/is-composition-being-edited.js
22
22
  export { onlyParmasGenerator, queryParam } from './utils/query-param.js';
23
23
  export { batchFetchEntries, entriesFromResponse, getBindingStringForCS, setStaticEntryInDS, setTemplateEntryInDS } from './utils/sdk.js';
24
24
  export { isInsideVisualBuilderFrame } from './utils/is-inside-visual-builder-frame.js';
25
- export { ComposableStudioError, ComposableStudioErrors, FALLBACK_POSSIBLE_ERRORS } from './utils/composable-studio-error.js';
25
+ export { ComposableStudioError, ComposableStudioErrors } from './utils/composable-studio-error.js';
26
26
  export { evaluateCondition } from './utils/conditionBlock.js';
27
27
  export { RendererModeUtil, clientRendererModeUtil, serializeComputedStyles } from './utils/canvas.js';
28
28
  export { loadGoogleFont } from './design/fonts/index.js';
@@ -1,9 +1,17 @@
1
1
  const ComposableStudioErrors = {
2
2
  COMPOSITION_NOT_FOUND: "COMPOSITION_NOT_FOUND",
3
+ COMPOSITION_NOT_FOUND_BY_URL: "COMPOSITION_NOT_FOUND_BY_URL",
4
+ PREVIEW_ENTRY_NOT_FOUND: "PREVIEW_ENTRY_NOT_FOUND",
3
5
  FETCHING_CONNECTED_DATA_FAILED: "FETCHING_CONNECTED_DATA_FAILED",
4
6
  RESOLVING_DATA_SOURCES_FAILED: "RESOLVING_DATA_SOURCES_FAILED",
5
7
  STACK_SDK_NOT_AVAILABLE: "STACK_SDK_NOT_AVAILABLE",
6
8
  INVALID_FETCH_SPEC_OPTIONS: "INVALID_FETCH_SPEC_OPTIONS",
9
+ MISSING_COMPOSITION_IDENTIFIER: "MISSING_COMPOSITION_IDENTIFIER",
10
+ UI_PARSING_ERROR: "UI_PARSING_ERROR",
11
+ SPEC_DATA_INVALID: "SPEC_DATA_INVALID",
12
+ NETWORK_ERROR: "NETWORK_ERROR",
13
+ AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR",
14
+ SERVER_ERROR: "SERVER_ERROR",
7
15
  };
8
16
  class ComposableStudioError extends Error {
9
17
  id;
@@ -13,15 +21,9 @@ class ComposableStudioError extends Error {
13
21
  this.id = id;
14
22
  this.details = details;
15
23
  }
16
- canFallback() {
17
- return FALLBACK_POSSIBLE_ERRORS.includes(this.id);
18
- }
19
24
  }
20
25
  // This fails for agadoo
21
26
  // ComposableStudioError.prototype.name = "ComposableStudioError";
22
- const FALLBACK_POSSIBLE_ERRORS = [
23
- ComposableStudioErrors.COMPOSITION_NOT_FOUND,
24
- ];
25
27
 
26
- export { ComposableStudioError, ComposableStudioErrors, FALLBACK_POSSIBLE_ERRORS };
28
+ export { ComposableStudioError, ComposableStudioErrors };
27
29
  //# sourceMappingURL=composable-studio-error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"composable-studio-error.js","sources":["../../src/utils/composable-studio-error.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,sBAAsB,GAAG;AACpC,IAAA,qBAAqB,EAAE,uBAAuB;AAC9C,IAAA,8BAA8B,EAAE,gCAAgC;AAChE,IAAA,6BAA6B,EAAE,+BAA+B;AAC9D,IAAA,uBAAuB,EAAE,yBAAyB;AAClD,IAAA,0BAA0B,EAAE,4BAA4B;;AAGpD,MAAO,qBAAsB,SAAQ,KAAK,CAAA;AAC9C,IAAA,EAAE;AACF,IAAA,OAAO;AAEP,IAAA,WAAA,CACE,EAAuC,EACvC,OAAe,EACf,OAAa,EAAA;QAEb,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,EAAE,GAAG,EAAE;AACZ,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;IACxB;IAEA,WAAW,GAAA;QACT,OAAO,wBAAwB,CAAC,QAAQ,CACtC,IAAI,CAAC,EAA+C,CACrD;IACH;AACD;AACD;AACA;AAEO,MAAM,wBAAwB,GAAG;AACtC,IAAA,sBAAsB,CAAC,qBAAqB;;;;;"}
1
+ {"version":3,"file":"composable-studio-error.js","sources":["../../src/utils/composable-studio-error.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,sBAAsB,GAAG;AACpC,IAAA,qBAAqB,EAAE,uBAAuB;AAC9C,IAAA,4BAA4B,EAAE,8BAA8B;AAC5D,IAAA,uBAAuB,EAAE,yBAAyB;AAClD,IAAA,8BAA8B,EAAE,gCAAgC;AAChE,IAAA,6BAA6B,EAAE,+BAA+B;AAC9D,IAAA,uBAAuB,EAAE,yBAAyB;AAClD,IAAA,0BAA0B,EAAE,4BAA4B;AACxD,IAAA,8BAA8B,EAAE,gCAAgC;AAChE,IAAA,gBAAgB,EAAE,kBAAkB;AACpC,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,oBAAoB,EAAE,sBAAsB;AAC5C,IAAA,YAAY,EAAE,cAAc;;AA+BxB,MAAO,qBAAsB,SAAQ,KAAK,CAAA;AAC9C,IAAA,EAAE;AACF,IAAA,OAAO;AAEP,IAAA,WAAA,CACE,EAAuC,EACvC,OAAe,EACf,OAAsC,EAAA;QAEtC,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,EAAE,GAAG,EAAE;AACZ,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;IACxB;AACD;AACD;AACA;;;;"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Keys for error message lookup. Use these constants instead of string literals.
3
+ * @internal
4
+ */
5
+ const ErrorMessageKey = {
6
+ AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR",
7
+ INVALID_CREDENTIALS_DEFAULT: "INVALID_CREDENTIALS_DEFAULT",
8
+ NETWORK_ERROR_EMPTY: "NETWORK_ERROR_EMPTY",
9
+ NETWORK_ERROR_GENERIC: "NETWORK_ERROR_GENERIC",
10
+ NETWORK_ERROR_DETAIL_DEFAULT: "NETWORK_ERROR_DETAIL_DEFAULT",
11
+ COMPOSITION_NOT_FOUND_404: "COMPOSITION_NOT_FOUND_404",
12
+ SERVER_ERROR: "SERVER_ERROR",
13
+ SERVER_ERROR_DETAIL_DEFAULT: "SERVER_ERROR_DETAIL_DEFAULT",
14
+ COMPOSITION_NOT_FOUND_API: "COMPOSITION_NOT_FOUND_API",
15
+ COMPOSITION_NOT_FOUND_API_DETAIL_DEFAULT: "COMPOSITION_NOT_FOUND_API_DETAIL_DEFAULT",
16
+ COMPOSITION_NOT_FOUND_DEFAULT: "COMPOSITION_NOT_FOUND_DEFAULT",
17
+ FETCHING_CONNECTED_DATA_FAILED: "FETCHING_CONNECTED_DATA_FAILED",
18
+ PREVIEW_ENTRY_NOT_FOUND: "PREVIEW_ENTRY_NOT_FOUND",
19
+ STACK_SDK_NOT_AVAILABLE: "STACK_SDK_NOT_AVAILABLE",
20
+ UI_PARSING_ERROR: "UI_PARSING_ERROR",
21
+ COMPOSITION_NOT_FOUND_BY_URL: "COMPOSITION_NOT_FOUND_BY_URL",
22
+ MISSING_COMPOSITION_IDENTIFIER: "MISSING_COMPOSITION_IDENTIFIER",
23
+ };
24
+ /**
25
+ * Default (en) error message templates. Single source of truth for user-facing error messages.
26
+ * Use getErrorMessage() with ErrorMessageKey constants to resolve messages with placeholders.
27
+ * @internal
28
+ */
29
+ const defaultErrorMessages = {
30
+ [ErrorMessageKey.AUTHENTICATION_ERROR]: "Authentication failed: {detail}",
31
+ [ErrorMessageKey.INVALID_CREDENTIALS_DEFAULT]: "Invalid API key or delivery token. Please check your credentials.",
32
+ [ErrorMessageKey.NETWORK_ERROR_EMPTY]: "Network error: Unable to connect to Contentstack API. Please check your internet connection, API endpoint, and credentials.",
33
+ [ErrorMessageKey.NETWORK_ERROR_GENERIC]: "Network error: {detail}",
34
+ [ErrorMessageKey.NETWORK_ERROR_DETAIL_DEFAULT]: "Failed to connect to API",
35
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_404]: "Composition not found. The requested composition does not exist or has been deleted.",
36
+ [ErrorMessageKey.SERVER_ERROR]: "Server error ({statusCode}): {detail}",
37
+ [ErrorMessageKey.SERVER_ERROR_DETAIL_DEFAULT]: "The server encountered an error. Please try again later.",
38
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_API]: "API error ({statusCode}): {detail}",
39
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_API_DETAIL_DEFAULT]: "Failed to fetch composition",
40
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_DEFAULT]: "Composition not found. An unexpected error occurred while fetching the composition.",
41
+ [ErrorMessageKey.FETCHING_CONNECTED_DATA_FAILED]: "Failed to fetch connected data",
42
+ [ErrorMessageKey.PREVIEW_ENTRY_NOT_FOUND]: "Preview entry not found for content type: {contentType}. The connected content type does not have an entry matching the composition query.",
43
+ [ErrorMessageKey.STACK_SDK_NOT_AVAILABLE]: "Stack SDK not available to fetch composition.",
44
+ [ErrorMessageKey.UI_PARSING_ERROR]: "Failed to parse composition UI structure",
45
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_BY_URL]: "Composition not found for URL: {url}. No composition matches the provided URL pattern.",
46
+ [ErrorMessageKey.MISSING_COMPOSITION_IDENTIFIER]: "Please provide either composableUid or url to fetch the composition.",
47
+ };
48
+ /**
49
+ * Keys for troubleshooting info lookup. Use with getTroubleshootingInfo().
50
+ * @internal
51
+ */
52
+ const TroubleshootingInfoKey = {
53
+ NETWORK_ERROR: "NETWORK_ERROR",
54
+ AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR",
55
+ COMPOSITION_NOT_FOUND_URL: "COMPOSITION_NOT_FOUND_URL",
56
+ COMPOSITION_NOT_FOUND_UID: "COMPOSITION_NOT_FOUND_UID",
57
+ PREVIEW_ENTRY_NOT_FOUND: "PREVIEW_ENTRY_NOT_FOUND",
58
+ };
59
+ /**
60
+ * Default (en) troubleshooting info by key. Single source of truth for cause/fix strings.
61
+ * @internal
62
+ */
63
+ const defaultTroubleshootingInfo = {
64
+ [TroubleshootingInfoKey.NETWORK_ERROR]: [
65
+ {
66
+ cause: "Network connectivity issue",
67
+ fix: "Check your internet connection and try again. Verify that the API endpoint is accessible.",
68
+ },
69
+ {
70
+ cause: "Invalid API credentials",
71
+ fix: "Verify your API key and delivery token are correct in the SDK configuration.",
72
+ },
73
+ {
74
+ cause: "Incorrect API endpoint",
75
+ fix: "Ensure the API endpoint URL is correct and points to the right Contentstack region.",
76
+ },
77
+ ],
78
+ [TroubleshootingInfoKey.AUTHENTICATION_ERROR]: [
79
+ {
80
+ cause: "Invalid API key",
81
+ fix: "Verify your API key is correct and has the necessary permissions. Check your Contentstack dashboard for the correct API key.",
82
+ },
83
+ {
84
+ cause: "Invalid delivery token",
85
+ fix: "Ensure your delivery token is valid and not expired. Generate a new token if needed.",
86
+ },
87
+ {
88
+ cause: "Missing permissions",
89
+ fix: "Check that your API credentials have the required permissions to access the content type and entries.",
90
+ },
91
+ ],
92
+ [TroubleshootingInfoKey.COMPOSITION_NOT_FOUND_URL]: [
93
+ {
94
+ cause: "No composition found for this URL",
95
+ fix: "Verify the URL is correct and matches an existing composition. Check that the composition is published and accessible.",
96
+ },
97
+ {
98
+ cause: "URL pattern does not match any composition",
99
+ fix: "Ensure the URL pattern in your composition matches the requested URL. Check the composition's URL field in Contentstack.",
100
+ },
101
+ {
102
+ cause: "Composition not published",
103
+ fix: "Publish the composition in Contentstack or use a preview/draft token to access unpublished content.",
104
+ },
105
+ ],
106
+ [TroubleshootingInfoKey.COMPOSITION_NOT_FOUND_UID]: [
107
+ {
108
+ cause: "Composition does not exist",
109
+ fix: "Verify the composition UID is correct. Check that the composition exists in your Contentstack stack.",
110
+ },
111
+ {
112
+ cause: "Composition UID is incorrect",
113
+ fix: "Double-check the composition UID you're using. You can find the correct UID on the composition listing page in studio",
114
+ },
115
+ {
116
+ cause: "Composition not published",
117
+ fix: "Publish the composition in Contentstack or use a preview/draft token to access unpublished content.",
118
+ },
119
+ ],
120
+ [TroubleshootingInfoKey.PREVIEW_ENTRY_NOT_FOUND]: [
121
+ {
122
+ cause: "No entry exists for the connected content type",
123
+ fix: "Create an entry for the connected content type in Contentstack, or verify the content type is correctly configured.",
124
+ },
125
+ {
126
+ cause: "URL pattern does not match any entry",
127
+ fix: "Ensure the URL in your composition query matches the URL field of an entry in the connected content type.",
128
+ },
129
+ {
130
+ cause: "Entry was deleted or unpublished",
131
+ fix: "Check if the entry exists and is published. Restore it from trash if deleted, or publish it if it's in draft state.",
132
+ },
133
+ {
134
+ cause: "Incorrect content type configuration",
135
+ fix: "Verify that the connected_content_type field in your composition is set to the correct content type UID.",
136
+ },
137
+ ],
138
+ };
139
+
140
+ export { ErrorMessageKey, TroubleshootingInfoKey, defaultErrorMessages, defaultTroubleshootingInfo };
141
+ //# sourceMappingURL=error-messages.default.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-messages.default.js","sources":["../../src/utils/error-messages.default.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AACI,MAAM,eAAe,GAAG;AAC7B,IAAA,oB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AsB,CAAC,yBAAyB,GAAG;AAClD,QAAA;AACE,YAAA,KAAK,EAAE,mCAAmC;AAC1C,YAAA,GAAG,EAAE,wHAAwH;AAC9H,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,4CAA4C;AACnD,YAAA,GAAG,EAAE,0HAA0H;AAChI,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,2BAA2B;AAClC,YAAA,GAAG,EAAE,qGAAqG;AAC3G,SAAA;AACF,KAAA;AACD,IAAA,CAAC,sBAAsB,CAAC,yBAAyB,GAAG;AAClD,QAAA;AACE,YAAA,KAAK,EAAE,4BAA4B;AACnC,YAAA,GAAG,EAAE,sGAAsG;AAC5G,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,8BAA8B;AACrC,YAAA,GAAG,EAAE,uHAAuH;AAC7H,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,2BAA2B;AAClC,YAAA,GAAG,EAAE,qGAAqG;AAC3G,SAAA;AACF,KAAA;AACD,IAAA,CAAC,sBAAsB,CAAC,uBAAuB,GAAG;AAChD,QAAA;AACE,YAAA,KAAK,EAAE,gDAAgD;AACvD,YAAA,GAAG,EAAE,qHAAqH;AAC3H,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,sCAAsC;AAC7C,YAAA,GAAG,EAAE,2GAA2G;AACjH,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,kCAAkC;AACzC,YAAA,GAAG,EAAE,qHAAqH;AAC3H,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,sCAAsC;AAC7C,YAAA,GAAG,EAAE,0GAA0G;AAChH,SAAA;AACF,KAAA;;;;;"}
@@ -0,0 +1,47 @@
1
+ import { defaultErrorMessages, defaultTroubleshootingInfo } from './error-messages.default.js';
2
+ export { ErrorMessageKey, TroubleshootingInfoKey } from './error-messages.default.js';
3
+
4
+ /**
5
+ * Error message lookup for studio-client. Messages are defined in error-messages.default.ts.
6
+ * Use getErrorMessage with ErrorMessageKey constants (no string literals).
7
+ * @internal
8
+ */
9
+ /**
10
+ * Returns the message string for the given key, substituting placeholders with params.
11
+ * Placeholders: {detail}, {statusCode}, {url}
12
+ * Use ErrorMessageKey constants for the key argument.
13
+ * @internal
14
+ */
15
+ function getErrorMessage(key, params) {
16
+ let template = defaultErrorMessages[key];
17
+ if (template == null) {
18
+ return String(key);
19
+ }
20
+ if (!params) {
21
+ return template;
22
+ }
23
+ if (params.detail !== undefined) {
24
+ template = template.replace(/\{detail\}/g, String(params.detail));
25
+ }
26
+ if (params.statusCode !== undefined) {
27
+ template = template.replace(/\{statusCode\}/g, String(params.statusCode));
28
+ }
29
+ if (params.url !== undefined) {
30
+ template = template.replace(/\{url\}/g, String(params.url));
31
+ }
32
+ if (params.contentType !== undefined) {
33
+ template = template.replace(/\{contentType\}/g, String(params.contentType));
34
+ }
35
+ return template;
36
+ }
37
+ /**
38
+ * Returns troubleshooting info (cause/fix pairs) for the given key.
39
+ * Use TroubleshootingInfoKey constants. Return type is compatible with TroubleshootingInfo[].
40
+ * @internal
41
+ */
42
+ function getTroubleshootingInfo(key) {
43
+ return defaultTroubleshootingInfo[key] ?? [];
44
+ }
45
+
46
+ export { getErrorMessage, getTroubleshootingInfo };
47
+ //# sourceMappingURL=error-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-messages.js","sources":["../../src/utils/error-messages.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;AAIG;AAyBH;;;;;AAKG;AACG,SAAU,eAAe,CAC7B,GAAwB,EACxB,MAA2B,EAAA;AAE3B,IAAA,IAAI,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC;AACxC,IAAA,IAAI,QAAQ,IAAI,IAAI,EAAE;AACpB,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB;IACA,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;AAC/B,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnE;AACA,IAAA,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE;AACnC,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3E;AACA,IAAA,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,EAAE;AAC5B,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D;AACA,IAAA,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE;AACpC,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7E;AACA,IAAA,OAAO,QAAQ;AACjB;AAEA;;;;AAIG;AACG,SAAU,sBAAsB,CACpC,GAA+B,EAAA;AAE/B,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC,IAAI,EAAE;AAC9C;;;;"}
@@ -33,7 +33,6 @@ function getUrlPatterns(pathname) {
33
33
  }
34
34
  patterns.add(prefix + temp.join("/"));
35
35
  }
36
- console.log("patterns", Array.from(patterns));
37
36
  return Array.from(patterns);
38
37
  }
39
38
 
@@ -1 +1 @@
1
- {"version":3,"file":"get-url-patterns.js","sources":["../../src/utils/get-url-patterns.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AACG,SAAU,cAAc,CAAC,QAAgB,EAAA;IAC7C,MAAM,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;IAChD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC,QAAQ;AACjE,IAAA,MAAM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C;IACvC;AAEA,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC7B;;;;"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * HTTP status code constants and helpers for error classification.
3
+ * @internal
4
+ */
5
+ const HttpStatus = {
6
+ UNAUTHORIZED: 401,
7
+ FORBIDDEN: 403,
8
+ NOT_FOUND: 404,
9
+ SERVER_ERROR_MIN: 500,
10
+ SERVER_ERROR_MAX: 599,
11
+ };
12
+ /**
13
+ * Contentstack API error codes (from Contentstack API responses).
14
+ * @internal
15
+ */
16
+ const ContentstackErrorCode = {
17
+ UNAUTHORIZED: 104,
18
+ INVALID_CREDENTIALS: 105,
19
+ ENTRY_NOT_FOUND: 141,
20
+ };
21
+ /**
22
+ * Node.js / network error codes that indicate connection failures.
23
+ * @internal
24
+ */
25
+ const NetworkErrorCode = {
26
+ ENOTFOUND: "ENOTFOUND",
27
+ ECONNREFUSED: "ECONNREFUSED",
28
+ ETIMEDOUT: "ETIMEDOUT",
29
+ };
30
+ const NETWORK_ERROR_CODES = [
31
+ NetworkErrorCode.ENOTFOUND,
32
+ NetworkErrorCode.ECONNREFUSED,
33
+ NetworkErrorCode.ETIMEDOUT,
34
+ ];
35
+ const NETWORK_ERROR_TYPE = "network";
36
+ /**
37
+ * Returns the HTTP status code from an error object (supports both status and statusCode).
38
+ * @internal
39
+ */
40
+ function getStatusCode(err) {
41
+ const code = err?.status ?? err?.statusCode;
42
+ return typeof code === "number" && Number.isFinite(code) ? code : undefined;
43
+ }
44
+ /**
45
+ * Returns true if the status code indicates an authentication/authorization error (401 or 403).
46
+ * @internal
47
+ */
48
+ function isAuthError(statusCode) {
49
+ return (statusCode === HttpStatus.UNAUTHORIZED ||
50
+ statusCode === HttpStatus.FORBIDDEN);
51
+ }
52
+ /**
53
+ * Returns true if the status code indicates a server error (5xx).
54
+ * @internal
55
+ */
56
+ function isServerError(statusCode) {
57
+ return (statusCode >= HttpStatus.SERVER_ERROR_MIN &&
58
+ statusCode <= HttpStatus.SERVER_ERROR_MAX);
59
+ }
60
+ /**
61
+ * Returns true if the error is a Contentstack auth error by error_code (104 or 105).
62
+ * @internal
63
+ */
64
+ function isContentstackAuthError(err) {
65
+ const code = err?.error_code;
66
+ return (code === ContentstackErrorCode.UNAUTHORIZED ||
67
+ code === ContentstackErrorCode.INVALID_CREDENTIALS);
68
+ }
69
+ /**
70
+ * Returns true if the error has Contentstack auth error shape (errors.api_key or errors.authorization)
71
+ * without necessarily having an HTTP status. Used when API returns auth failure in body only.
72
+ * @internal
73
+ */
74
+ function hasAuthErrorShape(err) {
75
+ if (!err || typeof err !== "object")
76
+ return false;
77
+ const apiKey = err?.errors?.api_key;
78
+ const auth = err?.errors?.authorization;
79
+ return ((Array.isArray(apiKey) && apiKey.length > 0) ||
80
+ (Array.isArray(auth) && auth.length > 0));
81
+ }
82
+ /**
83
+ * Returns true if the error indicates a network-level failure (no HTTP response).
84
+ * @internal
85
+ */
86
+ function isNetworkError(err) {
87
+ if (!err)
88
+ return false;
89
+ const code = err?.code;
90
+ const type = err?.type;
91
+ return ((typeof code === "string" && NETWORK_ERROR_CODES.includes(code)) ||
92
+ type === NETWORK_ERROR_TYPE);
93
+ }
94
+
95
+ export { ContentstackErrorCode, HttpStatus, NETWORK_ERROR_CODES, NETWORK_ERROR_TYPE, NetworkErrorCode, getStatusCode, hasAuthErrorShape, isAuthError, isContentstackAuthError, isNetworkError, isServerError };
96
+ //# sourceMappingURL=http-error.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-error.constants.js","sources":["../../src/utils/http-error.constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AAEI,MAAM,UAAU,GAAG;AACxB,IAAA,YAAY,EAAE,GAAG;AACjB,IAAA,SAAS,EAAE,GAAG;AACd,IAAA,SAAS,EAAE,GAAG;AACd,IAAA,gBAAgB,EAAE,GAAG;AACrB,IAAA,gBAAgB,EAAE,GAAG;;AAGvB;;;AAGG;AACI,MAAM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AI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,KAAK;AACjD,IAAA,MAAM,MAAM,GAAG,GAAG,EAAE,MAAM,EAAE,OAAO;AACnC,IAAA,MAAM,IAAI,GAAG,GAAG,EAAE,MAAM,EAAE,aAAa;AACvC,IAAA,QACE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;AAC3C,SAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AAE5C;AAEA;;;AAGG;AACG,SAAU,cAAc,CAAC,GAAQ,EAAA;AACrC,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,KAAK;AACtB,IAAA,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI;AACtB,IAAA,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI;AACtB,IAAA,QACE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,mBAAmB,CAAC,QAAQ,CAAC,IAAW,CAAC;QACtE,IAAI,KAAK,kBAAkB;AAE/B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-client",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -30,15 +30,16 @@
30
30
  "url": "https://github.com/contentstack/composable-studio-sdk/issues"
31
31
  },
32
32
  "devDependencies": {
33
- "@contentstack/common-config": "^1.1.3",
33
+ "@contentstack/common-config": "^1.1.5",
34
34
  "@contentstack/delivery-sdk": "^4.5.0",
35
- "@contentstack/studio-internal": "^1.1.3",
35
+ "@contentstack/studio-internal": "^1.1.5",
36
36
  "@rollup/plugin-commonjs": "^28.0.6",
37
37
  "@rollup/plugin-node-resolve": "^16.0.1",
38
38
  "@rollup/plugin-terser": "^0.4.4",
39
39
  "@rollup/plugin-typescript": "^12.1.4",
40
40
  "contentstack": "^3.20.3",
41
41
  "happy-dom": "^20.0.1",
42
+ "msw": "^2.12.9",
42
43
  "rollup": "^4.46.2",
43
44
  "rollup-plugin-dts": "^6.2.1",
44
45
  "rollup-plugin-node-externals": "^8.0.1",
@@ -46,13 +47,13 @@
46
47
  "typescript": "^5.5.4"
47
48
  },
48
49
  "dependencies": {
49
- "@contentstack/studio-message-types": "^1.1.3",
50
- "@contentstack/studio-messenger": "^1.1.3",
51
- "@contentstack/studio-registry": "^1.2.0",
50
+ "@contentstack/studio-message-types": "^1.1.5",
51
+ "@contentstack/studio-messenger": "^1.2.0",
52
+ "@contentstack/studio-registry": "^1.3.0",
52
53
  "eventemitter3": "^5.0.1",
53
54
  "html2canvas": "^1.4.1",
54
- "lodash-es": "^4.17.21",
55
+ "lodash-es": "^4.17.23",
55
56
  "zod": "^3.23.8"
56
57
  },
57
- "gitHead": "72726052f099c6a4cd39b1fcbc1bfe97f64ab130"
58
+ "gitHead": "6739518a282ff9788218b0acd2e46e0be2a6fb68"
58
59
  }