@designcrowd/library.brand-page 5.19.1-id-based-items-2 → 5.19.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 (52) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-Ruu5Az32.js → CreatedOnBrandCrowd-de-de-BmeMc9oz.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-DGUJtvld.js → CreatedOnBrandCrowd-en-us-CQNdm_6P.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-Dg-1uOfV.js → CreatedOnBrandCrowd-es-es-BrmHWeAM.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-CRKraZl8.js → CreatedOnBrandCrowd-fr-ca-CaIyjTXl.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-CRKraZl8.js → CreatedOnBrandCrowd-fr-fr-CaIyjTXl.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-bZ9VlEAu.js → CreatedOnBrandCrowd-pt-br-BClE0Nd9.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-bZ9VlEAu.js → CreatedOnBrandCrowd-pt-pt-BClE0Nd9.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-CJYfwZx8.js → CreatedOnDcom-de-de-CkrdlPqK.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-rzA1lVxH.js → CreatedOnDcom-en-us-D33J9qky.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-CNwGPjik.js → CreatedOnDcom-es-es-BsmInngw.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-DKw7OGIz.js → CreatedOnDcom-fr-ca-DOXlsRea.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-WzOEaAZG.js → CreatedOnDcom-fr-fr-SfFYLtyn.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-DkualVhm.js → CreatedOnDcom-pt-br-DcWeuZUy.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-w4Nnsdzq.js → CreatedOnDcom-pt-pt-DZsZZ4iX.js} +1 -1
  15. package/lib/src/brand-page/components/image-gallery/masonry/MasonryGallery.mixin.d.ts +1 -1
  16. package/lib/src/brand-page/models/index.d.ts +0 -12
  17. package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +0 -5
  18. package/lib/src/brand-page-maker/stores/ai-checkpoint/ai-checkpoint-store.d.ts +0 -18
  19. package/lib/src/index.mjs +1 -1
  20. package/lib/src/{lib-Dy7MYyqz.js → lib-C5vGkjfs.js} +17577 -17407
  21. package/lib/src/metadata-builder/builders/footer-builder.js +44 -34
  22. package/lib/src/metadata-builder/builders/section-builders/image-gallery-builder.js +68 -57
  23. package/lib/src/metadata-builder/builders/section-builders/images-section-builder.js +93 -58
  24. package/lib/src/metadata-builder/builders/section-builders/shapes-section-builder.js +99 -66
  25. package/lib/src/metadata-builder/builders/section-builders/social-links-builder.js +17 -57
  26. package/lib/src/metadata-builder/builders/section-builders/testimonial-section-builder.js +85 -51
  27. package/lib/src/metadata-builder/builders/section-builders/text-section-builder.js +74 -49
  28. package/lib/src/metadata-builder/parsers/ai-toolcall-parser.d.ts +4 -13
  29. package/lib/src/metadata-builder/parsers/section-tool-arguments.d.ts +48 -66
  30. package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +0 -2
  31. package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +0 -2
  32. package/lib/src/utils/minify-brand-page-metadata.d.ts +0 -2
  33. package/lib/src/utils/minify-brand-page-metadata.js +1 -8
  34. package/package.json +1 -1
  35. package/src/brand-page/components/image-gallery/masonry/MasonryGallery.mixin.ts +1 -2
  36. package/src/brand-page/models/index.ts +0 -12
  37. package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +0 -6
  38. package/src/metadata-builder/builders/footer-builder.test.ts +0 -298
  39. package/src/metadata-builder/builders/footer-builder.ts +65 -56
  40. package/src/metadata-builder/builders/section-builders/image-gallery-builder.ts +88 -62
  41. package/src/metadata-builder/builders/section-builders/images-section-builder.ts +129 -66
  42. package/src/metadata-builder/builders/section-builders/shapes-section-builder.ts +160 -105
  43. package/src/metadata-builder/builders/section-builders/social-links-builder.ts +20 -65
  44. package/src/metadata-builder/builders/section-builders/testimonial-section-builder.ts +146 -83
  45. package/src/metadata-builder/builders/section-builders/text-section-builder.ts +122 -70
  46. package/src/metadata-builder/parsers/ai-toolcall-parser.ts +4 -13
  47. package/src/metadata-builder/parsers/section-tool-arguments.ts +48 -66
  48. package/src/utils/minify-brand-page-metadata.ts +2 -14
  49. package/lib/src/metadata-builder/builders/item-id-utils.d.ts +0 -54
  50. package/lib/src/metadata-builder/builders/item-id-utils.js +0 -96
  51. package/src/metadata-builder/builders/item-id-utils.test.ts +0 -184
  52. package/src/metadata-builder/builders/item-id-utils.ts +0 -117
