@contentstack/studio-client 3.2.0 → 4.0.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 (95) hide show
  1. package/dist/breakpoints/BreakpointManager.js +7 -5
  2. package/dist/breakpoints/BreakpointManager.js.map +1 -1
  3. package/dist/breakpoints/breakpoint.js +3 -2
  4. package/dist/breakpoints/breakpoint.js.map +1 -1
  5. package/dist/canvas/canvas.utils.js +13 -1
  6. package/dist/canvas/canvas.utils.js.map +1 -1
  7. package/dist/composable-studio/build-scoped-data.js +12 -35
  8. package/dist/composable-studio/build-scoped-data.js.map +1 -1
  9. package/dist/composable-studio/sdk.js +1064 -430
  10. package/dist/composable-studio/sdk.js.map +1 -1
  11. package/dist/composable-studio/studio-intelligence.manager.js +5 -2
  12. package/dist/composable-studio/studio-intelligence.manager.js.map +1 -1
  13. package/dist/config/config.schema.js +45 -8
  14. package/dist/config/config.schema.js.map +1 -1
  15. package/dist/config/default-config.js +10 -3
  16. package/dist/config/default-config.js.map +1 -1
  17. package/dist/config/process-user-config.js +37 -1
  18. package/dist/config/process-user-config.js.map +1 -1
  19. package/dist/config/stack-sdk-wrapper.js +36 -1
  20. package/dist/config/stack-sdk-wrapper.js.map +1 -1
  21. package/dist/context-menu/context-menu.js +5 -2
  22. package/dist/context-menu/context-menu.js.map +1 -1
  23. package/dist/design/handle-active-style-change.js +3 -2
  24. package/dist/design/handle-active-style-change.js.map +1 -1
  25. package/dist/dnd/dnd-event.js +2 -1
  26. package/dist/dnd/dnd-event.js.map +1 -1
  27. package/dist/dnd/dnd-manager.js +3 -1
  28. package/dist/dnd/dnd-manager.js.map +1 -1
  29. package/dist/editor.d.ts +250 -0
  30. package/dist/editor.js +11 -0
  31. package/dist/editor.js.map +1 -0
  32. package/dist/get-active-node-screenshot/get-node-screenshot-event.js +2 -1
  33. package/dist/get-active-node-screenshot/get-node-screenshot-event.js.map +1 -1
  34. package/dist/hidden-element-notification/hidden-element-notification-event.js +2 -1
  35. package/dist/hidden-element-notification/hidden-element-notification-event.js.map +1 -1
  36. package/dist/highlight-node/highlight-node-manager.js +225 -15
  37. package/dist/highlight-node/highlight-node-manager.js.map +1 -1
  38. package/dist/highlight-node/highlight-node.js +42 -6
  39. package/dist/highlight-node/highlight-node.js.map +1 -1
  40. package/dist/highlight-spacing/highlight-spacing-events.js +2 -1
  41. package/dist/highlight-spacing/highlight-spacing-events.js.map +1 -1
  42. package/dist/index.d.ts +1006 -436
  43. package/dist/index.js +12 -13
  44. package/dist/index.js.map +1 -1
  45. package/dist/url-change/url-change.js +4 -3
  46. package/dist/url-change/url-change.js.map +1 -1
  47. package/dist/url-metadata/build-template-query.js +14 -3
  48. package/dist/url-metadata/build-template-query.js.map +1 -1
  49. package/dist/utils/canvas.js +2 -1
  50. package/dist/utils/canvas.js.map +1 -1
  51. package/dist/utils/check-bindings.js +233 -0
  52. package/dist/utils/check-bindings.js.map +1 -0
  53. package/dist/utils/classify-response-error.js +288 -0
  54. package/dist/utils/classify-response-error.js.map +1 -0
  55. package/dist/utils/composable-studio-error.js +36 -20
  56. package/dist/utils/composable-studio-error.js.map +1 -1
  57. package/dist/utils/composition-not-found.js +52 -0
  58. package/dist/utils/composition-not-found.js.map +1 -0
  59. package/dist/utils/constants.js +21 -2
  60. package/dist/utils/constants.js.map +1 -1
  61. package/dist/utils/degraded-finding.js +166 -0
  62. package/dist/utils/degraded-finding.js.map +1 -0
  63. package/dist/utils/editor-mode.js +1 -1
  64. package/dist/utils/http-error.constants.js +12 -46
  65. package/dist/utils/http-error.constants.js.map +1 -1
  66. package/dist/utils/include-path-rules.js +40 -1
  67. package/dist/utils/include-path-rules.js.map +1 -1
  68. package/dist/utils/is-composition-being-edited.js +1 -1
  69. package/dist/utils/is-inside-iframe.js +1 -1
  70. package/dist/utils/is-inside-visual-builder-frame.js +1 -1
  71. package/dist/utils/parse-ui.js +60 -0
  72. package/dist/utils/parse-ui.js.map +1 -0
  73. package/dist/utils/query-param.js +1 -1
  74. package/dist/utils/query-param.js.map +1 -1
  75. package/dist/utils/reference-stub.js +75 -0
  76. package/dist/utils/reference-stub.js.map +1 -0
  77. package/dist/utils/reference_fetcher.js +44 -3
  78. package/dist/utils/reference_fetcher.js.map +1 -1
  79. package/dist/utils/require-stack.js +141 -0
  80. package/dist/utils/require-stack.js.map +1 -0
  81. package/dist/utils/served-by.js +33 -0
  82. package/dist/utils/served-by.js.map +1 -0
  83. package/dist/utils/studio-error-codes.js +253 -0
  84. package/dist/utils/studio-error-codes.js.map +1 -0
  85. package/dist/utils/studio-error.js +122 -0
  86. package/dist/utils/studio-error.js.map +1 -0
  87. package/dist/utils/studio-messaging.js +25 -0
  88. package/dist/utils/studio-messaging.js.map +1 -0
  89. package/dist/visual-builder/composition-save-event.js +2 -1
  90. package/dist/visual-builder/composition-save-event.js.map +1 -1
  91. package/package.json +19 -6
  92. package/dist/utils/error-messages.default.js +0 -141
  93. package/dist/utils/error-messages.default.js.map +0 -1
  94. package/dist/utils/error-messages.js +0 -47
  95. package/dist/utils/error-messages.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,25 +1,18 @@
