@contentstack/studio-client 1.6.0 → 1.7.1

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 (86) hide show
  1. package/dist/breakpoints/BreakpointManager.js +18 -5
  2. package/dist/breakpoints/BreakpointManager.js.map +1 -1
  3. package/dist/canvas/canvas.utils.js +1 -1
  4. package/dist/canvas/canvas.utils.js.map +1 -1
  5. package/dist/composable-studio/build-scoped-data.js +170 -0
  6. package/dist/composable-studio/build-scoped-data.js.map +1 -0
  7. package/dist/composable-studio/collect-data-needs.js +344 -0
  8. package/dist/composable-studio/collect-data-needs.js.map +1 -0
  9. package/dist/composable-studio/composition-metadata.js +75 -0
  10. package/dist/composable-studio/composition-metadata.js.map +1 -0
  11. package/dist/composable-studio/composition-placement.types.js +7 -0
  12. package/dist/composable-studio/composition-placement.types.js.map +1 -0
  13. package/dist/composable-studio/sdk.js +2169 -192
  14. package/dist/composable-studio/sdk.js.map +1 -1
  15. package/dist/composable-studio/studio-intelligence.manager.js +2 -12
  16. package/dist/composable-studio/studio-intelligence.manager.js.map +1 -1
  17. package/dist/config/default-config.js +1 -0
  18. package/dist/config/default-config.js.map +1 -1
  19. package/dist/config/stack-sdk-wrapper.js +86 -0
  20. package/dist/config/stack-sdk-wrapper.js.map +1 -1
  21. package/dist/context-menu/context-menu.js +1 -0
  22. package/dist/context-menu/context-menu.js.map +1 -1
  23. package/dist/dnd/dnd-manager.js +1 -0
  24. package/dist/dnd/dnd-manager.js.map +1 -1
  25. package/dist/highlight-node/highlight-node-manager.js +1 -0
  26. package/dist/highlight-node/highlight-node-manager.js.map +1 -1
  27. package/dist/highlight-node/highlight-node.js +5 -1
  28. package/dist/highlight-node/highlight-node.js.map +1 -1
  29. package/dist/index.d.ts +1033 -294
  30. package/dist/index.js +13 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/json-rte-registry/embedded-entry-conversion.js +186 -0
  33. package/dist/json-rte-registry/embedded-entry-conversion.js.map +1 -0
  34. package/dist/json-rte-registry/index.js +73 -33
  35. package/dist/json-rte-registry/index.js.map +1 -1
  36. package/dist/json-rte-registry/stack-sdk-store.js +10 -0
  37. package/dist/json-rte-registry/stack-sdk-store.js.map +1 -0
  38. package/dist/query/query-executor.js +182 -27
  39. package/dist/query/query-executor.js.map +1 -1
  40. package/dist/studio-internal/dist/utils/section-slot-walker.js +63 -0
  41. package/dist/studio-internal/dist/utils/section-slot-walker.js.map +1 -0
  42. package/dist/{packages/studio-internal → studio-internal}/dist/utils/spec-compression.js +1 -1
  43. package/dist/studio-internal/dist/utils/spec-compression.js.map +1 -0
  44. package/dist/url-metadata/build-template-query.js +124 -0
  45. package/dist/url-metadata/build-template-query.js.map +1 -0
  46. package/dist/url-metadata/parse-url-metadata.js +75 -0
  47. package/dist/url-metadata/parse-url-metadata.js.map +1 -0
  48. package/dist/url-metadata/rank-url-matches.js +100 -0
  49. package/dist/url-metadata/rank-url-matches.js.map +1 -0
  50. package/dist/url-metadata/select-url-winner.js +45 -0
  51. package/dist/url-metadata/select-url-winner.js.map +1 -0
  52. package/dist/url-metadata/shouldUseUrlMetadataPath.js +22 -0
  53. package/dist/url-metadata/shouldUseUrlMetadataPath.js.map +1 -0
  54. package/dist/url-metadata/types.js +50 -0
  55. package/dist/url-metadata/types.js.map +1 -0
  56. package/dist/url-metadata/url-pattern-matcher.js +311 -0
  57. package/dist/url-metadata/url-pattern-matcher.js.map +1 -0
  58. package/dist/utils/build-composition-fetch-query.js +19 -0
  59. package/dist/utils/build-composition-fetch-query.js.map +1 -0
  60. package/dist/utils/canvas.js +14 -0
  61. package/dist/utils/canvas.js.map +1 -1
  62. package/dist/utils/constants.js +19 -2
  63. package/dist/utils/constants.js.map +1 -1
  64. package/dist/utils/convertCompositionQueryInputToCompositionQuery.js +11 -1
  65. package/dist/utils/convertCompositionQueryInputToCompositionQuery.js.map +1 -1
  66. package/dist/utils/editor-mode.js +142 -0
  67. package/dist/utils/editor-mode.js.map +1 -0
  68. package/dist/utils/editor-utils.js +9 -0
  69. package/dist/utils/editor-utils.js.map +1 -1
  70. package/dist/utils/is-composition-being-edited.js.map +1 -1
  71. package/dist/utils/query-param.js +1 -1
  72. package/dist/utils/query-param.js.map +1 -1
  73. package/dist/utils/reference_fetcher.js +61 -6
  74. package/dist/utils/reference_fetcher.js.map +1 -1
  75. package/dist/utils/sdk.js +16 -1
  76. package/dist/utils/sdk.js.map +1 -1
  77. package/dist/utils/spec-analyzer.js +21 -4
  78. package/dist/utils/spec-analyzer.js.map +1 -1
  79. package/package.json +8 -10
  80. package/dist/get-composition-from-slug/get-composition-from-slug.js +0 -59
  81. package/dist/get-composition-from-slug/get-composition-from-slug.js.map +0 -1
  82. package/dist/node_modules/fflate/esm/browser.js +0 -384
  83. package/dist/node_modules/fflate/esm/browser.js.map +0 -1
  84. package/dist/packages/studio-internal/dist/utils/spec-compression.js.map +0 -1
  85. package/dist/utils/get-url-patterns.js +0 -40
  86. package/dist/utils/get-url-patterns.js.map +0 -1
