@contentstack/studio-client 1.3.0 → 1.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.
Files changed (54) hide show
  1. package/dist/breakpoints/BreakpointManager.js +0 -1
  2. package/dist/breakpoints/BreakpointManager.js.map +1 -1
  3. package/dist/composable-studio/initializer-sdk.js +1 -10
  4. package/dist/composable-studio/initializer-sdk.js.map +1 -1
  5. package/dist/composable-studio/sdk.js +448 -127
  6. package/dist/composable-studio/sdk.js.map +1 -1
  7. package/dist/config/config.schema.js +11 -0
  8. package/dist/config/config.schema.js.map +1 -1
  9. package/dist/config/default-config.js +1 -0
  10. package/dist/config/default-config.js.map +1 -1
  11. package/dist/config/process-user-config.js +10 -1
  12. package/dist/config/process-user-config.js.map +1 -1
  13. package/dist/config/stack-sdk-wrapper.js +52 -12
  14. package/dist/config/stack-sdk-wrapper.js.map +1 -1
  15. package/dist/context-menu/context-menu.js +0 -1
  16. package/dist/context-menu/context-menu.js.map +1 -1
  17. package/dist/design/handle-active-style-change.js +0 -1
  18. package/dist/design/handle-active-style-change.js.map +1 -1
  19. package/dist/dnd/dnd-manager.js +2 -3
  20. package/dist/dnd/dnd-manager.js.map +1 -1
  21. package/dist/highlight-node/highlight-node-manager.js +0 -1
  22. package/dist/highlight-node/highlight-node-manager.js.map +1 -1
  23. package/dist/highlight-node/highlight-node.js +30 -14
  24. package/dist/highlight-node/highlight-node.js.map +1 -1
  25. package/dist/index.d.ts +249 -25
  26. package/dist/index.js +6 -3
  27. package/dist/index.js.map +1 -1
  28. package/dist/node_modules/fflate/esm/browser.js +384 -0
  29. package/dist/node_modules/fflate/esm/browser.js.map +1 -0
  30. package/dist/packages/studio-internal/dist/utils/spec-compression.js +43 -0
  31. package/dist/packages/studio-internal/dist/utils/spec-compression.js.map +1 -0
  32. package/dist/query/expression-resolver.js +124 -0
  33. package/dist/query/expression-resolver.js.map +1 -0
  34. package/dist/query/query-executor.js +327 -0
  35. package/dist/query/query-executor.js.map +1 -0
  36. package/dist/url-change/url-change.js +65 -0
  37. package/dist/url-change/url-change.js.map +1 -0
  38. package/dist/utils/composable-studio-error.js +9 -7
  39. package/dist/utils/composable-studio-error.js.map +1 -1
  40. package/dist/utils/conditionBlock.js +16 -4
  41. package/dist/utils/conditionBlock.js.map +1 -1
  42. package/dist/utils/error-messages.default.js +141 -0
  43. package/dist/utils/error-messages.default.js.map +1 -0
  44. package/dist/utils/error-messages.js +47 -0
  45. package/dist/utils/error-messages.js.map +1 -0
  46. package/dist/utils/http-error.constants.js +96 -0
  47. package/dist/utils/http-error.constants.js.map +1 -0
  48. package/dist/utils/is-inside-iframe.js +16 -0
  49. package/dist/utils/is-inside-iframe.js.map +1 -0
  50. package/dist/utils/reference_fetcher.js +104 -8
  51. package/dist/utils/reference_fetcher.js.map +1 -1
  52. package/dist/utils/sdk.js +3 -0
  53. package/dist/utils/sdk.js.map +1 -1
  54. package/package.json +9 -8
package/dist/index.d.ts CHANGED
@@ -1,15 +1,14 @@
1
1
  import * as _contentstack_studio_internal from '@contentstack/studio-internal';