1
1
  import { studioSdk } from './composable-studio/initializer-sdk.js';
2
2
  export { ELEMENT_TO_NODE, NODE_TO_ELEMENT, NODE_TO_PARENT, NODE_TO_PATH_NODE } from './composable-studio/weak-maps.js';
3
- export { buildSectionScopedData, getSeoMetadataPure } from './composable-studio/sdk.js';
3
+ export { buildSectionScopedData, derivePlacementIncludePaths, getSeoMetadataPure } from './composable-studio/sdk.js';
4
4
  export { getCompositionMetadata, renderMetadataToHtml } from './composable-studio/composition-metadata.js';
5
5
  export { TEMPLATE_BINDING_TYPE, TEMPLATE_FETCH_ROOT_KEY, fetchRootFromBinding, flattenPath, getRootBindingPath, getRootScopePath, isDataRootCleared, isPageAbsoluteField, isTemplateFetchRoot, isTemplateRootBinding, nestPath, parseEntryFetchRootKey, resolveInstanceRootBinding, resolveLegacySelectedField, resolveLegacySelectedFieldWithProvenance, resolveMatchedSchema, sectionDataEqual, splitFieldPath, synthesizeTemplateRootBinding, templateFetchRoot } from './composable-studio/section-data.js';
6
6
  export { parseStringValue, preProcessStaticValues } from './composable-studio/data/pre-process-static-values.js';
7
7
  export { COMPOSITION_PLACEMENT_OPTIONS } from './composable-studio/composition-placement.types.js';
8
8
  export { addContextMenuEventListeners } from './context-menu/context-menu.js';
9
- export { EDGE_PADDING, MAX_SCROLL_SPEED, SCROLL_INTERVAL, dndManager } from './dnd/dnd-manager.js';
10
- export { dndEventListener } from './dnd/dnd-event.js';
11
- export { calculateDynamicSpeed, getScrollableParent } from './dnd/scroll-utils.js';
12
- export { addHighlightNodeEventListeners, handleOnScroll, handleResize, isModKey } from './highlight-node/highlight-node.js';
13
- export { highlightNodeManager } from './highlight-node/highlight-node-manager.js';
14
- export { TARGET_NODE } from '@contentstack/studio-message-types/latest';
15
9
  export { addUrlChangeListeners } from './url-change/url-change.js';
16
- export { addHighlightSpacingEventListeners } from './highlight-spacing/highlight-spacing-events.js';
17
10
  export { getDefaultConfig } from './config/default-config.js';
18
11
  export { addBreakpointEventListeners } from './breakpoints/breakpoint.js';
19
12
  export { DEFAULT_BREAKPOINTS } from './breakpoints/breakpoint.constant.js';
20
13
  export { BreakpointManager } from './breakpoints/BreakpointManager.js';
21
14
  export { RendererMode } from './canvas/canvas.type.js';