@@ -0,0 +1,100 @@
1
+ import { matchCompositionUrl } from './url-pattern-matcher.js';
2
+
3
+ /**
4
+ * Rank URL matches across multiple composition entries
5
+ * Returns all composable_uid strings tied at the highest specificity score
6
+ *
7
+ * @param requestUrl The incoming URL to match against
8
+ * @param lightweightEntries Composition entries with url and composable_uid
9
+ * @returns Ranking result with all entries at max specificity tier
10
+ */
11
+ function rankUrlMatches(requestUrl, lightweightEntries) {
12
+ if (!lightweightEntries.length) {
13
+ return {
14
+ composableUids: [],
15
+ freeformComposableUids: [],
16
+ templatedComposableUids: [],
17
+ specificity: 0,
18
+ matches: [],
19
+ allMatches: [],
20
+ };
21
+ }
22
+ // Match each entry and collect results
23
+ const matches = [];
24
+ // Every successful match across all specificity tiers — for diagnostics.
25
+ const allMatches = [];
26
+ let maxSpecificity = -1;
27
+ for (const entry of lightweightEntries) {
28
+ if (!entry.url) {
29
+ continue; // Skip entries without URL patterns
30
+ }
31
+ const matchResult = matchCompositionUrl(requestUrl, entry.url, entry.composable_uid, {
32
+ connected_content_type: entry.connected_content_type,
33
+ });
34
+ if (matchResult.matched && matchResult.variables) {
35
+ // Additional validation: if composition_uid is in the URL pattern, it must match the entry's composable_uid
36
+ const extractedCompositionUid = matchResult.variables.metadata.composition_uid;
37
+ if (extractedCompositionUid &&
38
+ extractedCompositionUid !== entry.composable_uid) {
39
+ continue; // Skip this match as composition_uid doesn't match
40
+ }
41
+ // If content_type_uid is in the URL pattern, the composition's linked
42
+ // content type must match. Freeform compositions (no connected_content_type)
43
+ // are naturally excluded — this is intentional, content_type_uid is a
44
+ // linked-composition concept.
45
+ const extractedContentTypeUid = matchResult.variables.metadata.content_type_uid;
46
+ if (extractedContentTypeUid &&
47
+ extractedContentTypeUid !== entry.connected_content_type) {
48
+ continue;
49
+ }
50
+ const specificity = matchResult.variables.literalCharCount;
51
+ matches.push(matchResult);
52
+ allMatches.push({
53
+ composable_uid: entry.composable_uid,
54
+ url: entry.url,
55
+ specificity,
56
+ connected_content_type: entry.connected_content_type,
57
+ });
58
+ if (specificity > maxSpecificity) {
59
+ maxSpecificity = specificity;
60
+ }
61
+ }
62
+ }
63
+ // No matches found
64
+ if (maxSpecificity === -1) {
65
+ return {
66
+ composableUids: [],
67
+ freeformComposableUids: [],
68
+ templatedComposableUids: [],
69
+ specificity: 0,
70
+ matches: [],
71
+ allMatches: [],
72
+ };
73
+ }
74
+ // Collect all entries tied at the maximum specificity
75
+ const topTierMatches = matches.filter((match) => match.matched &&
76
+ match.variables &&
77
+ match.variables.literalCharCount === maxSpecificity);
78
+ // Separate freeform and templated matches
79
+ const freeformMatches = topTierMatches.filter((match) => !match.connected_content_type);
80
+ const templatedMatches = topTierMatches.filter((match) => !!match.connected_content_type);
81
+ // Extract UIDs for each category
82
+ const freeformComposableUids = freeformMatches.map((match) => match.composable_uid);
83
+ const templatedComposableUids = templatedMatches.map((match) => match.composable_uid);
84
+ // For backward compatibility, combine both (freeform first for priority)
85
+ const composableUids = [
86
+ ...freeformComposableUids,
87
+ ...templatedComposableUids,
88
+ ];
89
+ return {
90
+ composableUids,
91
+ freeformComposableUids,
92
+ templatedComposableUids,
93
+ specificity: maxSpecificity,
94
+ matches: topTierMatches,
95
+ allMatches,
96
+ };
97
+ }
98
+
99
+ export { rankUrlMatches };
100
+ //# sourceMappingURL=rank-url-matches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rank-url-matches.js","sources":["../../src/url-metadata/rank-url-matches.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQA;;;;;;;AAOG;AACG,SAAU,cAAc,CAC5B,UAAkB,EAClB,kBAAiD,EAAA;AAEjD,IAAA,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE;QAC9B,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,sBAAsB,EAAE,EAAE;AAC1B,YAAA,uBAAuB,EAAE,EAAE;AAC3B,YAAA,WAAW,EAAE,CAAC;AACd,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,UAAU,EAAE,EAAE;SACf;IACH;;IAGA,MAAM,OAAO,GAAyB,EAAE;;IAExC,MAAM,UAAU,GAAyB,EAAE;AAC3C,IAAA,IAAI,cAAc,GAAG,EAAE;AAEvB,IAAA,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE;AACtC,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;AACd,YAAA,SAAS;QACX;AAEA,QAAA,MAAM,WAAW,GAAG,mBAAmB,CACrC,UAAU,EACV,KAAK,CAAC,GAAG,EACT,KAAK,CAAC,cAAc,EACpB;YACE,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;AACrD,SAAA,CACF;QAED,IAAI,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,SAAS,EAAE;;YAEhD,MAAM,uBAAuB,GAC3B,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,eAAe;AAChD,YAAA,IACE,uBAAuB;AACvB,gBAAA,uBAAuB,KAAK,KAAK,CAAC,cAAc,E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MAAM,sBAAsB,GAAG,eAAe,CAAC,GAAG,CAChD,CAAC,KAAK,KAAK,KAAK,CAAC,cAAc,CAChC;AACD,IAAA,MAAM,uBAAuB,GAAG,gBAAgB,CAAC,GAAG,CAClD,CAAC,KAAK,KAAK,KAAK,CAAC,cAAc,CAChC;;AAGD,IAAA,MAAM,cAAc,GAAG;AACrB,QAAA,GAAG,sBAAsB;AACzB,QAAA,GAAG,uBAAuB;KAC3B;IAED,OAAO;QACL,cAAc;QACd,sBAAsB;QACtB,uBAAuB;AACvB,QAAA,WAAW,EAAE,cAAc;AAC3B,QAAA,OAAO,EAAE,cAAc;QACvB,UAAU;KACX;AACH;;;;"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Pick the winning composition among the top-tier (equally-specific) candidates,
3
+ * given the entry-existence probe results.
4
+ *
5
+ * Rules:
6
+ * - 0 candidates → no winner.
7
+ * - 1 candidate → it wins, marked `not-checked` (the happy path never probes).
8
+ * - >1 candidates → a freeform candidate (no content type) is unconditionally
9
+ * valid; a linked candidate is valid only if its content type owns a matching
10
+ * entry (`ownsByUid`). The first valid candidate in the given order wins. If
11
+ * none are valid, there is no winner (→ caller surfaces a not-found error).
12
+ *
13
+ * `ownershipByUid` records the per-candidate outcome for Studio diagnostics.
14
+ *
15
+ * The result is deterministic given the candidate order; a residual multi-owner
16
+ * tie is a content mistake (two entries at one URL) reported via diagnostics, not
17
+ * an error — we still return the first valid one.
18
+ */
19
+ function selectUrlWinner(topTier, ownsByUid) {
20
+ const ownershipByUid = new Map();
21
+ // Happy path — a single (or no) top-tier candidate needs no probe.
22
+ if (topTier.length <= 1) {
23
+ if (topTier[0]) {
24
+ ownershipByUid.set(topTier[0].composable_uid, "not-checked");
25
+ }
26
+ return { winnerUid: topTier[0]?.composable_uid, ownershipByUid };
27
+ }
28
+ let winnerUid;
29
+ for (const candidate of topTier) {
30
+ const isFreeform = !candidate.connected_content_type;
31
+ const result = isFreeform
32
+ ? "not-checked"
33
+ : ownsByUid.get(candidate.composable_uid)
34
+ ? "found"
35
+ : "absent";
36
+ ownershipByUid.set(candidate.composable_uid, result);
37
+ if (!winnerUid && (isFreeform || result === "found")) {
38
+ winnerUid = candidate.composable_uid;
39
+ }
40
+ }
41
+ return { winnerUid, ownershipByUid };
42
+ }
43
+
44
+ export { selectUrlWinner };
45
+ //# sourceMappingURL=select-url-winner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-url-winner.js","sources":["../../src/url-metadata/select-url-winner.ts"],"sourcesContent":[null],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,eAAe,CAC7B,OAA0B,EAC1B,SAA+B,EAAA;AAK/B,IAAA,MAAM,cAAc,GAAG,IAAI,GAAG,EAAgC;;AAG9D,IAAA,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE;AACvB,QAAA,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;AACd,YAAA,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,aAAa,CAAC;QAC9D;AACA,QAAA,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,EAAE;IAClE;AAEA,IAAA,IAAI,SAA6B;AACjC,IAAA,KAAK,MAAM,SAAS,IAAI,OAAO,EAAE;AAC/B,QAAA,MAAM,UAAU,GAAG,CAAC,SAAS,CAAC,sBAAsB;QACpD,MAAM,MAAM,GAAyB;AACnC,cAAE;cACA,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc;AACtC,kBAAE;kBACA,QAAQ;QACd,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;QACpD,IAAI,CAAC,SAAS,KAAK,UAAU,IAAI,MAAM,KAAK,OAAO,CAAC,EAAE;AACpD,YAAA,SAAS,GAAG,SAAS,CAAC,cAAc;QACtC;IACF;AAEA,IAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE;AACtC;;;;"}
@@ -0,0 +1,22 @@
1
+ import { parseUrlMetadata } from './parse-url-metadata.js';
2
+ import { COMPOSITION_PREVIEW_URL_SOURCES } from './types.js';
3
+
4
+ /**
5
+ * Determine if the metadata-driven path should be used
6
+ * It means whether we want to fallback to the wildcard routes
7
+ * or parse the URL for variables and determine the composition
8
+ * Returns false if metadata is missing, invalid JSON, or url_source is legacy_url
9
+ *
10
+ * @param url_metadata Raw url_metadata from composition entry
11
+ * @returns true if metadata path should be used, false for legacy path
12
+ */
13
+ function shouldUseUrlMetadataPath(url_metadata) {
14
+ if (!url_metadata) {
15
+ return false;
16
+ }
17
+ const parsed = parseUrlMetadata(url_metadata);
18
+ return parsed.url_source !== COMPOSITION_PREVIEW_URL_SOURCES.LEGACY_URL;
19
+ }
20
+
21
+ export { shouldUseUrlMetadataPath };
22
+ //# sourceMappingURL=shouldUseUrlMetadataPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shouldUseUrlMetadataPath.js","sources":["../../src/url-metadata/shouldUseUrlMetadataPath.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;;;;;;AAQG;AACG,SAAU,wBAAwB,CACtC,YAAwD,EAAA;IAExD,IAAI,CAAC,YAAY,EAAE;AACjB,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,MAAM,MAAM,GAAG,gBAAgB,CAAC,YAAY,CAAC;AAC7C,IAAA,OAAO,MAAM,CAAC,UAAU,KAAK,+BAA+B,CAAC,UAAU;AACzE;;;;"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Composition preview URL source types for CMS field `url_metadata.url_source`
3
+ *
4
+ * These constants define how the composition's preview URL is derived:
5
+ * - From custom preview URLs
6
+ * - From content type URL patterns
7
+ * - From default URL patterns
8
+ * - From user-specified patterns
9
+ * - From legacy URL configuration
10
+ */
11
+ const COMPOSITION_PREVIEW_URL_SOURCES = {
12
+ CUSTOM_PREVIEW_URL: "custom_preview_url",
13
+ CONTENT_TYPE_URL_PATTERN: "content_type_url_pattern",
14
+ DEFAULT_URL_PATTERN: "default_url_pattern",
15
+ USER_SPECIFIED_PATTERN: "user_specified_pattern",
16
+ LEGACY_URL: "legacy_url",
17
+ };
18
+ const COMPOSITION_PREVIEW_URL_SOURCES_VALUES = Object.values(COMPOSITION_PREVIEW_URL_SOURCES);
19
+ // Default URL source configuration
20
+ const DEFAULT_COMPOSITION_PREVIEW_URL_SOURCE = COMPOSITION_PREVIEW_URL_SOURCES.LEGACY_URL;
21
+ // Constants to avoid magic strings and typos for URL pattern variable types
22
+ const URL_PATTERN_VARIABLE_TYPES = {
23
+ ENTRY: "entry",
24
+ TAXONOMY: "taxonomy",
25
+ METADATA: "metadata", // Changed from 'system' to 'metadata'
26
+ DATE: "date",
27
+ // Anonymous `*` glob (legacy linked patterns). Matches exactly one path
28
+ // segment, captures a group for regex alignment, but carries no value and is
29
+ // skipped during variable extraction and query building.
30
+ WILDCARD: "wildcard",
31
+ };
32
+ const URL_PATTERN_METADATA_FIELDS = {
33
+ COMPOSITION_UID: "composition_uid",
34
+ CONTENT_TYPE_UID: "content_type_uid",
35
+ ENVIRONMENT: "environment",
36
+ LOCALE: "locale",
37
+ BRANCH: "branch",
38
+ };
39
+ const URL_PATTERN_METADATA_FIELDS_VALUES = Object.values(URL_PATTERN_METADATA_FIELDS);
40
+ const URL_PATTERN_DATE_VARIABLES = {
41
+ YEAR: "entry_created_date:year",
42
+ YEAR_SHORT: "entry_created_date:year_short",
43
+ MONTH: "entry_created_date:month",
44
+ MONTH_NAME: "entry_created_date:monthname",
45
+ MONTH_NAME_SHORT: "entry_created_date:monthname_short",
46
+ DAY: "entry_created_date:day",
47
+ };
48
+
49
+ 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 };
50
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../src/url-metadata/types.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AAEI,MAAM,+BAA+B,GAAG;AAC7C,IAAA,kBAAkB,EAAE,oBAAoB;AACxC,IAAA,wBAAwB,EAAE,0BAA0B;AACpD,IAAA,mBAAmB,EAAE,qBAAqB;AAC1C,IAAA,sBAAsB,EAAE,wBAAwB;AAChD,IAAA,UAAU,EAAE,YAAY;;AAGnB,MAAM,sCAAsC,GAAG,MAAM,CAAC,MAAM,CACjE,+BAA+B;AAQjC;AACO,MAAM,sCAAsC,GACjD,+BAA+B,CAAC;AA4BlC;AACO,MAAM,0BAA0B,GAAG;AACxC,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;AACpB,IAAA,IAAI,EAAE,MAAM;;;;AAIZ,IAAA,QAAQ,EAAE,UAAU;;AAGf,MAAM,2BAA2B,GAAG;AACzC,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,gBAAgB,EAAE,kBAAkB;AACpC,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,QAAQ;;AAGX,MAAM,kCAAkC,GAAG,MAAM,CAAC,MAAM,CAC7D,2BAA2B;AAQtB,MAAM,0BAA0B,GAAG;AACxC,IAAA,IAAI,EAAE,yBAAyB;AAC/B,IAAA,UAAU,EAAE,+BAA+B;AAC3C,IAAA,KAAK,EAAE,0BAA0B;AACjC,IAAA,UAAU,EAAE,8BAA8B;AAC1C,IAAA,gBAAgB,EAAE,oCAAoC;AACtD,IAAA,GAAG,EAAE,wBAAwB;;;;;"}
@@ -0,0 +1,311 @@
1
+ import { URL_PATTERN_VARIABLE_TYPES, URL_PATTERN_DATE_VARIABLES, URL_PATTERN_METADATA_FIELDS } from './types.js';
2
+
3
+ const METADATA_VARIABLE_NAMES = new Set([
4
+ URL_PATTERN_METADATA_FIELDS.ENVIRONMENT,
5
+ URL_PATTERN_METADATA_FIELDS.LOCALE,
6
+ URL_PATTERN_METADATA_FIELDS.BRANCH,
7
+ URL_PATTERN_METADATA_FIELDS.CONTENT_TYPE_UID,
8
+ URL_PATTERN_METADATA_FIELDS.COMPOSITION_UID,
9
+ ]);
10
+ /**
11
+ * Variable-order entry for an anonymous `*` glob. Carries no value — it only
12
+ * exists so capture-group ↔ variableOrder indexing stays aligned. Skipped during
13
+ * extraction (no case in the `matchUrlPattern` switch).
14
+ */
15
+ const WILDCARD_VARIABLE = {
16
+ type: URL_PATTERN_VARIABLE_TYPES.WILDCARD,
17
+ name: "*",
18
+ category: URL_PATTERN_VARIABLE_TYPES.WILDCARD,
19
+ };
20
+ /**
21
+ * Safely decode a URL component, handling malformed encoding gracefully
22
+ */
23
+ function safeDecodeURIComponent(str) {
24
+ try {
25
+ return decodeURIComponent(str);
26
+ }
27
+ catch (error) {
28
+ // If decoding fails (malformed URL), return original string
29
+ console.warn(`Failed to decode URL component: ${str}`, error);
30
+ return str;
31
+ }
32
+ }
33
+ /**
34
+ * Parse a URL pattern variable placeholder to extract type and name
35
+ * Examples: "entry.title" -> {type: "entry", name: "title", category: "entry"}
36
+ * "entry.group.blocks.block.single_line" -> {type: "entry", name: "group.blocks.block.single_line", category: "entry"}
37
+ * "entry.reference.title" with include: ["reference"] -> {type: "entry", name: "title", category: "entry", referenceName: "reference", referenceField: "title"}
38
+ * "taxonomy:category" -> {type: "taxonomy", name: "category", category: "taxonomy"}
39
+ */
40
+ function parseUrlPatternVariable(placeholder, includeReferences = []) {
41
+ if (placeholder.includes(".")) {
42
+ // Handle nested entry fields: entry.group.blocks.block.single_line
43
+ const [type, ...fieldPathParts] = placeholder.split(".");
44
+ if (type === URL_PATTERN_VARIABLE_TYPES.ENTRY) {
45
+ // Find longest matching reference from include array
46
+ let referenceName;
47
+ let referenceField;
48
+ // Check each potential reference prefix from longest to shortest
49
+ for (let i = fieldPathParts.length - 1; i >= 0; i--) {
50
+ const potentialRef = fieldPathParts.slice(0, i + 1).join(".");
51
+ if (includeReferences.includes(potentialRef)) {
52
+ referenceName = potentialRef;
53
+ referenceField = fieldPathParts.slice(i + 1).join(".");
54
+ break; // Take the longest match
55
+ }
56
+ }
57
+ if (referenceName && referenceField) {
58
+ // This is a reference field
59
+ return {
60
+ type,
61
+ name: fieldPathParts.join("."), // Keep full path for backwards compatibility
62
+ category: URL_PATTERN_VARIABLE_TYPES.ENTRY,
63
+ referenceName,
64
+ referenceField,
65
+ };
66
+ }
67
+ else {
68
+ // Regular nested field
69
+ return {
70
+ type,
71
+ name: fieldPathParts.join("."), // Full nested path as name
72
+ category: URL_PATTERN_VARIABLE_TYPES.ENTRY,
73
+ };
74
+ }
75
+ }
76
+ else {
77
+ // Non-entry type with dots (metadata/system variables)
78
+ const fieldPath = fieldPathParts.join(".");
79
+ return {
80
+ type,
81
+ name: fieldPath,
82
+ category: URL_PATTERN_VARIABLE_TYPES.METADATA,
83
+ };
84
+ }
85
+ }
86
+ else if (placeholder.includes(":")) {
87
+ const [type, name] = placeholder.split(":", 2);
88
+ return {
89
+ type,
90
+ name: type === URL_PATTERN_VARIABLE_TYPES.TAXONOMY ? name : placeholder, // Keep only name for taxonomy, full for dates
91
+ category: type === URL_PATTERN_VARIABLE_TYPES.TAXONOMY
92
+ ? URL_PATTERN_VARIABLE_TYPES.TAXONOMY
93
+ : URL_PATTERN_VARIABLE_TYPES.DATE,
94
+ };
95
+ }
96
+ // Single word variables - classify by name using constants
97
+ if (METADATA_VARIABLE_NAMES.has(placeholder)) {
98
+ return {
99
+ type: URL_PATTERN_VARIABLE_TYPES.METADATA,
100
+ name: placeholder,
101
+ category: URL_PATTERN_VARIABLE_TYPES.METADATA,
102
+ };
103
+ }
104
+ return null; // Unknown variables are not processed
105
+ }
106
+ /**
107
+ * Convert a literal stretch of a pattern into a regex fragment, treating each
108
+ * unescaped `*` as a single-segment wildcard (`([^/]+)`, legacy linked patterns).
109
+ * Pushes a {@link WILDCARD_VARIABLE} to `variableOrder` for every `*` so capture-
110
+ * group ↔ variableOrder indexing stays aligned. `*` contributes nothing to the
111
+ * literal-character count.
112
+ */
113
+ function appendLiteralSegment(literal, variableOrder) {
114
+ const parts = literal.split("*");
115
+ let regexFragment = "";
116
+ let literalChars = 0;
117
+ parts.forEach((part, index) => {
118
+ if (part) {
119
+ regexFragment += escapeRegExp(part);
120
+ literalChars += part.length;
121
+ }
122
+ // A boundary between parts is where a `*` was.
123
+ if (index < parts.length - 1) {
124
+ regexFragment += "([^/]+)";
125
+ variableOrder.push(WILDCARD_VARIABLE);
126
+ }
127
+ });
128
+ return { regexFragment, literalChars };
129
+ }
130
+ /**
131
+ * Compile a URL pattern into a regex that can match and extract variables
132
+ * Handles arbitrary patterns like: "lsefj{{entry.url}}assefs{{content_type_uid}}/{{taxonomy:ola}}"
133
+ */
134
+ function compileUrlPattern(pattern, includeReferences = []) {
135
+ // Decode the pattern in case it contains encoded literals
136
+ const decodedPattern = safeDecodeURIComponent(pattern);
137
+ // Find all {{variable}} placeholders
138
+ const placeholderRegex = /\{\{([^}]+)\}\}/g;
139
+ const variableOrder = [];
140
+ let literalCharCount = 0;
141
+ let lastIndex = 0;
142
+ let regexPattern = "";
143
+ let match;
144
+ while ((match = placeholderRegex.exec(decodedPattern)) !== null) {
145
+ // Add literal text before this placeholder (handling any `*` wildcards)
146
+ const literalPart = decodedPattern.slice(lastIndex, match.index);
147
+ if (literalPart) {
148
+ const { regexFragment, literalChars } = appendLiteralSegment(literalPart, variableOrder);
149
+ regexPattern += regexFragment;
150
+ literalCharCount += literalChars;
151
+ }
152
+ // Parse the variable placeholder
153
+ const variableName = match[1].trim();
154
+ const parsedVar = parseUrlPatternVariable(variableName, includeReferences);
155
+ if (parsedVar) {
156
+ variableOrder.push(parsedVar);
157
+ }
158
+ // Add capture group (non-greedy to stop at next literal)
159
+ regexPattern += "(.+?)";
160
+ lastIndex = placeholderRegex.lastIndex;
161
+ }
162
+ // Add any remaining literal text (handling any `*` wildcards)
163
+ const remainingLiteral = decodedPattern.slice(lastIndex);
164
+ if (remainingLiteral) {
165
+ const { regexFragment, literalChars } = appendLiteralSegment(remainingLiteral, variableOrder);
166
+ regexPattern += regexFragment;
167
+ literalCharCount += literalChars;
168
+ }
169
+ // Handle edge case where pattern ends with variables (make last capture greedy)
170
+ if (variableOrder.length > 0 && pattern.endsWith("}}")) {
171
+ regexPattern = regexPattern.replace(/\(\.\+\?\)$/, "(.+)");
172
+ }
173
+ return {
174
+ regex: new RegExp(`^${regexPattern}$`),
175
+ variableOrder,
176
+ literalCharCount,
177
+ };
178
+ }
179
+ /**
180
+ * Escape special regex characters in literal text
181
+ */
182
+ function escapeRegExp(string) {
183
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
184
+ }
185
+ /**
186
+ * Match a request URL against a compiled pattern and extract variables
187
+ */
188
+ function matchUrlPattern(requestUrl, compiledPattern) {
189
+ // Decode the request URL to handle percent-encoded characters
190
+ const decodedRequestUrl = safeDecodeURIComponent(requestUrl);
191
+ const match = compiledPattern.regex.exec(decodedRequestUrl);
192
+ if (!match) {
193
+ return null;
194
+ }
195
+ const fields = {};
196
+ const taxonomies = {};
197
+ const metadata = {};
198
+ const dateVariables = {};
199
+ // Extract captured groups based on variable order
200
+ for (let i = 0; i < compiledPattern.variableOrder.length; i++) {
201
+ const variable = compiledPattern.variableOrder[i];
202
+ const capturedValue = match[i + 1]; // match[0] is full match, groups start at index 1
203
+ if (capturedValue !== undefined) {
204
+ switch (variable.category) {
205
+ case URL_PATTERN_VARIABLE_TYPES.ENTRY: {
206
+ // Try to parse as number or boolean, fallback to string
207
+ let fieldValue = capturedValue;
208
+ if (capturedValue === "true")
209
+ fieldValue = true;
210
+ else if (capturedValue === "false")
211
+ fieldValue = false;
212
+ else if (!isNaN(Number(capturedValue)) &&
213
+ !isNaN(parseFloat(capturedValue))) {
214
+ fieldValue = Number(capturedValue);
215
+ }
216
+ // Check if this is a reference field
217
+ if (variable.referenceName && variable.referenceField) {
218
+ // Store as nested object: fields["reference"] = { "title": "value" }
219
+ if (!fields[variable.referenceName]) {
220
+ fields[variable.referenceName] = {};
221
+ }
222
+ fields[variable.referenceName][variable.referenceField] = fieldValue;
223
+ }
224
+ else {
225
+ // Store as simple field: fields["title"] = "value"
226
+ fields[variable.name] = fieldValue;
227
+ }
228
+ break;
229
+ }
230
+ case URL_PATTERN_VARIABLE_TYPES.TAXONOMY:
231
+ taxonomies[variable.name] = capturedValue;
232
+ break;
233
+ case URL_PATTERN_VARIABLE_TYPES.METADATA: {
234
+ // Map to specific metadata fields using constants
235
+ if (variable.name === URL_PATTERN_METADATA_FIELDS.COMPOSITION_UID) {
236
+ metadata.composition_uid = capturedValue;
237
+ }
238
+ else if (variable.name === URL_PATTERN_METADATA_FIELDS.CONTENT_TYPE_UID ||
239
+ variable.name === "contentTypeUid") {
240
+ metadata.content_type_uid = capturedValue;
241
+ }
242
+ else if (variable.name === URL_PATTERN_METADATA_FIELDS.ENVIRONMENT) {
243
+ metadata.environment = capturedValue;
244
+ }
245
+ else if (variable.name === URL_PATTERN_METADATA_FIELDS.LOCALE) {
246
+ metadata.locale = capturedValue;
247
+ }
248
+ else if (variable.name === URL_PATTERN_METADATA_FIELDS.BRANCH) {
249
+ metadata.branch = capturedValue;
250
+ }
251
+ break;
252
+ }
253
+ case URL_PATTERN_VARIABLE_TYPES.DATE: {
254
+ // Type-safe assignment for known date variables
255
+ if (Object.values(URL_PATTERN_DATE_VARIABLES).includes(variable.name)) {
256
+ dateVariables[variable.name] = capturedValue;
257
+ }
258
+ break;
259
+ }
260
+ }
261
+ }
262
+ }
263
+ return {
264
+ fields,
265
+ taxonomies,
266
+ metadata,
267
+ dateVariables,
268
+ literalCharCount: compiledPattern.literalCharCount,
269
+ // Full decoded request path — used to build the `{{entry.url}}` full-path
270
+ // `$or` branch (match the `url` field against the whole path).
271
+ requestPath: decodedRequestUrl,
272
+ };
273
+ }
274
+ /**
275
+ * Compute pattern specificity score for ranking
276
+ * Primary: literal character count (more specific)
277
+ * Secondary: total pattern length
278
+ */
279
+ function computePatternSpecificity(pattern) {
280
+ const compiled = compileUrlPattern(pattern);
281
+ return compiled.literalCharCount;
282
+ }
283
+ /**
284
+ * Match a single composition entry against a request URL
285
+ */
286
+ function matchCompositionUrl(requestUrl, compositionUrl, composable_uid, options) {
287
+ try {
288
+ const compiledPattern = compileUrlPattern(compositionUrl, options?.includeReferences || []);
289
+ const variables = matchUrlPattern(requestUrl, compiledPattern);
290
+ if (variables) {
291
+ return {
292
+ matched: true,
293
+ composable_uid,
294
+ variables,
295
+ connected_content_type: options?.connected_content_type,
296
+ };
297
+ }
298
+ }
299
+ catch (error) {
300
+ // Pattern compilation or matching failed - treat as non-match
301
+ console.warn(`Pattern matching failed for composition ${composable_uid}:`, error);
302
+ }
303
+ return {
304
+ matched: false,
305
+ composable_uid,
306
+ connected_content_type: options?.connected_content_type,
307
+ };
308
+ }
309
+
310
+ export { compileUrlPattern, computePatternSpecificity, matchCompositionUrl, matchUrlPattern };
311
+ //# sourceMappingURL=url-pattern-matcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-pattern-matcher.js","sources":["../../src/url-metadata/url-pattern-matcher.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAcA,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;AACtC,IAAA,2BAA2B,CAAC,WAAW;AACvC,IAAA,2BAA2B,CAAC,MAAM;AAClC,IAAA,2BAA2B,CAAC,MAAM;AAClC,IAAA,2BAA2B,CAAC,gBAAgB;AAC5C,IAAA,2BAA2B,CAAC,eAAe;AAC5C,CAAA,CAAC;AAEF;;;;AAIG;AACH,MAAM,iBAAiB,GAA2B;IAChD,IAAI,EAAE,0BAA0B,CAAC,QAAQ;AACzC,IAAA,IAAI,EAAE,GAAG;IACT,QAAQ,EAAE,0BAA0B,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AAI;AACF,QAAA,MAAM,eAAe,GAAG,iBAAiB,CACvC,cAAc,EACd,OAAO,EAAE,iBAAiB,IAAI,EAAE,CACjC;QACD,MAAM,SAAS,GAAG,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC;QAE9D,IAAI,SAAS,EAAE;YACb,OAAO;AACL,gBAAA,OAAO,EAAE,IAAI;gBACb,cAAc;gBACd,SAAS;gBACT,sBAAsB,EAAE,OAAO,EAAE,sBAAsB;aACxD;QACH;IACF;IAAE,OAAO,KAAK,EAAE;;QAEd,OAAO,CAAC,IAAI,CACV,CAAA,wCAAA,EAA2C,cAAc,CAAA,CAAA,CAAG,EAC5D,KAAK,CACN;IACH;IAEA,OAAO;AACL,QAAA,OAAO,EAAE,KAAK;QACd,cAAc;QACd,sBAAsB,EAAE,OAAO,EAAE,sBAAsB;KACxD;AACH;;;;"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Query builder utilities for composition fetching by templateContentTypeUid
3
+ */
4
+ function getPageLinkedPlacementFilter() {
5
+ return {
6
+ $or: [
7
+ { place_composition_as: "page" },
8
+ { place_composition_as: "" },
9
+ { place_composition_as: null },
10
+ { place_composition_as: undefined },
11
+ { place_composition_as: { $exists: false } },
12
+ // Removed because, it was getting the sections as well
13
+ // { connected_content_type: { $exists: true } },
14
+ ],
15
+ };
16
+ }
17
+
18
+ export { getPageLinkedPlacementFilter };
19
+ //# sourceMappingURL=build-composition-fetch-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-composition-fetch-query.js","sources":["../../src/utils/build-composition-fetch-query.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;AAEG;SAEa,4BAA4B,GAAA;IAC1C,OAAO;AACL,QAAA,GAAG,EAAE;YACH,EAAE,oBAAoB,EAAE,MAAM,EAAE;YAChC,EAAE,oBAAoB,EAAE,EAAE,EAAE;YAC5B,EAAE,oBAAoB,EAAE,IAAI,EAAE;YAC9B,EAAE,oBAAoB,EAAE,SAAS,EAAE;AACnC,YAAA,EAAE,oBAAoB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;;;AAG7C,SAAA;KACF;AACH;;;;"}
@@ -101,6 +101,20 @@ class RendererModeUtil {
101
101
  return RendererMode.PREVIEW;
102
102
  }
