@remkoj/optimizely-cms-react 2.0.0-pre4 → 2.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 (43) hide show
  1. package/dist/components/cms-styles.d.ts +53 -0
  2. package/dist/components/cms-styles.js +23 -0
  3. package/dist/components/cms-styles.js.map +1 -0
  4. package/dist/components/index.d.ts +2 -1
  5. package/dist/components/index.js +2 -1
  6. package/dist/components/index.js.map +1 -1
  7. package/dist/components/rich-text.d.ts +75 -0
  8. package/dist/components/rich-text.js +136 -0
  9. package/dist/components/rich-text.js.map +1 -0
  10. package/dist/factory.d.ts +10 -2
  11. package/dist/factory.js +26 -3
  12. package/dist/factory.js.map +1 -1
  13. package/dist/server/components/cms-content-area.d.ts +0 -1
  14. package/dist/server/components/cms-content.d.ts +0 -1
  15. package/dist/server/components/cms-content.js +16 -19
  16. package/dist/server/components/cms-content.js.map +1 -1
  17. package/dist/server/components/cms-editable.d.ts +22 -0
  18. package/dist/server/components/cms-editable.js +18 -0
  19. package/dist/server/components/cms-editable.js.map +1 -0
  20. package/dist/server/components/get-content-type.js +9 -14
  21. package/dist/server/components/get-content-type.js.map +1 -1
  22. package/dist/server/components/index.d.ts +1 -0
  23. package/dist/server/components/index.js +1 -0
  24. package/dist/server/components/index.js.map +1 -1
  25. package/dist/server/components/queries.js +12 -12
  26. package/dist/server/components/visual-builder/Composition.d.ts +6 -1
  27. package/dist/server/components/visual-builder/Composition.js +24 -66
  28. package/dist/server/components/visual-builder/Composition.js.map +1 -1
  29. package/dist/server/components/visual-builder/functions.d.ts +6 -1
  30. package/dist/server/components/visual-builder/functions.js +46 -0
  31. package/dist/server/components/visual-builder/functions.js.map +1 -1
  32. package/dist/server/components/visual-builder/types.d.ts +12 -2
  33. package/dist/server/type-utils.d.ts +0 -1
  34. package/dist/types.d.ts +44 -13
  35. package/dist/utilities.d.ts +22 -1
  36. package/dist/utilities.js +33 -3
  37. package/dist/utilities.js.map +1 -1
  38. package/package.json +9 -8
  39. package/dist/components/rich-text/index.d.ts +0 -32
  40. package/dist/components/rich-text/index.js +0 -43
  41. package/dist/components/rich-text/index.js.map +0 -1
  42. package/dist/server/components/utils.d.ts +0 -10
  43. package/dist/server/components/utils.js +0 -28
@@ -22,33 +22,28 @@ export async function getContentType(link, gqlClient) {
22
22
  const items = gqlResponse.Content?.items;
23
23
  if (!items || items.length == 0)
24
24
  throw new Error("The content item could not be found!");
25
- const contentType = Utils.normalizeContentType(items[0]?.ContentType);
25
+ const contentType = Utils.normalizeContentType(items[0]?._metadata?.types);
26
26
  if (!contentType)
27
27
  throw new Error("The item did not contain type information");
28
28
  return contentType;
29
29
  }
30
30
  export default getContentType;
