@contentstack/studio-client 0.0.2

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 (93) hide show
  1. package/README.md +37 -0
  2. package/dist/breakpoints/BreakpointManager.js +65 -0
  3. package/dist/breakpoints/BreakpointManager.js.map +1 -0
  4. package/dist/breakpoints/breakpoint.constant.js +31 -0
  5. package/dist/breakpoints/breakpoint.constant.js.map +1 -0
  6. package/dist/breakpoints/breakpoint.js +41 -0
  7. package/dist/breakpoints/breakpoint.js.map +1 -0
  8. package/dist/canvas/canvas.type.js +10 -0
  9. package/dist/canvas/canvas.type.js.map +1 -0
  10. package/dist/canvas/canvas.utils.js +127 -0
  11. package/dist/canvas/canvas.utils.js.map +1 -0
  12. package/dist/composable-studio/data/pre-process-static-values.js +158 -0
  13. package/dist/composable-studio/data/pre-process-static-values.js.map +1 -0
  14. package/dist/composable-studio/initializer-sdk.js +33 -0
  15. package/dist/composable-studio/initializer-sdk.js.map +1 -0
  16. package/dist/composable-studio/sdk.js +527 -0
  17. package/dist/composable-studio/sdk.js.map +1 -0
  18. package/dist/composable-studio/weak-maps.js +7 -0
  19. package/dist/composable-studio/weak-maps.js.map +1 -0
  20. package/dist/config/config.constant.js +4 -0
  21. package/dist/config/config.constant.js.map +1 -0
  22. package/dist/config/config.schema.js +40 -0
  23. package/dist/config/config.schema.js.map +1 -0
  24. package/dist/config/default-config.js +20 -0
  25. package/dist/config/default-config.js.map +1 -0
  26. package/dist/config/process-user-config.js +43 -0
  27. package/dist/config/process-user-config.js.map +1 -0
  28. package/dist/config/stack-sdk-wrapper.js +128 -0
  29. package/dist/config/stack-sdk-wrapper.js.map +1 -0
  30. package/dist/context-menu/context-menu.js +43 -0
  31. package/dist/context-menu/context-menu.js.map +1 -0
  32. package/dist/design/create-class-name-uid.js +13 -0
  33. package/dist/design/create-class-name-uid.js.map +1 -0
  34. package/dist/design/fonts/fonts.constant.js +16 -0
  35. package/dist/design/fonts/fonts.constant.js.map +1 -0
  36. package/dist/design/fonts/index.js +62 -0
  37. package/dist/design/fonts/index.js.map +1 -0
  38. package/dist/design/handle-active-style-change.js +50 -0
  39. package/dist/design/handle-active-style-change.js.map +1 -0
  40. package/dist/dnd/dnd-event.js +29 -0
  41. package/dist/dnd/dnd-event.js.map +1 -0
  42. package/dist/dnd/dnd-manager.js +144 -0
  43. package/dist/dnd/dnd-manager.js.map +1 -0
  44. package/dist/dnd/utils.js +50 -0
  45. package/dist/dnd/utils.js.map +1 -0
  46. package/dist/emitted-events/event-emitter.js +7 -0
  47. package/dist/emitted-events/event-emitter.js.map +1 -0
  48. package/dist/emitted-events/events.constant.js +7 -0
  49. package/dist/emitted-events/events.constant.js.map +1 -0
  50. package/dist/get-active-node-screenshot/get-node-screenshot-event.js +30 -0
  51. package/dist/get-active-node-screenshot/get-node-screenshot-event.js.map +1 -0
  52. package/dist/get-composition-from-slug/get-composition-from-slug.js +59 -0
  53. package/dist/get-composition-from-slug/get-composition-from-slug.js.map +1 -0
  54. package/dist/hidden-element-notification/hidden-element-notification-event.js +26 -0
  55. package/dist/hidden-element-notification/hidden-element-notification-event.js.map +1 -0
  56. package/dist/highlight-node/highlight-node-manager.js +307 -0
  57. package/dist/highlight-node/highlight-node-manager.js.map +1 -0
  58. package/dist/highlight-node/highlight-node.js +213 -0
  59. package/dist/highlight-node/highlight-node.js.map +1 -0
  60. package/dist/highlight-spacing/highlight-spacing-events.js +31 -0
  61. package/dist/highlight-spacing/highlight-spacing-events.js.map +1 -0
  62. package/dist/index.d.ts +719 -0
  63. package/dist/index.js +43 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/json-rte-registry/index.js +47 -0
  66. package/dist/json-rte-registry/index.js.map +1 -0
  67. package/dist/utils/canvas.js +128 -0
  68. package/dist/utils/canvas.js.map +1 -0
  69. package/dist/utils/composable-studio-error.js +27 -0
  70. package/dist/utils/composable-studio-error.js.map +1 -0
  71. package/dist/utils/condition-block.utils.js +23 -0
  72. package/dist/utils/condition-block.utils.js.map +1 -0
  73. package/dist/utils/conditionBlock.js +127 -0
  74. package/dist/utils/conditionBlock.js.map +1 -0
  75. package/dist/utils/constants.js +19 -0
  76. package/dist/utils/constants.js.map +1 -0
  77. package/dist/utils/convertCompositionQueryInputToCompositionQuery.js +19 -0
  78. package/dist/utils/convertCompositionQueryInputToCompositionQuery.js.map +1 -0
  79. package/dist/utils/editor-utils.js +86 -0
  80. package/dist/utils/editor-utils.js.map +1 -0
  81. package/dist/utils/is-composition-being-edited.js +12 -0
  82. package/dist/utils/is-composition-being-edited.js.map +1 -0
  83. package/dist/utils/is-inside-visual-builder-frame.js +12 -0
  84. package/dist/utils/is-inside-visual-builder-frame.js.map +1 -0
  85. package/dist/utils/query-param.js +33 -0
  86. package/dist/utils/query-param.js.map +1 -0
  87. package/dist/utils/reference_fetcher.js +214 -0
  88. package/dist/utils/reference_fetcher.js.map +1 -0
  89. package/dist/utils/sdk.js +66 -0
  90. package/dist/utils/sdk.js.map +1 -0
  91. package/dist/visual-builder/composition-save-event.js +13 -0
  92. package/dist/visual-builder/composition-save-event.js.map +1 -0
  93. package/package.json +57 -0