2
- import { Node, PathNode, Path, Descendant, Operation, BindingType, Condition, NodeStyles } from '@contentstack/studio-internal';
2
+ import { Node, PathNode, Path, Operation, Descendant, BindingType, Condition, NodeStyles } from '@contentstack/studio-internal';
3
3
  import * as _contentstack_studio_registry from '@contentstack/studio-registry';
4
- import { StudioSpecData, RawStaticValue, ICSEntryReference, StaticValue, BreakpointInput, Breakpoint } from '@contentstack/studio-registry';
4
+ import { RawStaticValue, ICSEntryReference, StudioSpecData, StaticValue, BreakpointInput, Breakpoint } from '@contentstack/studio-registry';
5
5
  export { Breakpoint } from '@contentstack/studio-registry';
6
6
  import * as _contentstack_studio_messenger from '@contentstack/studio-messenger';
7
- import { CompositionQueryInput, ComposableStudioQueryParams, CompositionQuery, ComposableStudioQueryParamsKeys, HiddenElementNotificationEventData, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
7
+ import { CompositionQuery, CompositionQueryInput, ComposableStudioQueryParams, ComposableStudioQueryParamsKeys, HiddenElementNotificationEventData, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
8
8
  export { IS_BROWSER } from '@contentstack/studio-messenger';
9
9
  import { z } from 'zod';
10
10
  import deliverySdk, { BaseAsset } from '@contentstack/delivery-sdk';
11
11
  import { Stack } from 'contentstack';
12
- import { InitMessage } from '@contentstack/studio-message-types/base';
13
12
  import { HitboxDetails, SerializedEvent, RefetchSpecEventData, ApplySymbolOperationEventData } from '@contentstack/studio-message-types/latest';
14
13
  export { ActiveBreakpointEventPayload, BaseHighlightEventPayload, ChangeActiveStyleGroupPayload, ComputedStyleSection, DraggerPosition, HighlightActiveNodeEventPayload, HighlightAncestorsEventPayload, HighlightFocusedNodeEventPayload, HighlightNodeEventPayload, HighlightSlotNodeEventPayload, HighlightStyleNodeEventPayload, HitboxDetails, MouseMoveEventPayload, MouseUpEventPayload, RefetchSpecEventData, RequestHighlightNodeEventPayload, SetCursorTypeEventPayload, TARGET_NODE, UpdateStyleEventPayload, ValidatePropEventPayload, handleActiveNodePayload, handleActiveSlotNode, handleFocusedNodePayload } from '@contentstack/studio-message-types/latest';
15
14
  import { EventEmitter } from 'eventemitter3';
@@ -25,6 +24,7 @@ declare const userConfigSchema: z.ZodObject<{
25
24
  */
26
25
  contentTypeUid: z.ZodOptional<z.ZodString>;
27
26
  stackSdk: z.ZodType<any, z.ZodTypeDef, any>;
27
+ locale: z.ZodOptional<z.ZodString>;
28
28
  cslp: z.ZodOptional<z.ZodObject<{
29
29
  appendTags: z.ZodOptional<z.ZodBoolean>;
30
30
  }, "strip", z.ZodTypeAny, {
@@ -42,9 +42,12 @@ declare const userConfigSchema: z.ZodObject<{
42
42
  enable?: boolean | undefined;
43
43
  position?: "top" | "top-left" | "top-right" | "top-center" | "bottom" | "bottom-left" | "bottom-right" | "bottom-center" | undefined;
44
44
  }>>;
45
+ fetchComposition: z.ZodOptional<z.ZodType<CompositionFetcher, z.ZodTypeDef, CompositionFetcher>>;
46
+ fetchTemplateEntry: z.ZodOptional<z.ZodType<TemplateEntryFetcher, z.ZodTypeDef, TemplateEntryFetcher>>;
45
47
  }, "strip", z.ZodTypeAny, {
46
48
  contentTypeUid?: string | undefined;
47
49
  stackSdk?: any;
50
+ locale?: string | undefined;
48
51
  cslp?: {
49
52
  appendTags?: boolean | undefined;
50
53
  } | undefined;
@@ -52,9 +55,12 @@ declare const userConfigSchema: z.ZodObject<{
52
55
  enable?: boolean | undefined;
53
56
  position?: "top" | "top-left" | "top-right" | "top-center" | "bottom" | "bottom-left" | "bottom-right" | "bottom-center" | undefined;
54
57
  } | undefined;
58
+ fetchComposition?: CompositionFetcher | undefined;
59
+ fetchTemplateEntry?: TemplateEntryFetcher | undefined;
55
60
  }, {
56
61
  contentTypeUid?: string | undefined;
57
62
  stackSdk?: any;
63
+ locale?: string | undefined;
58
64
  cslp?: {
59
65
  appendTags?: boolean | undefined;
60
66
  } | undefined;
@@ -62,13 +68,16 @@ declare const userConfigSchema: z.ZodObject<{
62
68
  enable?: boolean | undefined;
63
69
  position?: "top" | "top-left" | "top-right" | "top-center" | "bottom" | "bottom-left" | "bottom-right" | "bottom-center" | undefined;
64
70
  } | undefined;
71
+ fetchComposition?: CompositionFetcher | undefined;
72
+ fetchTemplateEntry?: TemplateEntryFetcher | undefined;
65
73
  }>;
66
74
 
67
75
  type JSStack = Stack;
68
76
  type TSStack = ReturnType<(typeof deliverySdk)["stack"]>;
69
77
  declare class StackSDK {
70
78
  sdk: JSStack | TSStack;
71
- constructor(sdk: JSStack | TSStack);
79
+ private _locale?;
80
+ constructor(sdk: JSStack | TSStack, locale?: string);
72
81
  isJavaScriptSDK(sdk: Stack | ReturnType<(typeof deliverySdk)["stack"]>): sdk is Stack;
73
82
  livePreviewQuery(livePreviewHash: string): void;
74
83
  ctQuery(contentTypeUid: string, options?: {
@@ -77,11 +86,13 @@ declare class StackSDK {
77
86
  references?: string[];
78
87
  only?: [string, string][];
79
88
  variantAlias?: string;
89
+ locale?: string;
80
90
  query?: Record<string, any>;
81
91
  }): any;
82
92
  entryQuery(contentTypeUid: string, entryUID: string, options?: {
83
93
  only?: [string, string][];
84
94
  variantAlias?: string;
95
+ locale?: string;
85
96
  }): any;
86
97
  private isJsQuery;
87
98
  where(query: ReturnType<StackSDK["ctQuery"]>, field: string, value: any): any;
@@ -91,10 +102,14 @@ declare class StackSDK {
91
102
  preview_token?: string;
92
103
  enable?: boolean;
93
104
  } | undefined;
105
+ get locale(): string | undefined;
94
106
  }
95
107
 
96
- interface Config extends DeepRequired<Omit<UserConfig, "stackSdk">> {
108
+ interface Config extends DeepRequired<Omit<UserConfig, "stackSdk" | "locale" | "fetchComposition" | "fetchTemplateEntry">> {
97
109
  stackSdk: StackSDK;
110
+ locale?: string;
111
+ fetchComposition?: CompositionFetcher;
112
+ fetchTemplateEntry?: TemplateEntryFetcher;
98
113
  }
99
114
  type LightConfig = Pick<Config, "openInStudioButton" | "contentTypeUid" | "cslp">;
100
115
  type UserConfig = z.infer<typeof userConfigSchema>;
@@ -202,13 +217,109 @@ type CompositionQueryOptions = {
202
217
  * Support for fetching data of a specified variant.
203
218
  */
204
219
  variantAlias?: string;
220
+ /**
221
+ * Override the default stack locale for this specific query.
222
+ * If provided, this locale will be used instead of the stack config locale.
223
+ * Automatically includes fallback support via Contentstack's native fallback mechanism.
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * // Fetch composition in French instead of default locale
228
+ * useCompositionData({ compositionUid: "blt123" }, { locale: "fr" })
229
+ * ```
230
+ */
231
+ locale?: string;
205
232
  extendQuery?: {
206
233
  [ct_uid: string]: {
207
234
  includeReferences?: string[];
208
235
  only?: (string | [string, string])[];
209
236
  };
210
237
  };
238
+ /**
239
+ * UID of a specific entry in the connected content type to use
240
+ * as the template/preview entry.
241
+ *
242
+ * When provided, the SDK fetches this exact entry instead of
243
+ * resolving by URL or grabbing the first available entry.
244
+ *
245
+ * Resolution priority: templateEntryUid > url > first entry (limit 1)
246
+ */
247
+ templateEntryUid?: string;
248
+ /**
249
+ * Per-query composition fetcher override. Takes precedence over global.
250
+ * Return the composition entry, null for not-found, or call `defaultFetch()`.
251
+ */
252
+ fetchComposition?: CompositionFetcher;
253
+ /**
254
+ * Per-query template entry fetcher override. Takes precedence over global.
255
+ * Return the entry, null for not-found, or call `defaultFetch()`.
256
+ */
257
+ fetchTemplateEntry?: TemplateEntryFetcher;
211
258
  };
259
+ /**
260
+ * CompositionQueryOptions with fetcher callbacks stripped.
261
+ * Passed to custom fetchers via the `options` field.
262
+ * Automatically picks up any future additions to CompositionQueryOptions.
263
+ */
264
+ type ResolvedQueryOptions = Omit<CompositionQueryOptions, "fetchComposition" | "fetchTemplateEntry">;
265
+ /**
266
+ * Context provided to a custom composition fetcher.
267
+ */
268
+ interface FetchCompositionContext {
269
+ /** The query input — has composableUid, url, or both */
270
+ compositionQuery: CompositionQuery;
271
+ /** The content type UID where compositions are stored */
272
+ contentTypeUid: string;
273
+ /** All query options (locale, variantAlias, extendQuery, templateEntryUid, + future) */
274
+ options: ResolvedQueryOptions;
275
+ /** The raw Contentstack SDK instance passed to studioSdk.init() */
276
+ stackSdk: any;
277
+ /**
278
+ * Calls the SDK's default composition fetching logic.
279
+ * Use this to: conditionally fall through, wrap/decorate, inspect/transform.
280
+ */
281
+ defaultFetch: () => Promise<CompositionEntry>;
282
+ }
283
+ /**
284
+ * Context provided to a custom template entry fetcher.
285
+ */
286
+ interface FetchTemplateEntryContext {
287
+ /** The already-fetched composition entry */
288
+ compositionEntry: CompositionEntry;
289
+ /** The original query (has composableUid, url, or both) */
290
+ compositionQuery: CompositionQuery;
291
+ /** The content type UID that this composition is linked to */
292
+ connectedContentType: string;
293
+ /** All query options (locale, variantAlias, extendQuery, templateEntryUid, + future) */
294
+ options: ResolvedQueryOptions;
295
+ /**
296
+ * SDK-computed reference field paths from UI tree bindings + options.extendQuery.
297
+ * e.g., ["author", "categories", "related_posts.author"]
298
+ */
299
+ includeReferences: string[];
300
+ /**
301
+ * SDK-computed field projections from UI tree bindings + options.extendQuery.
302
+ * Empty when inside Visual Builder (all fields fetched).
303
+ */
304
+ only: [string, string][];
305
+ /** The raw Contentstack SDK instance passed to studioSdk.init() */
306
+ stackSdk: any;
307
+ /**
308
+ * Calls the SDK's default template entry fetching logic.
309
+ * Uses templateEntryUid > url > first entry resolution.
310
+ */
311
+ defaultFetch: () => Promise<any>;
312
+ }
313
+ /**
314
+ * User-provided fetcher for compositions.
315
+ * Return the composition entry, null for not-found, or call defaultFetch().
316
+ */
317
+ type CompositionFetcher = (context: FetchCompositionContext) => Promise<CompositionEntry | null>;
318
+ /**
319
+ * User-provided fetcher for template entries.
320
+ * Return the entry, null for not-found, or call defaultFetch().
321
+ */
322
+ type TemplateEntryFetcher = (context: FetchTemplateEntryContext) => Promise<any | null>;
212
323
  /**
213
324
  * The query string we get after running URLSearchParams.toString()
214
325
  */
@@ -271,14 +382,14 @@ declare const studioSdk: {
271
382
  getConfig(): Config;
272
383
  isInsideStudioFrame: () => boolean;
273
384
  fetchSpec: (queryOptions: _contentstack_studio_messenger.CompositionQuery, options?: CompositionQueryOptions) => Promise<StudioSpec>;
274
- fetchTemplateEntry: (options: {
385
+ fetchData: (compositionEntry: CompositionEntry, queryOptions: _contentstack_studio_messenger.CompositionQuery, options?: CompositionQueryOptions) => Promise<_contentstack_studio_registry.StudioSpecData>;
386
+ fetchTemplateEntry: (fetchOptions: {
275
387
  connected_content_type: string;
276
388
  compositionQuery: _contentstack_studio_messenger.CompositionQuery;
277
389
  includeQueries: string[];
278
390
  onlyQueries: [string, string][];
279
391
  composableUid: string;
280
- variantAlias?: string;
281
- }, data: _contentstack_studio_registry.StudioSpecData) => Promise<void>;
392
+ }, data: _contentstack_studio_registry.StudioSpecData, compositionEntry: CompositionEntry, compositionQueryOptions?: CompositionQueryOptions) => Promise<void>;
282
393
  getSeoMetadata: (ui: _contentstack_studio_internal.Node) => SeoMetadata;
283
394
  };
284
395
  public: {
@@ -292,7 +403,6 @@ declare const studioSdk: {
292
403
  };
293
404
  };
294
405
  };
295
- declare const sendInitMessage: (message: InitMessage) => void;
296
406
 
297
407
  declare const ELEMENT_TO_NODE: WeakMap<HTMLElement, any>;
298
408
  declare const NODE_TO_ELEMENT: WeakMap<any, HTMLElement>;
@@ -367,8 +477,8 @@ declare class DNDManager {
367
477
  hasMoved: boolean;
368
478
  mouseDown: boolean;
369
479
  constructor();
370
- handleMouseDown(e: MouseEvent): void;
371
- handleMouseUp(e: MouseEvent): void;
480
+ handleMouseDown(_e: MouseEvent): void;
481
+ handleMouseUp(_e: MouseEvent): void;
372
482
  handleMouseLeave(e: MouseEvent): void;
373
483
  start(e: MouseEvent): void;
374
484
  startParent(): void;
@@ -398,6 +508,7 @@ declare const calculateDynamicSpeed: (distance: number, padding: number, maxSpee
398
508
 
399
509
  declare function handleOnScroll(): void;
400
510
  declare function handleResize(): void;
511
+ declare const isModKey: (e: MouseEvent | KeyboardEvent) => boolean;
401
512
  declare function addHighlightNodeEventListeners(): {
402
513
  removeEventListeners: () => void;
403
514
  } | undefined;
@@ -495,6 +606,15 @@ declare class HighlightNodeManager {
495
606
  }
496
607
  declare const highlightNodeManager: HighlightNodeManager;
497
608
 
609
+ /**
610
+ * Listens for URL changes inside the iframe (SPA navigations, pushState, replaceState, popstate)
611
+ * and sends URL_CHANGE postMessage to the parent so the studio can sync the navbar URL.
612
+ * Uses Navigation API when available, with popstate + history monkey-patch fallback.
613
+ */
614
+ declare function addUrlChangeListeners(): {
615
+ removeEventListeners: () => void;
616
+ } | undefined;
617
+
498
618
  declare function addHighlightSpacingEventListeners(): {
499
619
  removeEventListeners: () => void;
500
620
  } | undefined;
@@ -542,26 +662,58 @@ declare function entriesFromResponse<T>(response: EntriesResponse<T>): T[];
542
662
 
543
663
  declare const isInsideVisualBuilderFrame: () => boolean;
544
664
 
665
+ /**
666
+ * Checks if the current context is inside an iframe.
667
+ *
668
+ * @returns {boolean} True if inside an iframe, false otherwise.
669
+ */
670
+ declare const isInsideIframe: () => boolean;
671
+
545
672
  declare const ComposableStudioErrors: {
546
673
  readonly COMPOSITION_NOT_FOUND: "COMPOSITION_NOT_FOUND";
674
+ readonly COMPOSITION_NOT_FOUND_BY_URL: "COMPOSITION_NOT_FOUND_BY_URL";
675
+ readonly PREVIEW_ENTRY_NOT_FOUND: "PREVIEW_ENTRY_NOT_FOUND";
547
676
  readonly FETCHING_CONNECTED_DATA_FAILED: "FETCHING_CONNECTED_DATA_FAILED";
548
677
  readonly RESOLVING_DATA_SOURCES_FAILED: "RESOLVING_DATA_SOURCES_FAILED";
549
678
  readonly STACK_SDK_NOT_AVAILABLE: "STACK_SDK_NOT_AVAILABLE";
550
679
  readonly INVALID_FETCH_SPEC_OPTIONS: "INVALID_FETCH_SPEC_OPTIONS";
680
+ readonly MISSING_COMPOSITION_IDENTIFIER: "MISSING_COMPOSITION_IDENTIFIER";
681
+ readonly UI_PARSING_ERROR: "UI_PARSING_ERROR";
682
+ readonly SPEC_DATA_INVALID: "SPEC_DATA_INVALID";
683
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
684
+ readonly AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR";
685
+ readonly SERVER_ERROR: "SERVER_ERROR";
551
686
  };
552
- declare class ComposableStudioError extends Error {
553
- id: keyof typeof ComposableStudioErrors;
554
- details: any;
555
- constructor(id: keyof typeof ComposableStudioErrors, message: string, details?: any);
556
- canFallback(): boolean;
687
+ /**
688
+ * Information about a possible cause of an error and how to fix it
689
+ */
690
+ interface TroubleshootingInfo {
691
+ /**
692
+ * Description of the possible cause of the error
693
+ */
694
+ cause: string;
695
+ /**
696
+ * Suggested fix or resolution for this cause
697
+ */
698
+ fix: string;
557
699
  }
558
- declare const FALLBACK_POSSIBLE_ERRORS: readonly ["COMPOSITION_NOT_FOUND"];
559
- type TFallbackError = (typeof FALLBACK_POSSIBLE_ERRORS)[number];
560
- interface ComposableStudioClientError extends ComposableStudioError {
561
- id: Exclude<keyof typeof ComposableStudioErrors, TFallbackError>;
700
+ /**
701
+ * Type definition for error details that can be passed to ComposableStudioError
702
+ */
703
+ interface ComposableStudioErrorDetails {
704
+ /**
705
+ * Array of troubleshooting information with causes and fixes
706
+ */
707
+ troubleshootingInfo?: TroubleshootingInfo[];
708
+ /**
709
+ * Additional error context and metadata
710
+ */
711
+ [key: string]: any;
562
712
  }
563
- interface ComposableStudioFallbackError extends ComposableStudioError {
564
- id: TFallbackError;
713
+ declare class ComposableStudioError extends Error {
714
+ id: keyof typeof ComposableStudioErrors;
715
+ details?: ComposableStudioErrorDetails;
716
+ constructor(id: keyof typeof ComposableStudioErrors, message: string, details?: ComposableStudioErrorDetails);
565
717
  }
566
718
 
567
719
  declare const evaluateCondition: (condition: Condition, data: any) => boolean;
@@ -714,5 +866,77 @@ declare function getNodeScreenshotEvent(): {
714
866
  unregister: () => void;
715
867
  } | undefined;
716
868
 
717
- 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 };
718
- 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 };
869
+ interface QuerySpec {
870
+ contentType: string;
871
+ sourceType?: "content_type" | "taxonomy";
872
+ query: Record<string, any>;
873
+ params: Record<string, any>;
874
+ }
875
+ interface QueryResult {
876
+ entries: any[];
877
+ count: number;
878
+ currentPage: number;
879
+ pageSize: number;
880
+ hasNextPage: boolean;
881
+ hasPreviousPage: boolean;
882
+ }
883
+ interface QueryState extends QueryResult {
884
+ isLoading: boolean;
885
+ error: Error | null;
886
+ }
887
+ interface QueryExecutionOptions {
888
+ variantAlias?: string;
889
+ locale?: string;
890
+ }
891
+ interface RuntimeContext {
892
+ url?: {
893
+ params: Record<string, string>;
894
+ path: Record<string, string>;
895
+ hash?: string;
896
+ };
897
+ componentProps?: Record<string, any>;
898
+ user?: {
899
+ id?: string;
900
+ email?: string;
901
+ name?: string;
902
+ role?: string;
903
+ preferences?: Record<string, any>;
904
+ };
905
+ environment?: {
906
+ locale?: string;
907
+ region?: string;
908
+ timezone?: string;
909
+ };
910
+ }
911
+
912
+ declare class ExpressionResolver {
913
+ resolve(expression: any, context: RuntimeContext): any;
914
+ private resolveTimeExpression;
915
+ private resolveUrlExpression;
916
+ private resolvePropsExpression;
917
+ private resolveUserExpression;
918
+ private resolveEnvExpression;
919
+ private getNestedValue;
920
+ }
921
+
922
+ declare class QueryExecutor {
923
+ private sdk;
924
+ private expressionResolver;
925
+ constructor(sdk: any);
926
+ /**
927
+ * Detection logic:
928
+ * 1. If 'contentType' (lowercase) exists in object or prototype, it's likely TS SDK or CMA SDK.
929
+ * 2. If 'ContentType' (uppercase) exists AND 'contentType' doesn't, it's likely legacy JS Delivery SDK.
930
+ */
931
+ private isJavaScriptSDK;
932
+ /** TS @contentstack/delivery-sdk: Mongo filter must be sent via addParams({ query }), not .query(obj) */
933
+ private usesTsContentTypeEntryQuery;
934
+ execute(querySpec: QuerySpec, page?: number, context?: RuntimeContext, options?: QueryExecutionOptions): Promise<QueryResult>;
935
+ /**
936
+ * Helper to resolve expressions in nested query objects
937
+ */
938
+ private resolveExpressionsInQuery;
939
+ }
940
+
941
+ export { BreakpointManager, COMPOSABLE_DATA_ATTRIBUTES, COMPOSABLE_STUDIO_EMITTED_EVENTS, ComposableStudioError, ComposableStudioErrors, DEFAULT_BREAKPOINTS, EDGE_PADDING, ELEMENT_TO_NODE, ExpressionResolver, GOOGLE_FONT_API, INCLUDE_DEPTH_COUNT, MAX_SCROLL_SPEED, NODE_TO_ELEMENT, NODE_TO_PARENT, NODE_TO_PATH_NODE, QueryExecutor, RendererMode, RendererModeUtil, SCROLL_INTERVAL, addBreakpointEventListeners, addContextMenuEventListeners, addHighlightNodeEventListeners, addHighlightSpacingEventListeners, addUrlChangeListeners, 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, isInsideIframe, isInsideVisualBuilderFrame, isModKey, loadGoogleFont, onlyParmasGenerator, openHiddenElementNotification, parseStringValue, preProcessStaticValues, queryParam, registerJSONRTE, serializeComputedStyles, serializeEvent, setStaticEntryInDS, setTemplateEntryInDS, studioSdk, toggleNodeVisible, updateStyleOnStyleNodeChange };
942
+ export type { ClientEditableNodeInternalAttributes, ClientPreviewNodeInternalAttributes, ComposableStudioErrorDetails, ComposableStudioLightSdk, CompositionEntry, CompositionEntryIncompleteUi, CompositionFetcher, CompositionQueryForSSR, CompositionQueryForSSRInput, CompositionQueryOptions, Config, EmittedEvents, FetchCompositionContext, FetchTemplateEntryContext, FontVariants, GoogleFont, HiddenElementNotificationHandler, LightConfig, MetaProp, ParsedStringResult, QueryExecutionOptions, QueryResult, QuerySpec, QueryState, ResolvedQueryOptions, RuntimeContext, SearchQueryInput, SeoMetadata, StudioComponentFetchOptions, StudioComponentSpecOptions, StudioSdk, StudioSpec, SymbolEntry, TemplateEntryFetcher, TroubleshootingInfo, URLSearchParamsString, UserConfig };
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { studioSdk } from './composable-studio/initializer-sdk.js';
2
- export { sendInitMessage } from './composable-studio/initializer-sdk.js';
3
2
  export { ELEMENT_TO_NODE, NODE_TO_ELEMENT, NODE_TO_PARENT, NODE_TO_PATH_NODE } from './composable-studio/weak-maps.js';
4
3
  export { parseStringValue, preProcessStaticValues } from './composable-studio/data/pre-process-static-values.js';
5
4
  export { addContextMenuEventListeners } from './context-menu/context-menu.js';
6
5
  export { EDGE_PADDING, MAX_SCROLL_SPEED, SCROLL_INTERVAL, dndManager } from './dnd/dnd-manager.js';
7
6
  export { dndEventListener } from './dnd/dnd-event.js';
8
7
  export { calculateDynamicSpeed, getScrollContainer, getScrollContainerRect, getScrollableParent } from './dnd/utils.js';
9
- export { addHighlightNodeEventListeners, handleOnScroll, handleResize } from './highlight-node/highlight-node.js';
8
+ export { addHighlightNodeEventListeners, handleOnScroll, handleResize, isModKey } from './highlight-node/highlight-node.js';
10
9
  export { highlightNodeManager } from './highlight-node/highlight-node-manager.js';
11
10
  export { TARGET_NODE } from '@contentstack/studio-message-types/latest';
11
+ export { addUrlChangeListeners } from './url-change/url-change.js';
12
12
  export { addHighlightSpacingEventListeners } from './highlight-spacing/highlight-spacing-events.js';
13
13
  export { getDefaultConfig } from './config/default-config.js';
14
14
  export { addBreakpointEventListeners } from './breakpoints/breakpoint.js';
@@ -22,7 +22,8 @@ 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 { isInsideIframe } from './utils/is-inside-iframe.js';
26
+ export { ComposableStudioError, ComposableStudioErrors } from './utils/composable-studio-error.js';
26
27
  export { evaluateCondition } from './utils/conditionBlock.js';
27
28
  export { RendererModeUtil, clientRendererModeUtil, serializeComputedStyles } from './utils/canvas.js';
28
29
  export { loadGoogleFont } from './design/fonts/index.js';
@@ -35,6 +36,8 @@ export { getJSONRTE, registerJSONRTE } from './json-rte-registry/index.js';
35
36
  export { compositionSaveEventListener } from './visual-builder/composition-save-event.js';
36
37
  export { closeHiddenElementNotification, hiddenElementNotificationEventEmitter, openHiddenElementNotification } from './hidden-element-notification/hidden-element-notification-event.js';
37
38
  export { getNodeScreenshotEvent } from './get-active-node-screenshot/get-node-screenshot-event.js';
39
+ export { ExpressionResolver } from './query/expression-resolver.js';
40
+ export { QueryExecutor } from './query/query-executor.js';
38
41
  export { IS_BROWSER } from '@contentstack/studio-messenger';
39
42
 
40
43
  // STUDIO SDK
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;"}