22
- export { findNearestBuilderNode, findNearestSlotNode, getComposableElement, getComputedStyles, getHitboxDetails, getHitboxDirection, hasSlotDropzone, serializeEvent, toggleNodeVisible } from './canvas/canvas.utils.js';
15
+ export { findNearestBuilderNode, findNearestSlotNode, getComposableElement, getComposableElements, getComputedStyles, getHitboxDetails, getHitboxDirection, hasSlotDropzone, serializeEvent, toggleNodeVisible } from './canvas/canvas.utils.js';
23
16
  export { COMPOSABLE_DATA_ATTRIBUTES, INCLUDE_DEPTH_COUNT, SCHEMA_VERSION, SDK_VERSION, isBrowser } from './utils/constants.js';
24
17
  export { applyOperation, findPath, findPathForElement } from './utils/editor-utils.js';
25
18
  export { isCompositionBeingEdited } from './utils/is-composition-being-edited.js';
@@ -28,10 +21,14 @@ export { SECTION_COMPOSITIONS_KEY, TEMPLATE_FULL_ENTRY_KEY, batchFetchEntries, e
28
21
  export { isInsideVisualBuilderFrame } from './utils/is-inside-visual-builder-frame.js';
29
22
  export { isInsideIframe } from './utils/is-inside-iframe.js';
30
23
  export { STUDIO_CANVAS_QUERY_PARAM, STUDIO_MODE_HTML_CLASS, detectStudioMode, isStudioCanvas, isStudioEditorMode, markStudioMode } from './utils/editor-mode.js';
31
- export { ComposableStudioError, ComposableStudioErrors } from './utils/composable-studio-error.js';
24
+ export { ComposableStudioError } from './utils/composable-studio-error.js';
25
+ export { CompositionNotFoundError, isCompositionNotFound } from './utils/composition-not-found.js';
26
+ export { buildStudioErrorContext, createStudioError, isSetupFault } from './utils/studio-error.js';
27
+ export { StudioErrorClass, StudioErrorCode } from './utils/studio-error-codes.js';
32
28
  export { evaluateCondition, resolveConditionScope } from './utils/conditionBlock.js';
33
29
  export { RendererModeUtil, clientRendererModeUtil, serializeComputedStyles } from './utils/canvas.js';
34
30
  export { analyzeMultipleSpecs, analyzeUsedComponents, getComponentUsageStats, specUsesComponent } from './utils/spec-analyzer.js';
31
+ export { sendStudioEvent } from './utils/studio-messaging.js';
35
32
  export { loadGoogleFont } from './design/fonts/index.js';
36
33
  export { GOOGLE_FONT_API } from './design/fonts/fonts.constant.js';
37
34
  export { createClassNameUid } from './design/create-class-name-uid.js';
@@ -39,9 +36,6 @@ export { updateStyleOnStyleNodeChange } from './design/handle-active-style-chang
39
36
  export { composableStudioEventEmitter } from './emitted-events/event-emitter.js';
40
37
  export { COMPOSABLE_STUDIO_EMITTED_EVENTS } from './emitted-events/events.constant.js';
41
38
  export { getEmbeddedAssetRenderer, getEmbeddedEntryRenderer, getJSONRTE, registerEmbeddedEntryRenderer, registerJSONRTE, registerRTERenderer } from './json-rte-registry/index.js';
42
- export { compositionSaveEventListener } from './visual-builder/composition-save-event.js';
43
- export { closeHiddenElementNotification, hiddenElementNotificationEventEmitter, openHiddenElementNotification } from './hidden-element-notification/hidden-element-notification-event.js';
44
- export { getNodeScreenshotEvent } from './get-active-node-screenshot/get-node-screenshot-event.js';
45
39
  export { ExpressionResolver } from './query/expression-resolver.js';
46
40
  export { QueryExecutor } from './query/query-executor.js';
47
41
  export { buildTemplateQuery, buildUrlMetadataQueryObject, resolveByUrlSource } from './url-metadata/build-template-query.js';
@@ -50,9 +44,14 @@ export { rankUrlMatches } from './url-metadata/rank-url-matches.js';
50
44
  export { shouldUseUrlMetadataPath } from './url-metadata/shouldUseUrlMetadataPath.js';
51
45
  export { COMPOSITION_PREVIEW_URL_SOURCES, COMPOSITION_PREVIEW_URL_SOURCES_VALUES, DEFAULT_COMPOSITION_PREVIEW_URL_SOURCE, URL_PATTERN_DATE_VARIABLES, URL_PATTERN_METADATA_FIELDS, URL_PATTERN_METADATA_FIELDS_VALUES, URL_PATTERN_VARIABLE_TYPES } from './url-metadata/types.js';
52
46
  export { compileUrlPattern, computePatternSpecificity, matchCompositionUrl, matchUrlPattern } from './url-metadata/url-pattern-matcher.js';
47
+ export { TARGET_NODE } from '@contentstack/studio-message-types/latest';
53
48
  export { IS_BROWSER } from '@contentstack/studio-messenger';
54
49
  export { createEmbeddedEntryConversion, defaultAssetRender, extractHtmlRteRefs, extractJsonRteRefs, fetchEmbeddedEntries } from './json-rte-registry/embedded-entry-conversion.js';
55
50
 
51
+ // Editor-only listeners (dnd, highlight, hidden-element, screenshot,
52
+ // composition-save) live in `./editor`. They hold a static import of the
53
+ // postMessage bridge, which every consumer of this barrel would otherwise
54
+ // inherit. See src/editor.ts.
56
55
  // STUDIO SDK
57
56
 
58
57
  export { studioSdk as default, studioSdk };
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;AACA;AACA;AACA;AACA;;;;"}
@@ -1,10 +1,11 @@
1
- import { IS_BROWSER, composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
1
+ import { IS_BROWSER, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger/constants';
2
+ import { sendStudioEvent } from '../utils/studio-messaging.js';
2
3
 
3
4
  function sendUrlToParent() {
4
5
  if (!IS_BROWSER)
5
6
  return;
6
7
  const url = window.location.href;
7
- composableStudioEventManager?.send(POST_MESSAGE_EVENTS.URL_CHANGE, { url });
8
+ sendStudioEvent(POST_MESSAGE_EVENTS.URL_CHANGE, { url });
8
9
  }
9
10
  function setupNavigationApi() {
10
11
  if (!IS_BROWSER)
@@ -14,7 +15,7 @@ function setupNavigationApi() {
14
15
  return null;
15
16
  const handler = (event) => {
16
17
  const url = event.destination.url;
17
- composableStudioEventManager?.send(POST_MESSAGE_EVENTS.URL_CHANGE, { url });
18
+ sendStudioEvent(POST_MESSAGE_EVENTS.URL_CHANGE, { url });
18
19
  };
19
20
  nav.addEventListener("navigate", handler);
20
21
  return () => nav.removeEventListener("navigate", handler);
@@ -1 +1 @@
1
- {"version":3,"file":"url-change.js","sources":["../../src/url-change/url-change.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAkBA,SAAS,eAAe,GAAA;AACtB,IAAA,IAAI,CAAC,UAAU;QAAE;AACjB,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI;IAChC,4BAA4B,EAAE,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC;AAC7E;AAEA,SAAS,kBAAkB,GAAA;AACzB,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,IAAI;AAC5B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
2
 
3
- /** Non-empty predicate for scalar entry fields. */
3
+ /**
4
+ * Non-empty predicate for scalar entry fields: not the empty string, not null.
5
+ *
6
+ * `null` is expressed as a scalar `$ne` rather than as an element of `$nin`.
7
+ * The preview service rejects a `null` inside an `$in`/`$nin` array outright —
8
+ * HTTP 400, `error_code` 141, `{"query":["is not valid."]}` — while the CMA
9
+ * accepts it. The array form therefore failed every preview-transport read of
10
+ * this query and fell back to the CMA, spending a whole extra round trip on the
11
+ * path that gates the canvas iframe. Both services accept the scalar form and
12
+ * select the same entries.
13
+ */
4
14
  const NON_EMPTY = {
5
- $nin: ["", null],
15
+ $nin: [""],
16
+ $ne: null,
6
17
  };
7
18
  /** Existence predicate for taxonomy variables (entry has at least one term). */
8
19
  const TAXONOMY_EXISTS = { $exists: true };
@@ -15,7 +26,7 @@ const TAXONOMY_EXISTS = { $exists: true };
15
26
  * stringifies it and passes it to `api.cma.entry.getAll` via the `query` param.
16
27
  *
17
28
  * In `existence` mode for `legacy_url` and `content_type_url_pattern` the
18
- * object is `{ url: { $nin: ["", null] } }` regardless of `extractedVariables`.
29
+ * object is `{ url: { $nin: [""], $ne: null } }` regardless of `extractedVariables`.
19
30
  */
20
31
  function buildUrlMetadataQueryObject(context, mode = "match") {
21
32
  const { url_source, compositionQuery, extractedVariables } = context;
@@ -1 +1 @@
1
- {"version":3,"file":"build-template-query.js","sources":["../../src/url-metadata/build-template-query.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAoBA;AACA,MAAM,SAAS,GAA2C;AACxD,IAAA,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC;CACjB;AAED;AACA,MAAM,eAAe,GAAsB,EAAE,OAAO,EAAE,IAAI,EAAE;AAE5D;;;;;;;;;;AAUG;SACa,2BAA2B,CACzC,OAGC,EACD,OAA6B,OAAO,EAAA;IAEpC,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,OAAO;IACpE,MAAM,KAAK,GAAwB,EAA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,eAAe,EAAE,EAAE,GAAG,EAAE,kBAAkB,CAAC,WAAW,EAAE,CAAC;UACjE,eAAe;AAErB,IAAA,OAAO;SACJ,OAAO,CAAC,oBAAoB,EAAE;AAC7B,QAAA,UAAU,EAAE;YACV,GAAG,YAAY,CAAC,UAAU;YAC1B,GAAG,gBAAgB,CAAC,OAAO;AAC5B,SAAA,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,MAAM,EAAE,YAAY,CAAC,MAAM;QAC3B,MAAM,EAAE,YAAY,CAAC,MAAM;QAC3B,WAAW,EAAE,YAAY,CAAC,WAAW;AACrC,QAAA,KAAK,EAAE,UAAU;KAClB;SACA,KAAK,CAAC,CAAC,CAAC;AACb;AAEA;;AAEG;AACG,SAAU,kBAAkB,CAChC,QAAkB,EAClB,UAAkB,EAClB,gBAAkC,EAClC,kBAAgD,EAChD,gBAAuC,EACvC,oBAA4B,EAC5B,YAOC,EAAA;AAED,IAAA,MAAM,OAAO,GAAyB;QACpC,gBAAgB;QAChB,kBAAkB;QAClB,gBAAgB;QAChB,oBAAoB;AACpB,QAAA,UAAU,EAAE,UAA+C;KAC5D;IAED,OAAO,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAC;AAC5D;;;;"}
1
+ {"version":3,"file":"build-template-query.js","sources":["../../src/url-metadata/build-template-query.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAoBA;;;;;;;;;;AAUG;AACH,MAAM,SAAS,GAA+C;IAC5D,IAAI,EAAE,CAAC,EAAE,CAAC;AACV,IAAA,GAAG,EAAE,IAAI;CACV;AAED;AACA,MAAM,eAAe,GAAsB,EAAE,OAAO,EAAE,IAAI,EAAE;AAE5D;;;;;;;;;;AAUG;SACa,2BAA2B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,WAAW;AAEjB,IAAA,MAAM,UAAU,GACd,IAAI,KAAK,OAAO;QAChB,eAAe;QACf,WAAW;AACX,QAAA,kBAAkB,CAAC;AACjB,UAAE,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,EAAE,GAAG,EAAE,kBAAkB,CAAC,WAAW,EAAE,CAAC;UACjE,eAAe;AAErB,IAAA,OAAO;SACJ,OAAO,CAAC,oBAAoB,EAAE;AAC7B,QAAA,UAAU,EAAE;YACV,GAAG,YAAY,CAAC,UAAU;YAC1B,GAAG,gBAAgB,CAAC,OAAO;AAC5B,SAAA,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,MAAM,EAAE,YAAY,CAAC,MAAM;QAC3B,MAAM,EAAE,YAAY,CAAC,MAAM;QAC3B,WAAW,EAAE,YAAY,CAAC,WAAW;AACrC,QAAA,KAAK,EAAE,UAAU;KAClB;SACA,KAAK,CAAC,CAAC,CAAC;AACb;AAEA;;AAEG;AACG,SAAU,kBAAkB,CAChC,QAAkB,EAClB,UAAkB,EAClB,gBAAkC,EAClC,kBAAgD,EAChD,gBAAuC,EACvC,oBAA4B,EAC5B,YAOC,EAAA;AAED,IAAA,MAAM,OAAO,GAAyB;QACpC,gBAAgB;QAChB,kBAAkB;QAClB,gBAAgB;QAChB,oBAAoB;AACpB,QAAA,UAAU,EAAE,UAA+C;KAC5D;IAED,OAAO,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAC;AAC5D;;;;"}
@@ -1,5 +1,6 @@
1
- import { IS_BROWSER, COMPOSABLE_STUDIO_QUERY_PARAM } from '@contentstack/studio-messenger';
1
+ import { IS_BROWSER, COMPOSABLE_STUDIO_QUERY_PARAM } from '@contentstack/studio-messenger/constants';
2
2
  import { RendererMode } from '../canvas/canvas.type.js';
3
+ import '@contentstack/studio-messenger';
3
4
  import { camelCase } from 'lodash-es';
4
5
 
5
6
  class RendererModeUtil {
@@ -1 +1 @@
1
- {"version":3,"file":"canvas.js","sources":["../../src/utils/canvas.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;MAOa,gBAAgB,CAAA;IACnB,YAAY,GAA2B,IAAI;IAC3C,qBAAqB,GAAY,KAAK;AAC9C,IAAA,WAAA,CAAY,YAA8B,EAAA;AACxC,QAAA,IAAI,CAAC,UAAU,IAAI,CAAC,YAAY,EAAE;AAChC,YAAA,IAAI,CAAC,qBAAqB,GAAG,IAAI;YACjC;QACF;AACA,QAAA,IAAI,CAAC,YAAY;YACf,YAAY,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC/D;AAEA;;;;AAIG;IACH,mBAAmB,GAAA;AACjB,QAAA,IAAI,IAAI,CAAC,qBAAqB,EAAE;AAC9B,YAAA,OAAO,KAAK;QACd;QACA,OAAO,IAAI,CAAC,YAAa,CAAC,GAAG,CAAC,6BAA6B,CAAC,OAAO,CAAC;IACtE;AAEA;;;;AAIG;IACH,cAAc,GAAA;AACZ,QAAA,IAAI,IAAI,CAAC,qBAAqB,EAAE;AAC9B,YAAA,OAAO,KAAK;QACd;QACA,IAAI,CAAC,UAAU,EAAE;AACf,YAAA,OAAO,KAAK;QACd;AACA,QAAA,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,GAAG;IACnC;AAEA;;;;;;AAMG;IACH,0BAA0B,GAAA;AACxB,QAAA,IAAI,IAAI,CAAC,qBAAqB,EAAE;AAC9B,YAAA,OAAO,KAAK;QACd;QACA,QACE,IAAI,CAAC,YAAa,CAAC,GAAG,CAAC,6BAA6B,CAAC,cAAc,CAAC;AACpE,YAAA,MAAM;IAEV;AAEA;;;;;;;;;AASG;AACH,IAAA,2BAA2B,CAAC,cAAsB,EAAA;AAChD,QAAA,IAAI,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,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE;YAC/C;QACF;QAAE,OAAO,KAAK,EAAE;;YAEd,OAAO,CAAC,IAAI,CAAC,CAAA,kCAAA,EAAqC,QAAQ,CAAA,CAAE,EAAE,KAAK,CAAC;QACtE;IACF;AACA,IAAA,OAAO,gBAAgB;AACzB;;;;"}
@@ -0,0 +1,233 @@
1
+ import { get } from 'lodash-es';
2
+ import { DATA_SOURCES, getBindingString, convertBindingPath, DATA_SOURCES_PREFIX } from '@contentstack/studio-registry';
3
+ import { DegradedCode } from './degraded-finding.js';
4
+ import { getBindingStringForCS } from './sdk.js';
5
+
6
+ /**
7
+ * Finds the bindings that will render blank, before anybody has to ask why.
8
+ *
9
+ * This is the most common silent failure in the product: the page loads, the
10
+ * composition renders, one element is empty, and nothing anywhere says so. The
11
+ * author reports it as "Studio is broken" because from where they sit that is
12
+ * exactly what it looks like.
13
+ *
14
+ * **The check resolves a binding the same way the renderer does** — the same
15
+ * path builder, the same `get`, the same page-namespace fallback — rather than
16
+ * re-deriving the lookup here. Anything else would produce a second opinion, and
17
+ * a second opinion that disagrees with the screen is worse than silence: it
18
+ * sends somebody to fix a binding that works.
19
+ *
20
+ * Everything it cannot resolve the renderer's way is skipped rather than
21
+ * guessed. A binding inside a repeater is read against one iteration's item, and
22
+ * a binding inside a section is read against that section's own scoped data, so
23
+ * neither can be answered from the page's data and neither is reported. That
24
+ * makes this deliberately incomplete — and incomplete is the correct trade,
25
+ * because every case it does report is one the reader can act on.
26
+ */
27
+ /**
28
+ * Prop types that hold exactly one value.
29
+ *
30
+ * `object`, `array` and `json_rte` are left out because a container is what they
31
+ * are for. `any` is left out because it accepts whatever arrives, so there is
32
+ * nothing to mismatch against. `action` holds a function name and is resolved
33
+ * through a different path entirely.
34
+ */
35
+ const SINGLE_VALUE_PROP_TYPES = new Set([
36
+ "string",
37
+ "boolean",
38
+ "number",
39
+ "datestring",
40
+ "href",
41
+ "imageurl",
42
+ "choice",
43
+ "plaintext",
44
+ ]);
45
+ /** The binding kinds whose paths are absolute against the page's own data. */
46
+ const PAGE_ROOTED_BINDINGS = new Set([
47
+ DATA_SOURCES.CONTENTSTACK,
48
+ DATA_SOURCES.TEMPLATE,
49
+ ]);
50
+ /**
51
+ * Subfields an asset carries, used to tell an asset binding from any other
52
+ * dotted path.
53
+ *
54
+ * Matching on the subfield rather than on the field's own name is what keeps
55
+ * this working on every stack: an asset field can be called anything, but what
56
+ * a binding reads out of one is fixed by Contentstack.
57
+ */
58
+ const ASSET_SUBFIELDS = new Set([
59
+ "url",
60
+ "filename",
61
+ "title",
62
+ "content_type",
63
+ "file_size",
64
+ "dimension",
65
+ ]);
66
+ /**
67
+ * Whether a null value here is better explained by a known Preview API defect
68
+ * than by the author's binding.
69
+ *
70
+ * The defect: asked for an asset subfield as a dotted projection —
71
+ * `only[BASE][]=image.url` — on a request that also projects a bare field, the
72
+ * preview service returns null where the delivery CDN returns the asset. It is
73
+ * verified, it is ours, and it is invisible: the author sees a missing image and
74
+ * the only available reading is that they bound the wrong field.
75
+ *
76
+ * **It ranks rather than asserts, and the reason is precise.** The defect needs
77
+ * the other projected field to be a modular block, and telling a modular-blocks
78
+ * field from any other bare field needs the content type's schema, which is not
79
+ * fetched. So the conditions here are the ones that are provable — preview, a
80
+ * dotted asset projection, a bare field beside it — and the remaining
81
+ * uncertainty is carried in the causes instead of being papered over.
82
+ */
83
+ function looksLikeThePreviewAssetDefect(path, { servedBy, projection }) {
84
+ if (servedBy !== "preview")
85
+ return false;
86
+ const segments = path.split(".");
87
+ if (segments.length < 2)
88
+ return false;
89
+ if (!ASSET_SUBFIELDS.has(segments[segments.length - 1]))
90
+ return false;
91
+ const projectedAsDottedPath = projection.some(([parent, field]) => parent === "BASE" && field === path);
92
+ if (!projectedAsDottedPath)
93
+ return false;
94
+ return projection.some(([parent, field]) => parent === "BASE" && !field.includes("."));
95
+ }
96
+ /**
97
+ * Which entry a binding reads from, when the binding names one.
98
+ *
99
+ * A template binding does not: it reads whichever entry the composition is
100
+ * connected to on this request, and that is not knowable from the binding. Both
101
+ * fields are therefore absent rather than filled with a stand-in phrase — a
102
+ * stand-in reads as a value in the structured findings, and drops straight into
103
+ * the middle of a sentence as "on entry the connected entry of "the connected
104
+ * content type"".
105
+ */
106
+ function subjectOf(binding) {
107
+ const value = (binding.value ?? {});
108
+ return { entryUid: value.uid, contentTypeUid: value._content_type_uid };
109
+ }
110
+ /**
111
+ * Resolves a binding exactly as the renderer will.
112
+ *
113
+ * The page-namespace retry mirrors the renderer's own: a binding authored on a
114
+ * slot child against a page-level field produces a section-local path that
115
+ * resolves to nothing, and the renderer looks again under `dataSources.page`
116
+ * before giving up. Skipping that retry here would report every one of those
117
+ * bindings as broken while the screen shows them working.
118
+ */
119
+ function resolveAsRendererWould(binding, data) {
120
+ const dataPath = getBindingString(binding);
121
+ if (!dataPath)
122
+ return undefined;
123
+ const resolved = get(data, convertBindingPath(binding.type, dataPath));
124
+ if (resolved !== undefined && resolved !== null)
125
+ return resolved;
126
+ if (typeof dataPath === "string" &&
127
+ dataPath.startsWith(`${DATA_SOURCES_PREFIX}.`) &&
128
+ !dataPath.startsWith(`${DATA_SOURCES_PREFIX}.page.`) &&
129
+ get(data, `${DATA_SOURCES_PREFIX}.page`)) {
130
+ return get(data, dataPath.replace(new RegExp(`^${DATA_SOURCES_PREFIX}\\.`), `${DATA_SOURCES_PREFIX}.page.`));
131
+ }
132
+ return resolved;
133
+ }
134
+ /**
135
+ * Whether the document this binding reads from arrived at all.
136
+ *
137
+ * A binding against an entry that was never fetched is not a broken binding —
138
+ * the entry not arriving is its own finding, already reported with the uid that
139
+ * went missing. Reporting it twice under two names would have a reader chasing
140
+ * the binding instead of the entry.
141
+ */
142
+ function documentIsPresent(binding, dataSources) {
143
+ if (binding.type === DATA_SOURCES.TEMPLATE) {
144
+ return dataSources?.[DATA_SOURCES.TEMPLATE] != null;
145
+ }
146
+ const { entryUid, contentTypeUid } = subjectOf(binding);
147
+ if (!entryUid || !contentTypeUid)
148
+ return false;
149
+ return (dataSources?.[DATA_SOURCES.CONTENTSTACK]?.[`${contentTypeUid}:${entryUid}`] != null);
150
+ }
151
+ /**
152
+ * Every binding on the page that resolves to nothing, or to the wrong kind of
153
+ * thing.
154
+ *
155
+ * Deduplicated on the binding rather than on the element, because one field
156
+ * read by six elements is one thing to go and fix.
157
+ */
158
+ function findBindingDefects(spec, dataSources, request = { servedBy: "unknown", projection: [] }) {
159
+ const defects = new Map();
160
+ const data = { dataSources };
161
+ function inspectProp(prop) {
162
+ const binding = prop?.binding;
163
+ if (!binding?.type || !PAGE_ROOTED_BINDINGS.has(binding.type))
164
+ return;
165
+ if (!documentIsPresent(binding, dataSources))
166
+ return;
167
+ // A binding with no path reads the whole document. There is no field to be
168
+ // missing, so there is nothing here to report.
169
+ const dataPath = getBindingString(binding);
170
+ if (!dataPath || typeof dataPath !== "string")
171
+ return;
172
+ const { entryUid, contentTypeUid } = subjectOf(binding);
173
+ // The path as an author would recognise it. Read off the binding rather
174
+ // than sliced off the front of the lookup string, because the two kinds do
175
+ // not have the same number of segments in front of the field — a
176
+ // contentstack binding carries an entry key there and a template binding
177
+ // does not, so a fixed slice puts `product:prodA` into the sentence.
178
+ const path = getBindingStringForCS(binding);
179
+ const resolved = resolveAsRendererWould(binding, data);
180
+ if (resolved === undefined || resolved === null) {
181
+ // Our own defect gets named ahead of the author's binding when the
182
+ // conditions for it hold. Both produce the identical absence, and only
183
+ // one of them is worth an author's afternoon: told the field is missing,
184
+ // they will re-point a binding that is already correct and watch it stay
185
+ // blank, because the fix is not theirs to make.
186
+ const code = looksLikeThePreviewAssetDefect(path, request)
187
+ ? DegradedCode.PREVIEW_ASSET_PROJECTION_NULL
188
+ : DegradedCode.BINDING_PATH_MISSING;
189
+ defects.set(`${code}|${dataPath}`, {
190
+ code,
191
+ path,
192
+ entryUid,
193
+ contentTypeUid,
194
+ });
195
+ return;
196
+ }
197
+ // Presence-gated: a prop that never declared its type cannot be said to
198
+ // have got the wrong one, so an absent `type` reports nothing rather than
199
+ // guessing.
200
+ if (!prop.type || !SINGLE_VALUE_PROP_TYPES.has(prop.type))
201
+ return;
202
+ if (typeof resolved !== "object")
203
+ return;
204
+ defects.set(`${DegradedCode.BINDING_SHAPE_MISMATCH}|${dataPath}`, {
205
+ code: DegradedCode.BINDING_SHAPE_MISMATCH,
206
+ path,
207
+ entryUid,
208
+ contentTypeUid,
209
+ resolvedTo: Array.isArray(resolved) ? "modular block" : "group",
210
+ });
211
+ }
212
+ function traverse(node) {
213
+ if (!node)
214
+ return;
215
+ // A repeater's item bindings are read against one iteration, and a
216
+ // section's against its own scoped data. Neither can be answered from here,
217
+ // so neither subtree is walked.
218
+ if (node.type === "repeater" || node.type === "section-composition")
219
+ return;
220
+ Object.values(node.props ?? {}).forEach(inspectProp);
221
+ Object.values(node.slots ?? {}).forEach((slotContent) => {
222
+ if (Array.isArray(slotContent))
223
+ slotContent.forEach(traverse);
224
+ else if (slotContent && typeof slotContent === "object")
225
+ traverse(slotContent);
226
+ });
227
+ }
228
+ traverse(spec);
229
+ return [...defects.values()];
230
+ }
231
+
232
+ export { findBindingDefects };
233
+ //# sourceMappingURL=check-bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-bindings.js","sources":["../../src/utils/check-bindings.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBG;AAcH;;;;;;;AAOG;AACH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,YAAY;IACZ,MAAM;IACN,UAAU;IACV,QAAQ;IACR,WAAW;AACZ,CAAA,CAAC;AAEF;AACA,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAS;AAC3C,IAAA,YAAY,CAAC,YAAY;AACzB,IAAA,YAAY,CAAC,QAAQ;AACtB,CAAA,CAAC;AAEF;;;;;;;AAOG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;I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