31
- export const getContentTypeQuery = gql `query getContentType($id: Int, $workId: Int, $guidValue: String, $locale: [Locales])
31
+ export const getContentTypeQuery = gql `query getContentType($key: String!, $version: String, $locale: [Locales])
32
32
  {
33
- Content(
33
+ _Content(
34
34
  where: {
35
- ContentLink: {
36
- GuidValue: {
37
- eq: $guidValue
38
- }
39
- Id: {
40
- eq: $id
41
- },
42
- WorkId: {
43
- eq: $workId
44
- }
35
+ _metadata: {
36
+ key: { eq: $key }
37
+ version: { eq: $version }
45
38
  }
46
39
  },
47
40
  locale: $locale
48
41
  limit: 1
49
42
  ) {
50
43
  items {
51
- ContentType
44
+ _metadata {
45
+ types
46
+ }
52
47
  },
53
48
  total
54
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-content-type.js","sourceRoot":"","sources":["../../../src/server/components/get-content-type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AAErE,MAAM,KAAK,GAAG,KAAK,CAAA;AAEnB;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAA2B,EAAE,SAA2B;I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AAK,CAAA;AAEnB;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAA2B,EAAE,SAA2B;IAEzF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAA;IACvF,MAAM,YAAY,GAAG,KAAK,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAA;IAC9D,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,OAAO,CAAyB,mBAAmB,EAAE,YAAY,CAAC,CAAA;IACtG,IAAI,WAAW,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAClC,IAAI,KAAK;YACL,OAAO,CAAC,KAAK,CAAC,uDAAwD,WAAW,CAAC,OAAO,EAAE,KAAK,IAAI,CAAE,YAAY,EAAE,YAAY,CAAC,CAAA;QACrI,OAAO,SAAS,CAAA;IACpB,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE,KAAK,CAAA;IACxC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IAE3D,MAAM,WAAW,GAAG,KAAK,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;IAC1E,IAAI,CAAC,WAAW;QACZ,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAEhE,OAAO,WAAW,CAAA;AACtB,CAAC;AAED,eAAe,cAAc,CAAA;AAa7B,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;EAmBpC,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export * from './cms-content.js';
2
2
  export * from './cms-content-area.js';
3
+ export * from './cms-editable.js';
3
4
  export * from './visual-builder/index.js';
@@ -1,4 +1,5 @@
1
1
  export * from './cms-content.js';
2
2
  export * from './cms-content-area.js';
3
+ export * from './cms-editable.js';
3
4
  export * from './visual-builder/index.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA"}
@@ -2,19 +2,19 @@ import { gql } from 'graphql-request';
2
2
  export const CmsContentFragments = {
3
3
  IContentDataProps: ["_metadata", "_type", "__typename"],
4
4
  ContentLink: gql `fragment ContentLink on ContentModelReference {
5
- id: Id,
6
- workId: WorkId,
7
- guidValue: GuidValue
5
+ id: Id,
6
+ workId: WorkId,
7
+ guidValue: GuidValue
8
8
  }`,
9
9
  ContentLinkSearch: gql `fragment ContentLinkSearch on ContentModelReferenceSearch {
10
- id: Id,
11
- workId: WorkId,
12
- guidValue: GuidValue
10
+ id: Id,
11
+ workId: WorkId,
12
+ guidValue: GuidValue
13
13
  }`,
14
14
  IContentData: gql `fragment IContentData on IContent {
15
15
  contentType: ContentType
16
16
  id: ContentLink {
17
- ...ContentLink
17
+ ...ContentLink
18
18
  }
19
19
  locale: Language {
20
20
  name: Name
@@ -25,7 +25,7 @@ export const CmsContentFragments = {
25
25
  item: ContentLink {
26
26
  ...ContentLinkSearch
27
27
  data: Expanded {
28
- ...BlockData
28
+ ...BlockData
29
29
  }
30
30
  }
31
31
  displayOption:DisplayOption
@@ -34,7 +34,7 @@ export const CmsContentFragments = {
34
34
  item: ContentLink {
35
35
  ...ContentLinkSearch
36
36
  data: Expanded {
37
- ...IContentData
37
+ ...IContentData
38
38
  }
39
39
  }
40
40
  displayOption:DisplayOption
@@ -43,7 +43,7 @@ export const CmsContentFragments = {
43
43
  item: ContentLink {
44
44
  ...ContentLink
45
45
  data: Expanded {
46
- ...IContentData
46
+ ...IContentData
47
47
  }
48
48
  }
49
49
  displayOption:DisplayOption
@@ -102,7 +102,7 @@ export const ContentAreaFragments = {
102
102
  }`
103
103
  };
104
104
  export const getContentById = gql `query getContentById($id: Int, $workId: Int, $guidValue: String, $locale: [Locales!], $isCommonDraft: Boolean) {
105
- Content(
105
+ content:_Content(
106
106
  where: {
107
107
  ContentLink: {
108
108
  Id: { eq: $id },
@@ -123,7 +123,7 @@ export const getContentById = gql `query getContentById($id: Int, $workId: Int,
123
123
  }`;
124
124
  export const getContentByPath = gql `query getContentByPath($path: String!, $locale: [Locales], $siteId: String)
125
125
  {
126
- Content(
126
+ content: _Content(
127
127
  where: {
128
128
  RelativePath: {
129
129
  eq: $path
@@ -1,5 +1,10 @@
1
- /// <reference types="react" />
2
1
  import 'server-only';
3
2
  import type { OptimizelyCompositionProps } from './types.js';
3
+ /**
4
+ * Render the composition as made available through Optimizely Graph for Visual Builder
5
+ *
6
+ * @param param0
7
+ * @returns The
8
+ */
4
9
  export declare function OptimizelyComposition({ node, leafPropsFactory, nodePropsFactory }: OptimizelyCompositionProps): Promise<JSX.Element>;
5
10
  export default OptimizelyComposition;
@@ -1,86 +1,44 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import 'server-only';
2
- import { isElementNode } from './functions.js';
3
+ import { isElementNode, defaultNodePropsFactory, defaultPropsFactory } from './functions.js';
3
4
  import { CmsContent } from '../cms-content.js';
4
- import { isContentLink, isInlineContentLink } from '@remkoj/optimizely-graph-client';
5
5
  import getServerContext from '../../context.js';
6
- function isContentType(toTest) {
7
- return Array.isArray(toTest) && toTest.every(x => typeof (x) == 'string' && x.length > 0);
8
- }
9
- const defaultPropsFactory = (node) => {
10
- const contentType = node.element?._metadata?.types;
11
- if (!isContentType(contentType))
12
- throw new Error("Invalid content type: " + JSON.stringify(contentType));
13
- const contentLink = {
14
- key: node.element?._metadata?.key || node.key || undefined,
15
- version: node.element?._metadata?.version,
16
- locale: node.element?._metadata?.locale
17
- };
18
- if (!(isContentLink(contentLink) || isInlineContentLink(contentLink)))
19
- throw new Error("Invalid content link: " + JSON.stringify(contentLink));
20
- const layoutData = {
21
- type: node.type,
22
- layoutType: node.layoutType,
23
- template: node.template,
24
- settings: node.settings
25
- };
26
- return [contentLink, contentType, node.element, layoutData];
27
- };
28
- function ucFirst(input) {
29
- return input[0].toUpperCase() + input.substring(1);
30
- }
31
- const defaultNodePropsFactory = (node) => {
32
- const componentTypes = [
33
- [node.template, node.type ? ucFirst(node.type) : null, ucFirst(node.layoutType), "Component", "Content"].filter(x => x),
34
- (node.template && node.type) ? [node.type ? ucFirst(node.type) : null, ucFirst(node.layoutType), "Component", "Content"].filter(x => x) : null,
35
- ["Node", "Component", "Content"]
36
- ].filter(x => x);
37
- const contentLink = { key: node.key ?? '' };
38
- const componentData = {};
39
- const layoutData = {
40
- type: node.type,
41
- layoutType: node.layoutType,
42
- template: node.template,
43
- settings: node.settings
44
- };
45
- if (!(isContentLink(contentLink) || isInlineContentLink(contentLink)))
46
- throw new Error("Invalid content link: " + JSON.stringify(contentLink));
47
- return [contentLink, componentTypes, componentData, layoutData];
48
- };
6
+ /**
7
+ * Render the composition as made available through Optimizely Graph for Visual Builder
8
+ *
9
+ * @param param0
10
+ * @returns The
11
+ */
49
12
  export async function OptimizelyComposition({ node, leafPropsFactory = defaultPropsFactory, nodePropsFactory = defaultNodePropsFactory }) {
13
+ const { factory, isDebug } = getServerContext();
50
14
  if (isElementNode(node)) {
15
+ if (isDebug)
16
+ console.log(`⚪ [VisualBuilder] Rendering element node ${JSON.stringify(node)}`);
51
17
  const [contentLink, contentType, fragmentData, layoutProps] = leafPropsFactory(node);
52
- return CmsContent({ contentLink, contentType, fragmentData, layoutProps });
18
+ //@ts-expect-error CmsContent is an Asynchronous server component, which isn't supported by the generic React Typings
19
+ return _jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, layoutProps: layoutProps });
53
20
  }
54
- const { factory, isDebug } = getServerContext();
21
+ if (isDebug)
22
+ console.log(`⚪ [VisualBuilder] Rendering structure node ${JSON.stringify(node)}`);
55
23
  if (!factory)
56
- throw new Error("OptimizelyComposition requires the factory be defined within the serverContext");
57
- const children = await Promise.all((node.nodes ?? []).map((child, idx) => {
58
- const childKey = `vb::node::${child.key}::${child.name}`;
59
- return OptimizelyComposition({
60
- key: childKey,
61
- node: child,
62
- leafPropsFactory,
63
- nodePropsFactory
64
- });
65
- }));
24
+ throw new Error("🟡 [VisualBuilder] [OptimizelyComposition] The factory must be defined within the serverContext");
66
25
  const [contentLink, contentTypes, fragmentData, layoutProps] = nodePropsFactory(node);
67
26
  const firstExistingType = contentTypes.map(ct => {
68
27
  const reversed = [...ct].reverse();
69
28
  const hasType = factory.has(reversed);
70
29
  if (!hasType && isDebug)
71
- console.log(`🟡 [VisualBuilder] Content type ${reversed.join('/')} not found within factory`);
30
+ console.log(`🟡 [VisualBuilder] [OptimizelyComposition] Content type ${reversed.join('/')} not found within factory`);
72
31
  return hasType;
73
32
  }).indexOf(true);
74
33
  const contentType = contentTypes[firstExistingType];
75
34
  if (!contentType)
76
- throw new Error("OptimizelyComposition requires the factory have a definition for Component/Node");
77
- return CmsContent({
78
- contentType,
79
- contentLink,
80
- fragmentData,
81
- children,
82
- layoutProps
83
- });
35
+ throw new Error("🟡 [VisualBuilder] [OptimizelyComposition] The factory must have a definition for Component/Node");
36
+ //@ts-expect-error CmsContent is an Asynchronous server component, which isn't supported by the generic React Typings
37
+ return _jsx(CmsContent, { contentType: contentType, contentLink: contentLink, fragmentData: fragmentData, layoutProps: layoutProps, children: (node.nodes ?? []).map((child) => {
38
+ const childKey = child.key ? child.key : `vb::${JSON.stringify(child)}`;
39
+ //@ts-expect-error OptimizelyComposition is an Asynchronous server component, which isn't supported by the generic React Typings
40
+ return _jsx(OptimizelyComposition, { node: child, leafPropsFactory: leafPropsFactory, nodePropsFactory: nodePropsFactory }, childKey);
41
+ }) });
84
42
  }
85
43
  export default OptimizelyComposition;
86
44
  //# sourceMappingURL=Composition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Composition.js","sourceRoot":"","sources":["../../../../src/server/components/visual-builder/Composition.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAG9C,OAAO,EAAE,aAAa,EAAyB,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AAE3G,OAAO,gBAAgB,MAAM,kBAAkB,CAAA;AAE/C,SAAS,aAAa,CAAC,MAAW;IAE9B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAM,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AAC5F,CAAC;AAED,MAAM,mBAAmB,GAAsB,CAA8C,IAAgC,EAAE,EAAE;IAC7H,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAA;IAClD,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAA;IAEzE,MAAM,WAAW,GAAwC;QACrD,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,SAAS;QAC1D,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO;QACzC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM;KAC1C,CAAA;IACD,IAAI,CAAC,C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QAC5C,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAA;QAClC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAI,CAAC,OAAO,IAAI,OAAO;YACnB,OAAO,CAAC,GAAG,CAAC,2DAA4D,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAE,2BAA2B,CAAC,CAAA;QAC3H,OAAO,OAAO,CAAA;IAClB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAChB,MAAM,WAAW,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAA;IACnD,IAAI,CAAC,WAAW;QACZ,MAAM,IAAI,KAAK,CAAC,kGAAkG,CAAC,CAAA;IAEvH,qHAAqH;IACrH,OAAO,KAAC,UAAU,IAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,YACtH,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAQ,IAAI,CAAC,SAAS,CAAE,KAAK,CAAE,EAAE,CAAA;YAC1E,gIAAgI;YAChI,OAAO,KAAC,qBAAqB,IAAkB,IAAI,EAAG,KAAK,EAAG,gBAAgB,EAAG,gBAAgB,EAAG,gBAAgB,EAAG,gBAAgB,IAAnG,QAAQ,CAAgG,CAAA;QAChJ,CAAC,CAAC,GACO,CAAA;AACjB,CAAC;AAED,eAAe,qBAAqB,CAAA"}
@@ -1,5 +1,10 @@
1
- import { CompositionNode, CompositionElementNode, CompositionStructureNode } from './types.js';
1
+ import type { ContentType } from '../../../types.js';
2
+ import type { CompositionNode, LeafPropsFactory, CompositionElementNode, NodePropsFactory, CompositionStructureNode } from './types.js';
2
3
  export declare function isElementNode(node: CompositionNode<Record<string, any>>): node is CompositionElementNode<Record<string, any>>;
3
4
  export declare function isElementNodeOfType<ET extends Record<string, any>>(node: CompositionNode<Record<string, any>>, test: (data: Record<string, any>) => data is ET): node is CompositionElementNode<ET>;
4
5
  export declare function isStructureNode(node: CompositionNode<Record<string, any>>): node is CompositionStructureNode;
5
6
  export declare function isNode(toTest: any): toTest is CompositionNode;
7
+ export declare function isContentType(toTest: any): toTest is ContentType;
8
+ export declare const defaultPropsFactory: LeafPropsFactory;
9
+ export declare const defaultNodePropsFactory: NodePropsFactory;
10
+ export declare function ucFirst(input: string | undefined | null): string | null;
@@ -1,3 +1,4 @@
1
+ import { isContentLink, isInlineContentLink } from '@remkoj/optimizely-graph-client';
1
2
  export function isElementNode(node) {
2
3
  return node.layoutType == "element";
3
4
  }
@@ -17,4 +18,49 @@ export function isNode(toTest) {
17
18
  const hasValidType = typeof toTest.layoutType == 'string' && nodeTypes.includes(toTest.layoutType);
18
19
  return hasValidName && hasValidType;
19
20
  }
21
+ export function isContentType(toTest) {
22
+ return Array.isArray(toTest) && toTest.every(x => typeof (x) == 'string' && x.length > 0);
23
+ }
24
+ export const defaultPropsFactory = (node) => {
25
+ const contentType = node.element?._metadata?.types;
26
+ if (!isContentType(contentType))
27
+ throw new Error("Invalid content type: " + JSON.stringify(contentType));
28
+ const contentLink = {
29
+ key: node.element?._metadata?.key || node.key || undefined,
30
+ version: node.element?._metadata?.version,
31
+ locale: node.element?._metadata?.locale
32
+ };
33
+ if (!(isContentLink(contentLink) || isInlineContentLink(contentLink)))
34
+ throw new Error("Invalid content link: " + JSON.stringify(contentLink));
35
+ const layoutData = {
36
+ type: node.type,
37
+ layoutType: node.layoutType,
38
+ template: node.template,
39
+ settings: node.settings
40
+ };
41
+ return [contentLink, contentType, node.element, layoutData];
42
+ };
43
+ export const defaultNodePropsFactory = (node) => {
44
+ const componentTypes = [
45
+ [node.template, ucFirst(node.type), ucFirst(node.layoutType), "Component", "Content"].filter(x => x),
46
+ (node.template && node.type) ? [node.type ? ucFirst(node.type) : null, ucFirst(node.layoutType), "Component", "Content"].filter(x => x) : null,
47
+ ["Node", "Component", "Content"]
48
+ ].filter(x => x);
49
+ const contentLink = { key: node.key ?? '' };
50
+ const componentData = {};
51
+ const layoutData = {
52
+ type: node.type,
53
+ layoutType: node.layoutType,
54
+ template: node.template,
55
+ settings: node.settings
56
+ };
57
+ if (!(isContentLink(contentLink) || isInlineContentLink(contentLink)))
58
+ throw new Error("🔴 [VisualBuilder] Invalid content link: " + JSON.stringify(contentLink) + " - Node: " + JSON.stringify(node));
59
+ return [contentLink, componentTypes, componentData, layoutData];
60
+ };
61
+ export function ucFirst(input) {
62
+ if (typeof (input) == 'string' && input.length > 0)
63
+ return input[0].toUpperCase() + input.substring(1);
64
+ return null;
65
+ }
20
66
  //# sourceMappingURL=functions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../src/server/components/visual-builder/functions.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAC,IAAyC;IAEnE,OAAO,IAAI,CAAC,UAAU,IAAI,SAAS,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAgC,IAAyC,EAAE,IAA8C;IAExJ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;QACpB,OAAO,KAAK,CAAA;IAChB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC7B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAyC;IAErE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,MAAW;IAE9B,IAAI,OAAM,CAAC,MAAM,CAAC,IAAI,QAAQ,IAAI,MAAM,IAAI,IAAI;QAC5C,OAAO,KAAK,CAAA;IAEhB,MAAM,SAAS,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,MAAM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,EAAE,IAAI,CAAC,IAAI;QACf,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;KAC1B,CAAA;IAED,IAAI,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,mBAAmB,CAAC,WAAW,CAAC,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,2CAA2C,GAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAE,WAAW,GAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAE/H,OAAO,CAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,CAAE,CAAA;AACrE,CAAC,CAAA;AAED,MAAM,UAAU,OAAO,CAAC,KAAgC;IAEpD,IAAI,OAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAC7C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACtD,OAAO,IAAI,CAAA;AACf,CAAC"}
@@ -34,9 +34,19 @@ export type CompositionComponentType<NT extends CompositionNode> = ComponentType
34
34
  }>>;
35
35
  export type LeafPropsFactory = <ET extends Record<string, any>, LT = string>(node: CompositionElementNode<ET>) => [ContentLinkWithLocale<LT> | InlineContentLinkWithLocale<LT>, ContentType, ET] | [ContentLinkWithLocale<LT> | InlineContentLinkWithLocale<LT>, ContentType, ET, Record<string, any>];
36
36
  export type NodePropsFactory = <ET extends Record<string, any>, LT = string>(node: CompositionStructureNode) => [ContentLinkWithLocale<LT> | InlineContentLinkWithLocale<LT>, Array<ContentType>, ET] | [ContentLinkWithLocale<LT> | InlineContentLinkWithLocale<LT>, Array<ContentType>, ET, Record<string, any>];
37
- export type OptimizelyCompositionProps = {
37
+ export type OptimizelyCompositionProps = JSX.IntrinsicAttributes & {
38
+ /**
39
+ * The Visual Builder node to start rendering from
40
+ */
38
41
  node: CompositionNode<Record<string, any>>;
42
+ /**
43
+ * Allows overriding of the factory that transforms the data received from
44
+ * Optimizely Graph into properties for an element.
45
+ */
39
46
  leafPropsFactory?: LeafPropsFactory;
47
+ /**
48
+ * Allows overriding of the factory that transforms the data received from
49
+ * Optimizely Graph into properties for a structure node.
50
+ */
40
51
  nodePropsFactory?: NodePropsFactory;
41
- key?: string;
42
52
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * Tests if K is a property of T - if so: it is the type of
4
3
  * T[K]; if not: it is equal to never
package/dist/types.d.ts CHANGED
@@ -2,10 +2,10 @@ import type { PropsWithChildren, ComponentType as ReactComponentType, ExoticComp
2
2
  import type { DocumentNode } from "graphql";
3
3
  import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
4
4
  import type { IOptiGraphClient } from "@remkoj/optimizely-graph-client";
5
- import type { ContentLink, ContentLinkWithLocale, InlineContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
5
+ import type { ContentLinkWithLocale, InlineContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
6
6
  export type ContentType = string[];
7
7
  export type { ContentLink, ContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
8
- export type CmsComponentProps<T> = PropsWithChildren<{
8
+ export type CmsComponentProps<T, L extends Record<string, any> = Record<string, any>> = PropsWithChildren<{
9
9
  /**
10
10
  * The identifier of the content item
11
11
  */
@@ -21,10 +21,9 @@ export type CmsComponentProps<T> = PropsWithChildren<{
21
21
  /**
22
22
  * Contextual layout data, if any
23
23
  */
24
- layoutProps?: Record<string, any>;
24
+ layoutProps?: L;
25
25
  }>;
26
- export type ContentQueryProps<LocaleType = string> = ContentLink & {
27
- locale?: Array<LocaleType> | LocaleType | null;
26
+ export type ContentQueryProps<LocaleType = string> = ContentLinkWithLocale<LocaleType> & {
28
27
  path?: string | null;
29
28
  domain?: string | null;
30
29
  };
@@ -43,17 +42,17 @@ export type WithGqlFragment<BaseComponent, DataType> = BaseComponent & {
43
42
  export type WithGqlQuery<B, T> = B & {
44
43
  getDataQuery: GetDataQuery<T>;
45
44
  };
46
- export type BaseCmsComponent<T = {}> = T extends never | TypedDocumentNode | DocumentNode ? DynamicCmsComponent<T> : ReactComponentType<CmsComponentProps<T>>;
47
- export type DynamicCmsComponent<T extends TypedDocumentNode | DocumentNode = DocumentNode> = ReactComponentType<CmsComponentProps<ResponseDataType<T>>>;
45
+ export type BaseCmsComponent<T = {}, L extends Record<string, any> = Record<string, any>> = T extends never | TypedDocumentNode | DocumentNode ? DynamicCmsComponent<T> : ReactComponentType<CmsComponentProps<T, L>>;
46
+ export type DynamicCmsComponent<T extends TypedDocumentNode | DocumentNode = DocumentNode, L extends Record<string, any> = Record<string, any>> = ReactComponentType<CmsComponentProps<ResponseDataType<T>, L>>;
48
47
  export type GraphQLFragmentBase = {
49
48
  ' $fragmentName'?: string;
50
49
  };
51
50
  export type GraphQLQueryBase = {
52
51
  __typename?: 'Query';
53
52
  };
54
- export type CmsComponentWithFragment<T = DocumentNode> = BaseCmsComponent<T> & WithGqlFragment<{}, T>;
55
- export type CmsComponentWithQuery<T = DocumentNode> = BaseCmsComponent<T> & WithGqlQuery<{}, T>;
56
- export type CmsComponentWithOptionalQuery<T = DocumentNode> = BaseCmsComponent<T> & Partial<WithGqlQuery<{}, T>>;
53
+ export type CmsComponentWithFragment<T = DocumentNode, L extends Record<string, any> = Record<string, any>> = BaseCmsComponent<T, L> & WithGqlFragment<{}, T>;
54
+ export type CmsComponentWithQuery<T = DocumentNode, L extends Record<string, any> = Record<string, any>> = BaseCmsComponent<T, L> & WithGqlQuery<{}, T>;
55
+ export type CmsComponentWithOptionalQuery<T = DocumentNode, L extends Record<string, any> = Record<string, any>> = BaseCmsComponent<T, L> & Partial<WithGqlQuery<{}, T>>;
57
56
  /**
58
57
  * A generic Optimizely CMS Component that will change the static surface based upon the
59
58
  * provided data type for the component. It will detect automatically whether the component
@@ -63,21 +62,53 @@ export type CmsComponentWithOptionalQuery<T = DocumentNode> = BaseCmsComponent<T
63
62
  * When a type is provided that cannot be resolved to either the output of a Query or a Fragment,
64
63
  * it will assume an optional getDataQuery method.
65
64
  */
66
- export type CmsComponent<T = DocumentNode> = T extends TypedDocumentNode<infer R, any> ? CmsComponentWithQuery<R> : T extends DocumentNode ? CmsComponentWithQuery<{
65
+ export type CmsComponent<T = DocumentNode, L extends Record<string, any> = Record<string, any>> = T extends TypedDocumentNode<infer R, any> ? CmsComponentWithQuery<R, L> : T extends DocumentNode ? CmsComponentWithQuery<{
67
66
  [key: string]: any;
68
- }> : T extends GraphQLFragmentBase ? CmsComponentWithFragment<T> : T extends GraphQLQueryBase ? CmsComponentWithQuery<T> : CmsComponentWithOptionalQuery<T>;
69
- export type CmsLayoutComponent<T = never> = ReactComponentType<CmsComponentProps<T>>;
67
+ }, L> : T extends GraphQLFragmentBase ? CmsComponentWithFragment<T, L> : T extends GraphQLQueryBase ? CmsComponentWithQuery<T, L> : CmsComponentWithOptionalQuery<T, L>;
68
+ export type CmsLayoutComponent<L extends Record<string, any> = Record<string, any>, T = never> = ReactComponentType<CmsComponentProps<T, L>>;
70
69
  export type ComponentType = (ReactComponentType<any>) | (ReactExoticComponent<any>) | (keyof JSX.IntrinsicElements);
71
70
  export type ComponentTypeHandle = string | string[];
72
71
  export type ComponentTypeDictionary = {
73
72
  type: ComponentTypeHandle;
74
73
  component: ComponentType;
75
74
  }[];
75
+ /**
76
+ * Component Factory
77
+ */
76
78
  export interface ComponentFactory {
79
+ /**
80
+ * Check if the component type has been registered within the factory
81
+ *
82
+ * @param type The component type to check for
83
+ * @returns Whether or not the type exists within the factory
84
+ */
77
85
  has(type: ComponentTypeHandle): boolean;
86
+ /**
87
+ * Register an individual component
88
+ * @param type The component type to register
89
+ * @param componentType The component to bind to the type
90
+ */
78
91
  register(type: ComponentTypeHandle, componentType: ComponentType): void;
92
+ /**
93
+ * Register all components provided through the dictionary
94
+ *
95
+ * @param components The components to register
96
+ */
79
97
  registerAll(components: ComponentTypeDictionary): void;
98
+ /**
99
+ * Resolve a component type
100
+ *
101
+ * @param type The type to search the component for
102
+ * @returns The component that was resolved for the provided type
103
+ */
80
104
  resolve(type: ComponentTypeHandle): ComponentType | undefined;
105
+ /**
106
+ * Retrieve the registered components as a dictionary that can be used to
107
+ * be imported in a new instance.
108
+ *
109
+ * @returns The dictionary
110
+ */
111
+ extract(): ComponentTypeDictionary;
81
112
  }
82
113
  export interface GenericContext {
83
114
  readonly client?: IOptiGraphClient;
@@ -4,7 +4,28 @@ import type { DocumentNode } from 'graphql';
4
4
  export declare function isNonEmptyString(toTest: any): toTest is string;
5
5
  export declare function isNotNullOrUndefined<T>(toTest?: T | null): toTest is T;
6
6
  export declare function isContentType(toTest: any): toTest is Types.ContentType;
7
- export declare function normalizeContentType(toNormalize: (string | null)[] | null | undefined): Types.ContentType | undefined;
7
+ /**
8
+ * Normalizes the content type by:
9
+ * - Converting strings to ContentType
10
+ * - Stripping the leading underscore, if any
11
+ *
12
+ * @param toNormalize The Content Type value to process
13
+ * @param stripContent When set to true, the global base type "Content" will be removed as well
14
+ * @returns
15
+ */
16
+ export declare function normalizeContentType(toNormalize: (string | null)[] | string | null | undefined, stripContent?: boolean): Types.ContentType | undefined;
17
+ /**
18
+ * Normalizes and prefixes the content type by:
19
+ * - Converting strings to ContentType
20
+ * - Stripping the leading underscore, if any
21
+ * - Removing the global base type "Content"
22
+ * - Ensuring that in the remaining type the least specific type is equal to the provided prefix
23
+ *
24
+ * @param contentType
25
+ * @param prefix
26
+ * @returns
27
+ */
28
+ export declare function normalizeAndPrefixContentType(contentType: Array<string | null> | string | null | undefined, prefix: string): Types.ContentType;
8
29
  export declare function isCmsComponentWithDataQuery<T = DocumentNode>(toTest?: Types.BaseCmsComponent<T>): toTest is Types.CmsComponentWithQuery<T>;
9
30
  export declare function isCmsComponentWithFragment<T = DocumentNode>(toTest?: Types.BaseCmsComponent<T>): toTest is Types.CmsComponentWithFragment<T>;
10
31
  export declare function validatesFragment<T extends ComponentType<any>>(toTest?: T): toTest is T & Pick<Required<Types.WithGqlFragment<T, any>>, "validateFragment">;
package/dist/utilities.js CHANGED
@@ -10,12 +10,42 @@ export function isContentType(toTest) {
10
10
  return false;
11
11
  return toTest.every(isNonEmptyString);
12
12
  }
13
- export function normalizeContentType(toNormalize) {
14
- if (!Array.isArray(toNormalize))
13
+ /**
14
+ * Normalizes the content type by:
15
+ * - Converting strings to ContentType
16
+ * - Stripping the leading underscore, if any
17
+ *
18
+ * @param toNormalize The Content Type value to process
19
+ * @param stripContent When set to true, the global base type "Content" will be removed as well
20
+ * @returns
21
+ */
22
+ export function normalizeContentType(toNormalize, stripContent = false) {
23
+ if (!toNormalize)
15
24
  return undefined;
16
- const filtered = toNormalize.filter(isNonEmptyString);
25
+ let filtered = (typeof (toNormalize) == 'string' ? toNormalize.split('/') : toNormalize).filter(isNonEmptyString).map(x => x.startsWith('_') ? x.substring(1) : x);
26
+ if (stripContent)
27
+ filtered = filtered.filter(x => x.toLowerCase() != 'content');
17
28
  return filtered.length > 0 ? filtered : undefined;
18
29
  }
30
+ /**
31
+ * Normalizes and prefixes the content type by:
32
+ * - Converting strings to ContentType
33
+ * - Stripping the leading underscore, if any
34
+ * - Removing the global base type "Content"
35
+ * - Ensuring that in the remaining type the least specific type is equal to the provided prefix
36
+ *
37
+ * @param contentType
38
+ * @param prefix
39
+ * @returns
40
+ */
41
+ export function normalizeAndPrefixContentType(contentType, prefix) {
42
+ if (!contentType)
43
+ return [prefix];
44
+ const processedContentType = (typeof (contentType) == 'string' ? contentType.split('/') : contentType).filter(isNonEmptyString).map(x => x.startsWith('_') ? x.substring(1) : x).filter(x => x.toLowerCase() != 'content');
45
+ if (processedContentType[0] != prefix)
46
+ processedContentType.unshift(prefix);
47
+ return processedContentType;
48
+ }
19
49
  export function isCmsComponentWithDataQuery(toTest) {
20
50
  const toTestType = typeof (toTest);
21
51
  if ((toTestType == 'function' || toTestType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