@@ -0,0 +1,527 @@
1
+ import { COMPOSABLE_STUDIO_QUERY_PARAM } from '@contentstack/studio-messenger';
2
+ import { DATA_SOURCES, DATA_SOURCES_PREFIX } from '@contentstack/studio-registry';
3
+ import { pick } from 'lodash-es';
4
+ import { processUserConfig } from '../config/process-user-config.js';
5
+ import { getCompositionFromSlug } from '../get-composition-from-slug/get-composition-from-slug.js';
6
+ import { INCLUDE_DEPTH_COUNT } from '../utils/constants.js';
7
+ import { isCompositionBeingEdited } from '../utils/is-composition-being-edited.js';
8
+ import { entriesFromResponse, setTemplateEntryInDS, setStaticEntryInDS } from '../utils/sdk.js';
9
+ import { ComposableStudioError, ComposableStudioErrors } from '../utils/composable-studio-error.js';
10
+ import { clientRendererModeUtil, RendererModeUtil } from '../utils/canvas.js';
11
+ import { getEntriesQueries } from '../utils/reference_fetcher.js';
12
+ import { preProcessStaticValues } from './data/pre-process-static-values.js';
13
+ import { convertCompositionQueryInputToCompositionQuery } from '../utils/convertCompositionQueryInputToCompositionQuery.js';
14
+
15
+ function addEditableTags(entry, contentTypeUid, tagsAsObject, locale = "en-us") {
16
+ if (entry) {
17
+ const appliedVariants = entry._applied_variants || entry?.system?.applied_variants || null;
18
+ entry.$ = getTag(entry, `${contentTypeUid}.${entry.uid}.${locale}`, tagsAsObject, locale, {
19
+ _applied_variants: appliedVariants,
20
+ shouldApplyVariant: !!appliedVariants,
21
+ metaKey: "",
22
+ });
23
+ }
24
+ }
25
+ function getTag(content, prefix, tagsAsObject, locale, appliedVariants) {
26
+ const tags = {};
27
+ const { shouldApplyVariant, _applied_variants } = appliedVariants;
28
+ Object.entries(content).forEach(([key, value]) => {
29
+ if (key === "$")
30
+ return;
31
+ let metaUID = value &&
32
+ typeof value === "object" &&
33
+ value._metadata &&
34
+ value._metadata.uid
35
+ ? value._metadata.uid
36
+ : "";
37
+ let updatedMetakey = appliedVariants.shouldApplyVariant
38
+ ? `${appliedVariants.metaKey ? appliedVariants.metaKey + "." : ""}${key}`
39
+ : "";
40
+ if (metaUID && updatedMetakey)
41
+ updatedMetakey = updatedMetakey + "." + metaUID;
42
+ switch (typeof value) {
43
+ case "object":
44
+ if (Array.isArray(value)) {
45
+ value.forEach((obj, index) => {
46
+ const childKey = `${key}__${index}`;
47
+ const parentKey = `${key}__parent`;
48
+ metaUID =
49
+ value &&
50
+ typeof value === "object" &&
51
+ obj._metadata &&
52
+ obj._metadata.uid
53
+ ? obj._metadata.uid
54
+ : "";
55
+ updatedMetakey = appliedVariants.shouldApplyVariant
56
+ ? `${appliedVariants.metaKey ? appliedVariants.metaKey + "." : ""}${key}`
57
+ : "";
58
+ if (metaUID && updatedMetakey)
59
+ updatedMetakey = updatedMetakey + "." + metaUID;
60
+ /**
61
+ * Indexes of array are handled here
62
+ * {
63
+ * "array": ["hello", "world"],
64
+ * "$": {
65
+ * "array": {"data-cslp": "content_type_uid.entry_uid.locale.array"}
66
+ * "array__0": {"data-cslp": "content_type_uid.entry_uid.locale.array.0"}
67
+ * "array__1": {"data-cslp": "content_type_uid.entry_uid.locale.array.1"}
68
+ * }
69
+ * }
70
+ */
71
+ tags[childKey] = getTagsValue(`${prefix}.${key}.${index}`, tagsAsObject, {
72
+ _applied_variants,
73
+ shouldApplyVariant,
74
+ metaKey: updatedMetakey,
75
+ });
76
+ tags[parentKey] = getParentTagsValue(`${prefix}.${key}`);
77
+ if (typeof obj !== "undefined" &&
78
+ obj !== null &&
79
+ obj._content_type_uid !== undefined &&
80
+ obj.uid !== undefined) {
81
+ /**
82
+ * References are handled here
83
+ * {
84
+ * "reference": [{
85
+ * "title": "title",
86
+ * "uid": "ref_uid",
87
+ * "_content_type_uid": "ref_content_type_uid",
88
+ * "$": {"title": {"data-cslp": "ref_content_type_uid.ref_uid.locale.title"}}
89
+ * }]
90
+ * }
91
+ */
92
+ const newAppliedVariants = obj._applied_variants ||
93
+ obj?.system?.applied_variants ||
94
+ _applied_variants;
95
+ const newShouldApplyVariant = !!newAppliedVariants;
96
+ value[index].$ = getTag(obj, `${obj._content_type_uid}.${obj.uid}.${obj.locale || locale}`, tagsAsObject, locale, {
97
+ _applied_variants: newAppliedVariants,
98
+ shouldApplyVariant: newShouldApplyVariant,
99
+ metaKey: "",
100
+ });
101
+ }
102
+ else if (typeof obj === "object") {
103
+ /**
104
+ * Objects inside Array like modular blocks are handled here
105
+ * {
106
+ * "array": [{
107
+ * "title": "title",
108
+ * "$": {"title": {"data-cslp": "content_type_uid.entry_uid.locale.array.0.title"}}
109
+ * }]
110
+ * }
111
+ */
112
+ obj.$ = getTag(obj, `${prefix}.${key}.${index}`, tagsAsObject, locale, {
113
+ _applied_variants,
114
+ shouldApplyVariant,
115
+ metaKey: updatedMetakey,
116
+ });
117
+ }
118
+ });
119
+ }
120
+ else {
121
+ if (value) {
122
+ /**
123
+ * Objects are handled here
124
+ * {
125
+ * "object": {
126
+ * "title": "title",
127
+ * "$": {
128
+ * "title": {"data-cslp": "content_type_uid.entry_uid.locale.object.title"}
129
+ * }
130
+ * },
131
+ * }
132
+ */
133
+ value.$ = getTag(value, `${prefix}.${key}`, tagsAsObject, locale, {
134
+ _applied_variants,
135
+ shouldApplyVariant,
136
+ metaKey: updatedMetakey,
137
+ });
138
+ }
139
+ }
140
+ /**
141
+ * {
142
+ * "object": {
143
+ * "title": "title",
144
+ * },
145
+ * "array": ["hello", "world"]
146
+ * "$": {
147
+ * "object": {"data-cslp": "content_type_uid.entry_uid.locale.object"},
148
+ * "array": {"data-cslp": "content_type_uid.entry_uid.locale.array"}
149
+ * }
150
+ * }
151
+ */
152
+ tags[key] = getTagsValue(`${prefix}.${key}`, tagsAsObject, {
153
+ _applied_variants,
154
+ shouldApplyVariant,
155
+ metaKey: updatedMetakey,
156
+ });
157
+ break;
158
+ default:
159
+ /**
160
+ * All primitive values are handled here
161
+ * {
162
+ * "title": "title",
163
+ * "$": {title: {"data-cslp": "content_type_uid.entry_uid.locale.title"}}
164
+ * }
165
+ */
166
+ tags[key] = getTagsValue(`${prefix}.${key}`, tagsAsObject, {
167
+ _applied_variants,
168
+ shouldApplyVariant,
169
+ metaKey: updatedMetakey,
170
+ });
171
+ }
172
+ });
173
+ return tags;
174
+ }
175
+ function getTagsValue(dataValue, tagsAsObject, appliedVariants) {
176
+ if (appliedVariants.shouldApplyVariant &&
177
+ appliedVariants._applied_variants &&
178
+ appliedVariants._applied_variants[appliedVariants.metaKey]) {
179
+ const variant = appliedVariants._applied_variants[appliedVariants.metaKey];
180
+ // Adding v2 prefix to the cslp tag. New cslp tags are in v2 format. ex: v2:content_type_uid.entry_uid.locale.title
181
+ const newDataValueArray = ("v2:" + dataValue).split(".");
182
+ newDataValueArray[1] = newDataValueArray[1] + "_" + variant;
183
+ dataValue = newDataValueArray.join(".");
184
+ }
185
+ {
186
+ return { "data-cslp": dataValue };
187
+ }
188
+ }
189
+ function getParentTagsValue(dataValue, tagsAsObject) {
190
+ {
191
+ return { "data-cslp-parent-field": dataValue };
192
+ }
193
+ }
194
+ function generateSdk(userConfig) {
195
+ const config = processUserConfig(userConfig);
196
+ if (clientRendererModeUtil.isInsideStudioFrame()) {
197
+ const hash = new URLSearchParams(window.location.search).get(COMPOSABLE_STUDIO_QUERY_PARAM.PREVIEW_HASH) || "";
198
+ config.stackSdk.livePreviewQuery?.(hash);
199
+ }
200
+ async function resolveStaticData(staticBindingQueries, staticBindingOnlyQueries, data, options = {}) {
201
+ const { variantAlias } = options;
202
+ try {
203
+ const promises = [];
204
+ for (const _content_type_uid in staticBindingQueries) {
205
+ const ct_promises = [];
206
+ for (const entry_uid in staticBindingQueries[_content_type_uid]) {
207
+ const references = staticBindingQueries[_content_type_uid][entry_uid];
208
+ const onlyQuery = staticBindingOnlyQueries[_content_type_uid][entry_uid] || [];
209
+ // We need locale for redirect to the correct locale.
210
+ if (config.cslp.appendTags) {
211
+ onlyQuery.push(["BASE", "locale"]);
212
+ }
213
+ const query = config.stackSdk.entryQuery(_content_type_uid, entry_uid, {
214
+ only: onlyQuery,
215
+ variantAlias,
216
+ });
217
+ if (references.length) {
218
+ query.includeReference(references);
219
+ }
220
+ ct_promises.push(query.fetch());
221
+ }
222
+ promises.push(Promise.allSettled(ct_promises));
223
+ }
224
+ const ct_entries_res = await Promise.allSettled(promises);
225
+ const ct_uids = Object.keys(staticBindingQueries);
226
+ for (let i = 0; i < ct_entries_res.length; i++) {
227
+ const ct_entries = ct_entries_res[i];
228
+ const ct_uid = ct_uids[i];
229
+ if (ct_entries.status === "fulfilled") {
230
+ for (const entry of ct_entries.value) {
231
+ if (entry.status === "fulfilled") {
232
+ setStaticEntryInDS(data.dataSources, ct_uid, [entry.value]);
233
+ if (config.cslp.appendTags) {
234
+ addEditableTags(entry.value, ct_uid, true, entry.value?.locale || "en-us");
235
+ }
236
+ }
237
+ else {
238
+ //TODO: Add logger support general to have studio prefix
239
+ console.error("Unable to resolve entry", entry.reason);
240
+ }
241
+ }
242
+ }
243
+ else {
244
+ console.error("Unable to resolve content type", ct_uid, ct_entries.reason);
245
+ }
246
+ }
247
+ }
248
+ catch (err) {
249
+ console.error("Error while resolving static data", err);
250
+ }
251
+ }
252
+ /**
253
+ * When composition is binded to a content type, we need to fetch the entry for that content type. Called template entry.
254
+ */
255
+ async function fetchTemplateEntry(options, data) {
256
+ if (!config.stackSdk) {
257
+ console.error("Fetching template entry not possible without stackSdk");
258
+ return;
259
+ }
260
+ const { connected_content_type, compositionQuery, includeQueries, onlyQueries, } = options;
261
+ if (!connected_content_type) {
262
+ return;
263
+ }
264
+ let dataQuery = config.stackSdk
265
+ .ctQuery(connected_content_type, {
266
+ references: includeQueries,
267
+ only: onlyQueries,
268
+ variantAlias: options.variantAlias,
269
+ })
270
+ .limit(1);
271
+ if ("url" in compositionQuery) {
272
+ dataQuery = config.stackSdk.where(dataQuery, "url", compositionQuery.url);
273
+ }
274
+ // We used the `find` instead of `findOne` because it
275
+ // caused issues with the fetch data.
276
+ const response = await dataQuery.find().catch((err) => {
277
+ console.error("Error fetching connected data", err);
278
+ throw new ComposableStudioError(ComposableStudioErrors.FETCHING_CONNECTED_DATA_FAILED, "Failed to fetch connected data", {
279
+ options,
280
+ response: err,
281
+ });
282
+ });
283
+ const entries = entriesFromResponse(response);
284
+ if (!entries?.[0]) {
285
+ return;
286
+ }
287
+ const entry = entries[0];
288
+ if (config.cslp.appendTags) {
289
+ addEditableTags(entry, connected_content_type, true, entry.locale);
290
+ }
291
+ setTemplateEntryInDS(data.dataSources, entry);
292
+ if (!isCompositionBeingEdited(options?.composableUid || ""))
293
+ return;
294
+ }
295
+ async function fetchSpec(queryOptions, options) {
296
+ const { variantAlias } = options || {};
297
+ if (!config.stackSdk) {
298
+ throw new ComposableStudioError(ComposableStudioErrors.STACK_SDK_NOT_AVAILABLE, "Stack SDK not available to fetch composition.");
299
+ }
300
+ const { compositionEntry, symbolEntries } = await fetchComposition(config, queryOptions);
301
+ // This will iterate over ui and collect all data to fetch ( entries and depth of refrerences for both template and static contentstack)
302
+ const { templateReferencesPath, templateOnlyKeys, contentstackEntriesReferencesPath, contentstackEntriesOnlyKeys, } = getEntriesQueries(compositionEntry, compositionEntry.connected_content_type || "", options);
303
+ const page = typeof compositionEntry.ui === "string"
304
+ ? JSON.parse(compositionEntry.ui)
305
+ : compositionEntry.ui;
306
+ const ui = page;
307
+ const data = {
308
+ [DATA_SOURCES_PREFIX]: {},
309
+ [DATA_SOURCES.STATIC_VALUE]: preProcessStaticValues(compositionEntry.static_value || {}),
310
+ };
311
+ // TODO: Add a variantAlias to the fetchTemplateEntry and resolveStaticData.
312
+ await Promise.all([
313
+ fetchTemplateEntry({
314
+ connected_content_type: compositionEntry.connected_content_type || "",
315
+ compositionQuery: queryOptions,
316
+ includeQueries: templateReferencesPath,
317
+ onlyQueries: templateOnlyKeys,
318
+ composableUid: compositionEntry.composable_uid,
319
+ variantAlias: variantAlias,
320
+ }, data),
321
+ resolveStaticData(contentstackEntriesReferencesPath, contentstackEntriesOnlyKeys, data, {
322
+ variantAlias: variantAlias,
323
+ }),
324
+ ]);
325
+ return {
326
+ data,
327
+ ui,
328
+ compositionEntry,
329
+ //TODO: Need to fetch symbols from the server
330
+ symbols: symbolEntries,
331
+ config: getLightConfig(),
332
+ };
333
+ }
334
+ function getLightConfig() {
335
+ return pick(config, ["openInStudioButton", "contentTypeUid", "cslp"]);
336
+ }
337
+ function getSeoMetadata(ui) {
338
+ return ui.metadata.seo || null;
339
+ }
340
+ return {
341
+ internal: {
342
+ getConfig() {
343
+ return config;
344
+ },
345
+ isInsideStudioFrame: clientRendererModeUtil.isInsideStudioFrame,
346
+ // Once we fetch the data, we need to perform certain operation to store the UI and data.
347
+ // Hence, we moved this to the internal method.
348
+ fetchSpec,
349
+ fetchTemplateEntry,
350
+ getSeoMetadata,
351
+ },
352
+ public: {
353
+ // Exposing this method for the user to fetch the data.
354
+ /**
355
+ * This method is used to fetch the composition data for the SSR.
356
+ *
357
+ * @param queryOptions - The query options for the composition.
358
+ * @param options - The options for the composition.
359
+ * @returns The composition data for the SSR.
360
+ */
361
+ fetchCompositionData: async (queryOptions, options) => {
362
+ if (!config.stackSdk) {
363
+ throw new ComposableStudioError(ComposableStudioErrors.STACK_SDK_NOT_AVAILABLE, "Stack SDK not available to fetch composition.");
364
+ }
365
+ const { searchQuery, ...compositionQueryInput } = queryOptions;
366
+ const compositionQuery = convertCompositionQueryInputToCompositionQuery(compositionQueryInput);
367
+ const urlSearchParam = new URLSearchParams(searchQuery);
368
+ const rendererModeUtil = new RendererModeUtil(urlSearchParam);
369
+ // If queryOptions has composableUid and we are editing the current composition, we don't need to fetch the spec.
370
+ if ("compositionUid" in queryOptions &&
371
+ rendererModeUtil.isEditingCurrentComposition(queryOptions.compositionUid || "")) {
372
+ return {
373
+ spec: null,
374
+ fetchOptions: {
375
+ searchQuery: urlSearchParam.toString(),
376
+ compositionQuery,
377
+ config: getLightConfig(),
378
+ options,
379
+ mode: rendererModeUtil.getMode(queryOptions.compositionUid || ""),
380
+ },
381
+ hasSpec: true,
382
+ hasTemplate: true,
383
+ seo: null,
384
+ };
385
+ }
386
+ const spec = await fetchSpec(compositionQuery, options);
387
+ if (rendererModeUtil.isEditingCurrentComposition(spec.compositionEntry.composable_uid || "")) {
388
+ return {
389
+ spec: null,
390
+ fetchOptions: {
391
+ searchQuery: urlSearchParam.toString(),
392
+ compositionQuery,
393
+ config: getLightConfig(),
394
+ options,
395
+ mode: rendererModeUtil.getMode(spec.compositionEntry.composable_uid),
396
+ },
397
+ hasSpec: true,
398
+ hasTemplate: true,
399
+ seo: null,
400
+ };
401
+ }
402
+ config.stackSdk.livePreviewQuery(urlSearchParam.get(COMPOSABLE_STUDIO_QUERY_PARAM.PREVIEW_HASH) ||
403
+ urlSearchParam.get(COMPOSABLE_STUDIO_QUERY_PARAM.LIVE_PREVIEW_HASH) ||
404
+ "");
405
+ return {
406
+ spec,
407
+ hasSpec: !!spec.compositionEntry,
408
+ hasTemplate: !!spec.data.dataSources[DATA_SOURCES.TEMPLATE],
409
+ fetchOptions: {
410
+ // TODO: @Nilesh - see if we can remove this as this config is already available in the spec.
411
+ config: getLightConfig(),
412
+ compositionQuery,
413
+ options,
414
+ searchQuery: urlSearchParam.toString(),
415
+ mode: rendererModeUtil.getMode(spec.compositionEntry.composable_uid),
416
+ },
417
+ seo: getSeoMetadata(spec.ui),
418
+ };
419
+ },
420
+ /**
421
+ * This method is used to get the configuration for the client.
422
+ *
423
+ * @returns The configuration for the client.
424
+ */
425
+ getConfig: getLightConfig,
426
+ },
427
+ };
428
+ }
429
+ const parseUI = (ui) => {
430
+ try {
431
+ return JSON.parse(ui);
432
+ }
433
+ catch (error) {
434
+ //TODO: Create a fallback for UI Error
435
+ return {};
436
+ }
437
+ };
438
+ function getAllSymbols(compositionEntry) {
439
+ const res = [];
440
+ const Q = [compositionEntry];
441
+ while (Q.length > 0) {
442
+ const curr = Q.shift();
443
+ const symbols = (curr?.symbols || []);
444
+ for (const symbol of symbols) {
445
+ symbol.ui = parseUI(symbol.ui);
446
+ res.push(symbol);
447
+ Q.push(symbol);
448
+ }
449
+ }
450
+ return res;
451
+ }
452
+ /**
453
+ * This function fetches UI Composition from defined options.
454
+ **/
455
+ async function fetchComposition(config, options) {
456
+ let uiQuery;
457
+ if ("composableUid" in options) {
458
+ uiQuery = config.stackSdk.where(config.stackSdk.ctQuery(config.contentTypeUid), "composable_uid", options.composableUid);
459
+ const response = await uiQuery
460
+ .find()
461
+ .then((res) => {
462
+ let response;
463
+ if (Array.isArray(res)) {
464
+ response = res[0][0];
465
+ }
466
+ else {
467
+ response = res.entries[0];
468
+ }
469
+ if (!response) {
470
+ throw new ComposableStudioError(ComposableStudioErrors.COMPOSITION_NOT_FOUND, "Composition not found", {
471
+ options,
472
+ response: "Composition not found",
473
+ });
474
+ }
475
+ return response;
476
+ })
477
+ .catch((err) => {
478
+ console.error("Could not fetch Composition", err);
479
+ throw new ComposableStudioError(ComposableStudioErrors.COMPOSITION_NOT_FOUND, "Composition not found", // TODO: Add more details - Add potential solution to check if the user changed the content type.
480
+ {
481
+ options,
482
+ response: err,
483
+ });
484
+ });
485
+ return {
486
+ compositionEntry: response,
487
+ symbolEntries: getAllSymbols(response),
488
+ };
489
+ }
490
+ else if ("url" in options) {
491
+ return await config.stackSdk
492
+ .ctQuery(config.contentTypeUid, {
493
+ includeAll: true,
494
+ includeAllDepth: INCLUDE_DEPTH_COUNT,
495
+ })
496
+ .find()
497
+ .then((res) => {
498
+ const entries = entriesFromResponse(res);
499
+ const entry = getCompositionFromSlug(options.url, entries);
500
+ if (!entry) {
501
+ // TODO: Throw a different error here, and handle both in the catch block below.
502
+ throw new ComposableStudioError(ComposableStudioErrors.COMPOSITION_NOT_FOUND,
503
+ // TODO: Add more details - Add potential solution to check if the user changed the content type.
504
+ "Composition not found", {
505
+ options,
506
+ });
507
+ }
508
+ return {
509
+ compositionEntry: entry,
510
+ symbolEntries: getAllSymbols(entry),
511
+ };
512
+ })
513
+ .catch((err) => {
514
+ // This error is different. Here, we have issues while fetching the entries.
515
+ console.error("Could not fetch Composition", err);
516
+ throw new ComposableStudioError(ComposableStudioErrors.COMPOSITION_NOT_FOUND, "Composition not found");
517
+ });
518
+ }
519
+ else {
520
+ throw new ComposableStudioError(ComposableStudioErrors.INVALID_FETCH_SPEC_OPTIONS, "Please provide either composableUid or url to fetch the composition.", {
521
+ options,
522
+ });
523
+ }
524
+ }
525
+
526
+ export { generateSdk, parseUI };
527
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","sources":["../../src/composable-studio/sdk.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;AA4CA,SAAS,eAAe,CACtB,KAAiB,EACjB,cAAsB,EACtB,YAAqB,EACrB,MAAA,GAAiB,OAAO,EAAA;IAExB,IAAI,KAAK,EAAE;AACT,QAAA,MAAM,eAAe,GACnB,KAAK,CAAC,iBAAiB,IAAI,KAAK,EAAE,MAAM,E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MAAM,MAAM,CAAC;AACjB,aAAA,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE;AAC9B,YAAA,UAAU,EAAE,IAAI;AAChB,YAAA,eAAe,EAAE,mBAAmB;SACrC;AACA,aAAA,IAAI;AACJ,aAAA,IAAI,CAAC,CAAC,GAA2D,KAAI;AACpE,YAAA,MAAM,OAAO,GACX,mBAAmB,CAAmB,GAAG,CAAC;YAE5C,MAAM,KAAK,GAAG,sBAAsB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC;YAC1D,IAAI,CAAC,KAAK,EAAE;;AAEV,gBAAA,MAAM,IAAI,qBAAqB,CAC7B,sBAAsB,CAAC,qBAAqB;;AAE5C,gBAAA,uBAAuB,EACvB;oBACE,OAAO;AACR,iBAAA,CACF;YACH;YAEA,OAAO;AACL,gBAAA,gBAAgB,EAAE,KAAK;AACvB,gBAAA,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC;aACpC;AACH,QAAA,CAAC;AACA,aAAA,KAAK,CAAC,CAAC,GAAQ,KAAI;;AAElB,YAAA,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC;YACjD,MAAM,IAAI,qBAAqB,CAC7B,sBAAsB,CAAC,qBAAqB,EAC5C,uBAAuB,CACxB;AACH,QAAA,CAAC,CAAC;IACN;SAAO;QACL,MAAM,IAAI,qBAAqB,CAC7B,sBAAsB,CAAC,0BAA0B,EACjD,sEAAsE,EACtE;YACE,OAAO;AACR,SAAA,CACF;IACH;AACF;;;;"}
@@ -0,0 +1,7 @@
1
+ const ELEMENT_TO_NODE = new WeakMap();
2
+ const NODE_TO_ELEMENT = new WeakMap();
3
+ const NODE_TO_PATH_NODE = new WeakMap();
4
+ const NODE_TO_PARENT = new WeakMap();
5
+
6
+ export { ELEMENT_TO_NODE, NODE_TO_ELEMENT, NODE_TO_PARENT, NODE_TO_PATH_NODE };
7
+ //# sourceMappingURL=weak-maps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weak-maps.js","sources":["../../src/composable-studio/weak-maps.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEO,MAAM,eAAe,GAAG,IAAI,OAAO;AACnC,MAAM,eAAe,GAAG,IAAI,OAAO;AACnC,MAAM,iBAAiB,GAAG,IAAI,OAAO;AACrC,MAAM,cAAc,GAAG,IAAI,OAAO;;;;"}
@@ -0,0 +1,4 @@
1
+ const DEFAULT_COMPOSITION_TYPE_UID = "compositions";
2
+
3
+ export { DEFAULT_COMPOSITION_TYPE_UID };
4
+ //# sourceMappingURL=config.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.constant.js","sources":["../../src/config/config.constant.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,4BAA4B,GAAG;;;;"}
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+
3
+ const editButtonInBuilderPosition = z.enum([
4
+ "top",
5
+ "top-left",
6
+ "top-right",
7
+ "top-center",
8
+ "bottom",
9
+ "bottom-left",
10
+ "bottom-right",
11
+ "bottom-center",
12
+ ]);
13
+ const userConfigSchema = z.object({
14
+ /**
15
+ * Visual type to be used for storing the UI
16
+ */
17
+ contentTypeUid: z.string().optional(),
18
+ stackSdk: z.custom((obj) => {
19
+ const sdkHasAllRequiredProperty = ["livePreviewQuery"].every((key) => {
20
+ // Since the functions are in the prototype,
21
+ // we cannot use `hasOwnProperty()` to check for the property.
22
+ return key in obj;
23
+ });
24
+ return sdkHasAllRequiredProperty;
25
+ }),
26
+ cslp: z
27
+ .object({
28
+ appendTags: z.boolean().optional(),
29
+ })
30
+ .optional(),
31
+ openInStudioButton: z
32
+ .object({
33
+ enable: z.boolean().optional(),
34
+ position: editButtonInBuilderPosition.optional(),
35
+ })
36
+ .optional(),
37
+ });
38
+
39
+ export { editButtonInBuilderPosition, userConfigSchema };
40
+ //# sourceMappingURL=config.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.schema.js","sources":["../../src/config/config.schema.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGO,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC;IAChD,KAAK;IACL,UAAU;IACV,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,aAAa;IACb,cAAc;IACd,eAAe;AAChB,CAAA;AAEM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;AACvC;;AAEG;AACH,IAAA,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACrC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAc,CAAC,GAAG,KAAI;QACtC,MAAM,yBAAyB,GAAG,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,KAAI;;;YAGnE,OAAO,GAAG,IAAI,GAAG;AACnB,QAAA,CAAC,CAAC;AAEF,QAAA,OAAO,yBAAyB;AAClC,IAAA,CAAC,CAAC;AACF,IAAA,IAAI,EAAE;AACH,SAAA,MAAM,CAAC;AACN,QAAA,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;KACnC;AACA,SAAA,QAAQ,EAAE;AACb,IAAA,kBAAkB,EAAE;AACjB,SAAA,MAAM,CAAC;AACN,QAAA,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;AAC9B,QAAA,QAAQ,EAAE,2BAA2B,CAAC,QAAQ,EAAE;KACjD;AACA,SAAA,QAAQ,EAAE;AACd,CAAA;;;;"}
@@ -0,0 +1,20 @@
1
+ function getDefaultConfig() {
2
+ return {
3
+ contentTypeUid: "",
4
+ /**
5
+ * We should not face any issues with the following line
6
+ * as we provide the proper value after initializing.
7
+ */
8
+ stackSdk: {},
9
+ cslp: {
10
+ appendTags: false,
11
+ },
12
+ openInStudioButton: {
13
+ enable: true,
14
+ position: "bottom",
15
+ },
16
+ };
17
+ }
18
+
19
+ export { getDefaultConfig };
20
+ //# sourceMappingURL=default-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-config.js","sources":["../../src/config/default-config.ts"],"sourcesContent":[null],"names":[],"mappings":"SAGgB,gBAAgB,GAAA;IAC9B,OAAO;AACL,QAAA,cAAc,EAAE,EAAE;AAClB;;;AAGG;AACH,QAAA,QAAQ,EAAE,EAAyB;AACnC,QAAA,IAAI,EAAE;AACJ,YAAA,UAAU,EAAE,KAAK;AAClB,SAAA;AACD,QAAA,kBAAkB,EAAE;AAClB,YAAA,MAAM,EAAE,IAAI;AACZ,YAAA,QAAQ,EAAE,QAAQ;AACnB,SAAA;KACF;AACH;;;;"}