@@ -1,117 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- import type { BrandPageModel } from '../../brand-page/models';
3
-
4
- /**
5
- * Sentinel anchor meaning "the end of the list", mirroring the section-level
6
- * `move_before_content_id: "__end__"` convention used in base-section-builder.
7
- */
8
- export const END_ITEM_ANCHOR = '__end__';
9
-
10
- /** Generate a stable item id. Mirrors section-level `uuid.v4()` id generation. */
11
- export const generateItemId = (): string => uuidv4();
12
-
13
- /**
14
- * Walk an entire BrandPageModel and backfill a stable uuid `id` onto every
15
- * nested array item that lacks one (gallery images, images/shapes/testimonial
16
- * items, text items, social links, and footer social links).
17
- *
18
- * BP-5603: this must run BEFORE the model is minified for the AI, so the same
19
- * id the AI is shown (and copies into `item_id`) is the one the executor later
20
- * matches. The maker holds a single live model instance for both the minify
21
- * and the apply step, so mutating it here makes the ids round-trip; they then
22
- * persist on the next save. Idempotent — existing ids are preserved.
23
- */
24
- export const ensureBrandPageItemIds = (model: BrandPageModel): void => {
25
- const ensureContentItemIds = (content: Record<string, unknown>): void => {
26
- // Every array field that the minifier surfaces as a list of items.
27
- for (const field of ['images', 'items', 'textItems', 'links'] as const) {
28
- const arr = content[field];
29
-
30
- if (Array.isArray(arr)) ensureItemIds(arr as { id?: string }[]);
31
- }
32
- };
33
-
34
- for (const page of model.pages ?? []) {
35
- for (const content of page.contents ?? []) {
36
- ensureContentItemIds(content as unknown as Record<string, unknown>);
37
- }
38
- }
39
-
40
- ensureItemIds(model.pageFooterDesktop?.socialLinks);
41
- ensureItemIds(model.pageFooterMobile?.socialLinks);
42
- };
43
-
44
- /**
45
- * Backfill ids onto any items missing one. Per BP-5603 this runs in the
46
- * metadata builder when a section is processed, so the persisted metadata
47
- * returned to the client gains stable ids that subsequent AI tool calls can
48
- * reference. Mutates in place.
49
- */
50
- export const ensureItemIds = <T extends { id?: string }>(
51
- items: T[] | undefined,
52
- ): void => {
53
- if (!items) return;
54
-
55
- for (const item of items) {
56
- if (!item.id) item.id = generateItemId();
57
- }
58
- };
59
-
60
- /**
61
- * Remove items whose id appears in `ids`. Order-independent (no descending
62
- * index sort needed) — the whole point of the id-based migration. Items
63
- * without an id are never removed by id.
64
- */
65
- export const removeItemsByIds = <T extends { id?: string }>(
66
- items: T[] | undefined,
67
- ids: string[] | undefined,
68
- ): T[] => {
69
- if (!items?.length) return items ?? [];
70
-
71
- if (!ids?.length) return items;
72
-
73
- const toRemove = new Set(ids);
74
-
75
- return items.filter((item) => !item.id || !toRemove.has(item.id));
76
- };
77
-
78
- /**
79
- * Position `item` within `items` relative to an anchor id — the item-level
80
- * mirror of base-section-builder's `moveContent`:
81
- *
82
- * - `moveBeforeItemId === undefined` → leave an existing item where it is;
83
- * append a new (not-yet-present) item to the end.
84
- * - `moveBeforeItemId === "__end__"` → move/insert at the very end.
85
- * - anchor id found → insert immediately before it.
86
- * - anchor id not found → fall through to the end (same
87
- * forgiving behaviour as `moveContent`).
88
- *
89
- * Mutates `items` in place. `item` may be an existing element of `items`
90
- * (a move) or a brand-new object (an insert).
91
- */
92
- export const repositionItemByAnchor = <T extends { id?: string }>(
93
- items: T[],
94
- item: T,
95
- moveBeforeItemId: string | undefined,
96
- ): void => {
97
- const currentIndex = items.indexOf(item);
98
-
99
- if (moveBeforeItemId === undefined) {
100
- if (currentIndex === -1) items.push(item);
101
-
102
- return;
103
- }
104
-
105
- if (currentIndex !== -1) items.splice(currentIndex, 1);
106
-
107
- const anchorIndex =
108
- moveBeforeItemId === END_ITEM_ANCHOR
109
- ? -1
110
- : items.findIndex((i) => i.id === moveBeforeItemId);
111
-
112
- if (anchorIndex !== -1) {
113
- items.splice(anchorIndex, 0, item);
114
- } else {
115
- items.push(item);
116
- }
117
- };