103
103
  }
104
+ /**
105
+ * Module-level mode util backed by `window.location.search` (the browser URL).
106
+ *
107
+ * SSR CAUTION: this reads `window`, which does not exist on the server, so on the server
108
+ * every method returns its production default (e.g. `isInsideStudioFrame()` -> false) for
109
+ * ALL requests. It is correct ONLY in browser-only code (the editor render, hooks,
110
+ * INIT_STUDIO). In server-reachable fetch code (studio-client's spec-fetch path) do NOT use
111
+ * this: the answer is wrong on the server, and a single shared singleton cannot represent
112
+ * per-request state across concurrent SSR requests anyway. There, use the request-scoped
113
+ * helpers in `sdk.ts` (`isInStudio` / `isEditorFetch` / `readStudioParam`, built on
114
+ * `getRequestSearchParams`), which read the forwarded request query on the server and fall
115
+ * back to `window` on the client. See COMS-1554 for the AsyncLocalStorage proposal that would
116
+ * remove this split and make this util correct everywhere.
117
+ */
104
118
  const clientRendererModeUtil = /* #__PURE__ */ new RendererModeUtil();
105
119
  const serializeComputedStyles = (computedStyle) => {
106
120
  const serializedStyles = {};
@@ -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,IA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5B,MAAM,oBAAoB,GACxB,yCAAyC;AACzC,YAAA,qDAAqD;QACvD,IAAI,oBAAoB,EAAE;YACxB,OAAO,YAAY,CAAC,gBAAgB;QACtC;QACA,OAAO,YAAY,CAAC,OAAO;IAC7B;AACD;AAED;;;;;;;;;;;;;AAaG;MACU,sBAAsB,mBAAmB,IAAI,gBAAgB;AAEnE,MAAM,uBAAuB,GAAG,CACrC,aAAkC,KACR;IAC1B,MAAM,gBAAgB,GAA2B,EAAE;IACnD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC;AACjD,IAAA,KAAK,IAAI,QAAQ,IAAI,eAAe,EAAE;AACpC,QAAA,IAAI;AACF,YAAA,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;AAC9B,YAAA,MAAM,KAAK,GAAG,aAAa,CAAC,QAAqC,CAAC;YAClE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;gBACzC,gBAAgB,CAAC,QAAQ,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;;;;"}
@@ -3,9 +3,26 @@ export { IS_BROWSER } from '@contentstack/studio-messenger';
3
3
  const isBrowser = () => {
4
4
  return typeof window !== "undefined" && typeof global === "undefined";
5
5
  };
6
- const INCLUDE_DEPTH_COUNT = 4;
6
+ /**
7
+ * Depth used for `includeAllDepth` when fetching entries with referenced content.
8
+ *
9
+ * NOTE: This is currently a workaround, not a real fix.
10
+ *
11
+ * The CDA enforces a hard limit of 100 on the number of include reference paths
12
+ * it will process. Exceeding it returns:
13
+ * { error_code: 141, error_message: "The include reference paths processing
14
+ * limit has been exceeded", errors: { include: ["should not be greater than 100"] } }
15
+ *
16
+ * History: started at 5 (worked), hit the 141 error, dropped to 4 (worked again),
17
+ * hit the same error, now at 3. Each step only treats the symptom — the real cause
18
+ * (why our reference path count blows past 100 at higher depths) is still unknown.
19
+ *
20
+ * TODO(COMS-1520): investigate the root cause and replace this magic number with a
21
+ * proper fix instead of lowering the depth each time the limit is hit.
22
+ */
23
+ const INCLUDE_DEPTH_COUNT = 3;
7
24
  // SDK Version constants for Studio Intelligence
8
- const SDK_VERSION = "1.6.0";
25
+ const SDK_VERSION = "1.7.1";
9
26
  const SCHEMA_VERSION = "1.0.0";
10
27
  const COMPOSABLE_DATA_ATTRIBUTES = {
11
28
  BUILDER: "data-composable-studio-builder",