create-sitecore-jss 22.2.0-canary.1 → 22.2.0-canary.11

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 (307) hide show
  1. package/dist/bin.js +70 -28
  2. package/dist/common/index.js +5 -3
  3. package/dist/common/processes/install.js +9 -2
  4. package/dist/common/processes/next.js +3 -3
  5. package/dist/common/processes/transform.js +29 -14
  6. package/dist/common/prompts/base.js +0 -12
  7. package/dist/common/prompts/sxp.js +20 -0
  8. package/dist/common/utils/helpers.js +28 -43
  9. package/dist/init-runner.js +16 -11
  10. package/dist/initializers/angular/index.js +13 -0
  11. package/dist/initializers/angular/prompts.js +22 -1
  12. package/dist/initializers/angular-sxp/index.js +62 -0
  13. package/dist/initializers/angular-xmcloud/index.js +66 -0
  14. package/dist/initializers/nextjs/index.js +2 -2
  15. package/dist/initializers/nextjs/prompts.js +2 -0
  16. package/dist/initializers/nextjs/remove-dev-dependencies.js +2 -2
  17. package/dist/initializers/nextjs-multisite/index.js +1 -1
  18. package/dist/initializers/nextjs-styleguide/index.js +1 -1
  19. package/dist/initializers/nextjs-styleguide-tracking/index.js +1 -1
  20. package/dist/initializers/nextjs-sxa/index.js +1 -1
  21. package/dist/initializers/nextjs-xmcloud/index.js +1 -1
  22. package/dist/initializers/node-xmcloud-proxy/index.js +32 -0
  23. package/dist/initializers/react/index.js +3 -3
  24. package/dist/initializers/react/prompts.js +1 -1
  25. package/dist/initializers/react-native/prompts.js +1 -0
  26. package/dist/initializers/vue/prompts.js +1 -1
  27. package/dist/templates/angular/.env +9 -3
  28. package/dist/templates/angular/README.md +5 -45
  29. package/dist/templates/angular/angular.json +1 -6
  30. package/dist/templates/angular/package.json +5 -17
  31. package/dist/templates/angular/proxy.conf.js +5 -23
  32. package/dist/templates/angular/scripts/bootstrap.ts +5 -24
  33. package/dist/templates/angular/scripts/config/index.ts +28 -0
  34. package/dist/templates/angular/scripts/config/plugins/computed.ts +21 -0
  35. package/dist/templates/angular/scripts/config/plugins/fallback.ts +22 -0
  36. package/dist/templates/angular/scripts/config/plugins/package-json.ts +22 -0
  37. package/dist/templates/angular/scripts/config/plugins/scjssconfig.ts +29 -0
  38. package/dist/templates/angular/scripts/generate-config.ts +64 -73
  39. package/dist/templates/angular/scripts/generate-plugins.ts +28 -0
  40. package/dist/templates/angular/scripts/temp/gitignore +2 -0
  41. package/dist/templates/angular/scripts/update-graphql-fragment-data.ts +21 -27
  42. package/dist/templates/angular/server.bundle.ts +18 -1
  43. package/dist/templates/angular/src/app/JssState.ts +1 -4
  44. package/dist/templates/angular/src/app/app.module.ts +0 -2
  45. package/dist/templates/angular/src/app/components/app-components.shared.module.ts +4 -19
  46. package/dist/templates/angular/src/app/jss-context.server-side.service.ts +0 -2
  47. package/dist/templates/angular/src/app/lib/config.ts +16 -0
  48. package/dist/templates/angular/src/app/lib/dictionary-service-factory.ts +24 -13
  49. package/dist/templates/angular/src/app/lib/graphql-client-factory/config.ts +21 -0
  50. package/dist/templates/angular/src/app/lib/graphql-client-factory/index.ts +16 -0
  51. package/dist/templates/angular/src/app/lib/layout-service-factory.ts +20 -12
  52. package/dist/templates/angular/src/app/routing/layout/layout.component.html +1 -1
  53. package/dist/templates/angular/src/app/routing/layout/layout.component.ts +1 -2
  54. package/dist/templates/angular/src/app/routing/navigation/navigation.component.html +5 -6
  55. package/dist/templates/angular/src/app/routing/navigation/navigation.component.ts +1 -2
  56. package/dist/templates/angular/src/app/routing/routing.module.ts +14 -21
  57. package/dist/templates/angular/src/app/routing/scripts/scripts.component.html +1 -0
  58. package/dist/templates/angular/src/app/routing/scripts/scripts.component.ts +7 -0
  59. package/dist/templates/angular/src/app/routing/scripts/scripts.module.ts +8 -0
  60. package/dist/templates/angular/src/graphql-fragment-types.ts +0 -95
  61. package/dist/templates/angular/tsconfig.json +7 -2
  62. package/dist/templates/angular-sxp/package.json +12 -0
  63. package/dist/templates/angular-sxp/proxy.conf.js +43 -0
  64. package/dist/templates/angular-sxp/scripts/config/plugins/disconnected.ts +29 -0
  65. package/dist/templates/angular-sxp/src/app/components/app-components.shared.module.ts +35 -0
  66. package/dist/templates/{angular → angular-sxp}/src/app/jss-data-fetcher.service.ts +3 -1
  67. package/dist/templates/angular-sxp/src/app/routing/navigation/navigation.component.html +23 -0
  68. package/dist/templates/angular-sxp/src/app/routing/scripts/scripts.component.html +3 -0
  69. package/dist/templates/angular-sxp/src/app/routing/scripts/scripts.module.ts +9 -0
  70. package/dist/templates/{angular/src/app/routing → angular-sxp/src/app/routing/scripts}/visitor-identification/visitor-identification.component.ts +9 -3
  71. package/dist/templates/angular-sxp/src/graphql-fragment-types.ts +219 -0
  72. package/dist/templates/angular-xmcloud/.env +14 -0
  73. package/dist/templates/angular-xmcloud/angular.json +34 -0
  74. package/dist/templates/angular-xmcloud/package.json +15 -0
  75. package/dist/templates/angular-xmcloud/scripts/config/plugins/xmcloud.ts +39 -0
  76. package/dist/templates/angular-xmcloud/scripts/proxy-build.ts +15 -0
  77. package/dist/templates/angular-xmcloud/src/app/components/container/container.component.html +15 -0
  78. package/dist/templates/angular-xmcloud/src/app/components/container/container.component.ts +30 -0
  79. package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.html +13 -0
  80. package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.ts +16 -0
  81. package/dist/templates/angular-xmcloud/src/app/components/sxa.component.ts +15 -0
  82. package/dist/templates/angular-xmcloud/src/app/jss-link.service.ts +51 -0
  83. package/dist/templates/angular-xmcloud/src/app/lib/config.ts +17 -0
  84. package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory/config.ts +58 -0
  85. package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.html +39 -0
  86. package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.ts +109 -0
  87. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_component.scss +48 -0
  88. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_container.scss +64 -0
  89. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_fonts.scss +3 -0
  90. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_footer.scss +31 -0
  91. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_header.scss +49 -0
  92. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_navigation.scss +150 -0
  93. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_promo.scss +58 -0
  94. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_rich-text.scss +11 -0
  95. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_variables.scss +10 -0
  96. package/dist/templates/angular-xmcloud/src/assets/styles/basic/main.scss +8 -0
  97. package/dist/templates/angular-xmcloud/src/assets/styles/main.scss +4 -0
  98. package/dist/templates/angular-xmcloud/src/assets/styles/sass/_app.scss +103 -0
  99. package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/_functions.scss +8 -0
  100. package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/_mixins.scss +121 -0
  101. package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/_vars.scss +3 -0
  102. package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/vars/_colors.scss +283 -0
  103. package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/vars/_fontSizes.scss +16 -0
  104. package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/vars/_margins.scss +11 -0
  105. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/fonts/_fonts.scss +1 -0
  106. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/fonts/index.scss +1 -0
  107. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/index.scss +3 -0
  108. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/links/_link-button.scss +26 -0
  109. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/links/index.scss +1 -0
  110. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/reset/_inputs.scss +58 -0
  111. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/reset/_links.scss +14 -0
  112. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/reset/_ui-datepicker.scss +7 -0
  113. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/richtext/_richtext-files-icons.scss +86 -0
  114. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/richtext/_richtext.scss +101 -0
  115. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/richtext/index.scss +2 -0
  116. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/typehead/_typehead.scss +95 -0
  117. package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/typehead/index.scss +1 -0
  118. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-column-splitter.scss +14 -0
  119. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-container.scss +27 -0
  120. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-image.scss +18 -0
  121. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-navigation.scss +51 -0
  122. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-promo.scss +42 -0
  123. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-richtext-content.scss +19 -0
  124. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_alignment.scss +26 -0
  125. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_boxed.scss +16 -0
  126. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_clearfix.scss +11 -0
  127. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_highlighted.scss +63 -0
  128. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_link-button.scss +16 -0
  129. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_promoted-box.scss +3 -0
  130. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/index.scss +6 -0
  131. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/container/_bordered.scss +24 -0
  132. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/container/_title-row-box.scss +66 -0
  133. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/container/index.scss +1 -0
  134. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/image/_image-default-size.scss +6 -0
  135. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/image/index.scss +1 -0
  136. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/image-alignment/_image-left.scss +3 -0
  137. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/image-alignment/_image-right.scss +3 -0
  138. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/index.scss +17 -0
  139. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/layout/_acaindent.scss +5 -0
  140. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/layout/_background.scss +27 -0
  141. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/layout/index.scss +1 -0
  142. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/link-list/_component-link-list.scss +45 -0
  143. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/link-list/_list-vertical.scss +20 -0
  144. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/link-list/index.scss +2 -0
  145. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_navigation-fat.scss +58 -0
  146. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_navigation-main-horizontal-vertical.scss +176 -0
  147. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_navigation-mobile.scss +85 -0
  148. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_navigation-sidebar.scss +29 -0
  149. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_sitemap-navigation.scss +20 -0
  150. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/index.scss +5 -0
  151. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/promo/_absolute-bottom-link.scss +8 -0
  152. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/promo/_promo-hero.scss +40 -0
  153. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/promo/_promo-shadow.scss +42 -0
  154. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/promo/index.scss +3 -0
  155. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/rich-text/_rich-text-lists.scss +63 -0
  156. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/rich-text/index.scss +1 -0
  157. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/spacing/_background-colors.scss +14 -0
  158. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/spacing/_indent.scss +13 -0
  159. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/spacing/index.scss +2 -0
  160. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/title/_component-title.scss +30 -0
  161. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/title/index.scss +1 -0
  162. package/dist/templates/angular-xmcloud/src/assets/styles/sass/main.scss +4 -0
  163. package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/index.scss +6 -0
  164. package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/link-list/index.scss +0 -0
  165. package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/navigation/index.scss +0 -0
  166. package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/page-content/index.scss +0 -0
  167. package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/promo/index.scss +0 -0
  168. package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/rich-text/index.scss +0 -0
  169. package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/title/index.scss +0 -0
  170. package/dist/templates/nextjs/scripts/config/plugins/fallback.ts +0 -1
  171. package/dist/templates/nextjs/scripts/generate-config.ts +8 -1
  172. package/dist/templates/nextjs-styleguide/scripts/config/plugins/disconnected.ts +1 -0
  173. package/dist/templates/nextjs-sxa/src/assets/sass/components/_component-image.scss +1 -1
  174. package/dist/templates/node-xmcloud-proxy/.env +8 -0
  175. package/dist/templates/node-xmcloud-proxy/README.md +36 -0
  176. package/dist/templates/node-xmcloud-proxy/package.json +25 -0
  177. package/dist/templates/node-xmcloud-proxy/src/config.ts +19 -0
  178. package/dist/templates/node-xmcloud-proxy/src/index.ts +185 -0
  179. package/dist/templates/node-xmcloud-proxy/src/types.ts +61 -0
  180. package/dist/templates/node-xmcloud-proxy/tsconfig.json +22 -0
  181. package/dist/templates/react/scripts/generate-config.js +10 -3
  182. package/dist/templates/vue/scripts/generate-config.js +5 -0
  183. package/package.json +2 -2
  184. package/dist/templates/angular/src/app/lib/client-factory.ts +0 -28
  185. /package/dist/templates/{angular → angular-sxp}/data/component-content/Styleguide/ContentReuse/LoremIpsumContentBlock/en.yml +0 -0
  186. /package/dist/templates/{angular → angular-sxp}/data/component-content/gitignore +0 -0
  187. /package/dist/templates/{angular → angular-sxp}/data/content/Styleguide/ContentListField/Item1/en.yml +0 -0
  188. /package/dist/templates/{angular → angular-sxp}/data/content/Styleguide/ContentListField/Item2/en.yml +0 -0
  189. /package/dist/templates/{angular → angular-sxp}/data/content/Styleguide/EditFrameDemo/Item1/en.yml +0 -0
  190. /package/dist/templates/{angular → angular-sxp}/data/content/Styleguide/EditFrameDemo/Item2/en.yml +0 -0
  191. /package/dist/templates/{angular → angular-sxp}/data/content/Styleguide/ItemLinkField/Item1/en.yml +0 -0
  192. /package/dist/templates/{angular → angular-sxp}/data/content/Styleguide/ItemLinkField/Item2/en.yml +0 -0
  193. /package/dist/templates/{angular → angular-sxp}/data/content/gitignore +0 -0
  194. /package/dist/templates/{angular → angular-sxp}/data/dictionary/en.yml +0 -0
  195. /package/dist/templates/{angular → angular-sxp}/data/dictionary/{{language}}.yml +0 -0
  196. /package/dist/templates/{angular → angular-sxp}/data/media/files/jss.pdf +0 -0
  197. /package/dist/templates/{angular → angular-sxp}/data/media/img/jss_logo.png +0 -0
  198. /package/dist/templates/{angular → angular-sxp}/data/media/img/sc_logo.png +0 -0
  199. /package/dist/templates/{angular → angular-sxp}/data/routes/en.yml +0 -0
  200. /package/dist/templates/{angular → angular-sxp}/data/routes/graphql/en.yml +0 -0
  201. /package/dist/templates/{angular → angular-sxp}/data/routes/graphql/sample-1/en.yml +0 -0
  202. /package/dist/templates/{angular → angular-sxp}/data/routes/graphql/sample-2/en.yml +0 -0
  203. /package/dist/templates/{angular → angular-sxp}/data/routes/styleguide/custom-route-type/en.yml +0 -0
  204. /package/dist/templates/{angular → angular-sxp}/data/routes/styleguide/en.yml +0 -0
  205. /package/dist/templates/{angular → angular-sxp}/data/routes/styleguide/{{language}}.yml +0 -0
  206. /package/dist/templates/{angular → angular-sxp}/data/routes/{{language}}.yml +0 -0
  207. /package/dist/templates/{angular → angular-sxp}/scripts/disconnected-mode-proxy.ts +0 -0
  208. /package/dist/templates/{angular → angular-sxp}/scripts/lint-yml.ts +0 -0
  209. /package/dist/templates/{angular → angular-sxp}/sitecore/config/{{appName}}.config +0 -0
  210. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/component-content.sitecore.ts +0 -0
  211. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/Styleguide-Layout-Reuse.sitecore.ts +0 -0
  212. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/Styleguide-Layout-Tabs-Tab.sitecore.ts +0 -0
  213. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/Styleguide-Layout-Tabs.sitecore.ts +0 -0
  214. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/Styleguide-Layout.sitecore.ts +0 -0
  215. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/Styleguide-Multilingual.sitecore.ts +0 -0
  216. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/Styleguide-Section.sitecore.ts +0 -0
  217. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/content-block.sitecore.ts +0 -0
  218. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/graph-ql-connected-demo.sitecore.ts +0 -0
  219. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/graph-ql-integrated-demo.sitecore.graphql +0 -0
  220. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/graph-ql-integrated-demo.sitecore.ts +0 -0
  221. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/graph-ql-layout.sitecore.ts +0 -0
  222. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-angular-lazy-loading.sitecore.ts +0 -0
  223. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-component-params.sitecore.ts +0 -0
  224. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-custom-route-type.sitecore.ts +0 -0
  225. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-edit-frame.sitecore.ts +0 -0
  226. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-checkbox.sitecore.ts +0 -0
  227. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-content-list.sitecore.ts +0 -0
  228. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-custom.sitecore.ts +0 -0
  229. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-date.sitecore.ts +0 -0
  230. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-file.sitecore.ts +0 -0
  231. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-image.sitecore.ts +0 -0
  232. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-item-link.sitecore.ts +0 -0
  233. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-link.sitecore.ts +0 -0
  234. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-number.sitecore.ts +0 -0
  235. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-rich-text.sitecore.ts +0 -0
  236. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-field-usage-text.sitecore.ts +0 -0
  237. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-route-fields.sitecore.ts +0 -0
  238. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-sitecore-context.sitecore.ts +0 -0
  239. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/components/styleguide-tracking.sitecore.ts +0 -0
  240. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/config.js +0 -0
  241. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/content.sitecore.ts +0 -0
  242. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/dictionary.sitecore.ts +0 -0
  243. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/placeholders.sitecore.ts +0 -0
  244. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/routes.sitecore.ts +0 -0
  245. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/templates/Styleguide-Explanatory-Component.sitecore.ts +0 -0
  246. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/templates/styleguide-content-list-template.sitecore.ts +0 -0
  247. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/templates/styleguide-edit-frame-list-item-template.sitecore.ts +0 -0
  248. /package/dist/templates/{angular → angular-sxp}/sitecore/definitions/templates/styleguide-item-link-template.sitecore.ts +0 -0
  249. /package/dist/templates/{angular → angular-sxp}/sitecore/gitignore +0 -0
  250. /package/dist/templates/{angular → angular-sxp}/sitecore/pipelines/example.patch.ts +0 -0
  251. /package/dist/templates/{angular → angular-sxp}/src/app/components/graph-ql-connected-demo/graph-ql-connected-demo.component.graphql +0 -0
  252. /package/dist/templates/{angular → angular-sxp}/src/app/components/graph-ql-connected-demo/graph-ql-connected-demo.component.html +0 -0
  253. /package/dist/templates/{angular → angular-sxp}/src/app/components/graph-ql-connected-demo/graph-ql-connected-demo.component.ts +0 -0
  254. /package/dist/templates/{angular → angular-sxp}/src/app/components/graph-ql-integrated-demo/graph-ql-integrated-demo.component.html +0 -0
  255. /package/dist/templates/{angular → angular-sxp}/src/app/components/graph-ql-integrated-demo/graph-ql-integrated-demo.component.ts +0 -0
  256. /package/dist/templates/{angular → angular-sxp}/src/app/components/graph-ql-layout/graph-ql-layout.component.html +0 -0
  257. /package/dist/templates/{angular → angular-sxp}/src/app/components/graph-ql-layout/graph-ql-layout.component.ts +0 -0
  258. /package/dist/templates/{angular → angular-sxp}/src/app/components/shared/styleguide-specimen/styleguide-specimen.component.ts +0 -0
  259. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-angular-lazy-loading/styleguide-angular-lazy-loading.component.html +0 -0
  260. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-angular-lazy-loading/styleguide-angular-lazy-loading.component.ts +0 -0
  261. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-angular-lazy-loading/styleguide-angular-lazy-loading.module.ts +0 -0
  262. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-component-params/styleguide-component-params.component.html +0 -0
  263. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-component-params/styleguide-component-params.component.ts +0 -0
  264. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-custom-route-type/styleguide-custom-route-type.component.html +0 -0
  265. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-custom-route-type/styleguide-custom-route-type.component.ts +0 -0
  266. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-edit-frame/styleguide-edit-frame.component.html +0 -0
  267. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-edit-frame/styleguide-edit-frame.component.ts +0 -0
  268. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-checkbox/styleguide-field-usage-checkbox.component.html +0 -0
  269. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-checkbox/styleguide-field-usage-checkbox.component.ts +0 -0
  270. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-content-list/styleguide-field-usage-content-list.component.html +0 -0
  271. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-content-list/styleguide-field-usage-content-list.component.ts +0 -0
  272. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-custom/styleguide-field-usage-custom.component.html +0 -0
  273. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-custom/styleguide-field-usage-custom.component.ts +0 -0
  274. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-date/styleguide-field-usage-date.component.html +0 -0
  275. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-date/styleguide-field-usage-date.component.ts +0 -0
  276. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-file/styleguide-field-usage-file.component.html +0 -0
  277. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-file/styleguide-field-usage-file.component.ts +0 -0
  278. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-image/styleguide-field-usage-image.component.html +0 -0
  279. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-image/styleguide-field-usage-image.component.ts +0 -0
  280. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-item-link/styleguide-field-usage-item-link.component.html +0 -0
  281. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-item-link/styleguide-field-usage-item-link.component.ts +0 -0
  282. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-link/styleguide-field-usage-link.component.html +0 -0
  283. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-link/styleguide-field-usage-link.component.ts +0 -0
  284. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-number/styleguide-field-usage-number.component.html +0 -0
  285. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-number/styleguide-field-usage-number.component.ts +0 -0
  286. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-rich-text/styleguide-field-usage-rich-text.component.html +0 -0
  287. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-rich-text/styleguide-field-usage-rich-text.component.ts +0 -0
  288. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-text/styleguide-field-usage-text.component.html +0 -0
  289. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-field-usage-text/styleguide-field-usage-text.component.ts +0 -0
  290. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-layout/styleguide-layout.component.html +0 -0
  291. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-layout/styleguide-layout.component.ts +0 -0
  292. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-layout-reuse/styleguide-layout-reuse.component.html +0 -0
  293. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-layout-reuse/styleguide-layout-reuse.component.ts +0 -0
  294. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-layout-tabs/styleguide-layout-tabs.component.html +0 -0
  295. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-layout-tabs/styleguide-layout-tabs.component.ts +0 -0
  296. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-layout-tabs-tab/styleguide-layout-tabs-tab.component.html +0 -0
  297. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-layout-tabs-tab/styleguide-layout-tabs-tab.component.ts +0 -0
  298. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-multilingual/styleguide-multilingual.component.html +0 -0
  299. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-multilingual/styleguide-multilingual.component.ts +0 -0
  300. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-route-fields/styleguide-route-fields.component.html +0 -0
  301. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-route-fields/styleguide-route-fields.component.ts +0 -0
  302. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-section/styleguide-section.component.html +0 -0
  303. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-section/styleguide-section.component.ts +0 -0
  304. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-sitecore-context/styleguide-sitecore-context.component.html +0 -0
  305. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-sitecore-context/styleguide-sitecore-context.component.ts +0 -0
  306. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-tracking/styleguide-tracking.component.html +0 -0
  307. /package/dist/templates/{angular → angular-sxp}/src/app/components/styleguide-tracking/styleguide-tracking.component.ts +0 -0
@@ -1,7 +1,9 @@
1
+ import 'dotenv/config';
1
2
  import * as fs from 'fs';
2
3
  import * as path from 'path';
3
4
  import { constantCase } from 'constant-case';
4
- const packageConfig = require('../package.json');
5
+ import { jssConfigFactory } from './config';
6
+ import { JssConfig } from 'lib/config';
5
7
 
6
8
  /**
7
9
  * Generate config
@@ -10,91 +12,80 @@ const packageConfig = require('../package.json');
10
12
  * settings as variables into the JSS app.
11
13
  * NOTE! Any configs returned here will be written into the client-side JS bundle. DO NOT PUT SECRETS HERE.
12
14
  */
13
- export function generateConfig(configOverrides?: { [key: string]: unknown }, outputPath?: string) {
14
- const defaultConfig = {
15
- production: false,
16
- sitecoreApiHost: '',
17
- sitecoreApiKey: 'no-api-key-set',
18
- sitecoreSiteName: process.env.SITECORE_SITE_NAME,
19
- sitecoreLayoutServiceConfig: 'jss',
20
- defaultLanguage: 'en',
21
- defaultServerRoute: '/',
22
- layoutServiceConfigurationName: 'default',
23
- };
24
15
 
25
- if (!outputPath) {
26
- outputPath = 'src/environments/environment.js';
27
- }
16
+ const defaultConfigValue: JssConfig = {
17
+ production: false,
18
+ sitecoreApiKey: process.env[`${constantCase('sitecoreApiKey')}`],
19
+ sitecoreApiHost: process.env[`${constantCase('sitecoreApiHost')}`],
20
+ sitecoreSiteName: process.env[`${constantCase('sitecoreSiteName')}`],
21
+ defaultLanguage: process.env[`${constantCase('defaultLanguage')}`],
22
+ graphQLEndpoint: process.env[`${constantCase('graphQLEndpoint')}`],
23
+ graphQLEndpointPath: process.env[`${constantCase('graphQLEndpointPath')}`],
24
+ defaultServerRoute: '/',
25
+ };
28
26
 
29
- // require + combine config sources
30
- const scjssConfig = transformScJssConfig();
31
- const packageJson = transformPackageConfig();
27
+ generateConfig('src/environments/environment.js', defaultConfigValue, { production: false });
28
+ generateConfig('src/environments/environment.prod.js', defaultConfigValue, { production: true });
32
29
 
33
- // optional:
34
- // do any other dynamic config source (e.g. environment-specific config files)
35
- // Object.assign merges the objects in order, so the
36
- // package.json config can override the calculated config,
37
- // scjssconfig.json overrides it,
38
- // and finally config passed in the configOverrides param wins.
39
- const config = Object.assign(defaultConfig, scjssConfig, packageJson, configOverrides);
30
+ /**
31
+ * Generates the JSS config based on config plugins (under ./config/plugins)
32
+ * and then writes the config to disk.
33
+ * @param {string} outputPath the output path of the generated config.
34
+ * @param {JssConfig} [defaultConfig] Default configuration.
35
+ * @param {[key: string]:unknown} [configOverrides] configuration values that override the generated ones.
36
+ */
37
+ export function generateConfig(
38
+ outputPath: string,
39
+ defaultConfig: JssConfig = defaultConfigValue,
40
+ configOverrides?: { [key: string]: unknown }
41
+ ) {
42
+ // Handle undefined values
43
+ defaultConfig = Object.keys(defaultConfig).reduce((acc, key) => {
44
+ return {
45
+ ...acc,
46
+ [key]: defaultConfig[key] || '',
47
+ };
48
+ }, {});
40
49
 
41
- // The GraphQL endpoint is an example of making a _computed_ config setting
42
- // based on other config settings.
43
- const computedConfig: { [key: string]: string } = {};
44
- computedConfig.graphQLEndpoint = '`${config.sitecoreApiHost}${config.graphQLEndpointPath}`';
50
+ jssConfigFactory
51
+ .create(defaultConfig)
52
+ .then((config) => {
53
+ writeConfig(Object.assign(config, configOverrides), outputPath);
54
+ })
55
+ .catch((e) => {
56
+ console.error('Error generating config');
57
+ console.error(e);
58
+ process.exit(1);
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Writes the config object to disk with support for environment variables.
64
+ * @param {JssConfig} config JSS configuration to write.
65
+ * @param {string} outputPath the outputh path of the generated config.
66
+ */
67
+ export function writeConfig(config: JssConfig, outputPath?: string) {
68
+ if (!outputPath) {
69
+ outputPath = 'src/environments/environment.js';
70
+ }
45
71
 
46
72
  let configText = `/* eslint-disable */
47
- // Do not edit this file, it is auto-generated at build time!
48
- // See scripts/bootstrap.ts to modify the generation of this file.
49
- const config = {};\n`;
73
+ // Do not edit this file, it is auto-generated at build time!
74
+ // See scripts/bootstrap.ts to modify the generation of this file.
75
+ const config = {};\n`;
50
76
 
51
77
  // Set base configuration values, allowing override with environment variables
52
78
  Object.keys(config).forEach((prop) => {
53
- configText += `config.${prop} = process.env.${constantCase(prop)} || "${config[prop]?.toString().trim()}";\n`;
54
- });
55
- // Set computed values, allowing override with environment variables
56
- Object.keys(computedConfig).forEach((prop) => {
57
- configText += `config.${prop} = process.env.${constantCase(prop)} || ${
58
- computedConfig[prop]?.toString().trim()
59
- };\n`;
79
+ // Handle undefined values
80
+ const value = config[prop] || '';
81
+ configText += `config.${prop} = process.env.${constantCase(
82
+ prop
83
+ )} || "${value.toString().trim()}";\n`;
60
84
  });
85
+
61
86
  configText += `module.exports.environment = config;`;
62
87
 
63
88
  const configPath = path.resolve(outputPath);
64
89
  console.log(`Writing runtime config to ${configPath}`);
65
90
  fs.writeFileSync(configPath, configText, { encoding: 'utf8' });
66
91
  }
67
-
68
- function transformScJssConfig() {
69
- // scjssconfig.json may not exist if you've never run setup
70
- // so if it doesn't we substitute a fake object
71
- let config;
72
- try {
73
- config = require('../scjssconfig.json');
74
- } catch (e) {
75
- return {};
76
- }
77
-
78
- if (!config) {
79
- return {};
80
- }
81
-
82
- return {
83
- sitecoreApiKey: config.sitecore.apiKey,
84
- sitecoreApiHost: config.sitecore.layoutServiceHost,
85
- };
86
- }
87
-
88
- function transformPackageConfig() {
89
- const packageAny = packageConfig;
90
-
91
- if (!packageAny.config) {
92
- return {};
93
- }
94
-
95
- return {
96
- sitecoreSiteName: packageAny.config.appName,
97
- defaultLanguage: packageAny.config.language || 'en',
98
- graphQLEndpointPath: packageAny.config.graphQLEndpointPath || null,
99
- };
100
- }
@@ -0,0 +1,28 @@
1
+ import {
2
+ generatePlugins,
3
+ ModuleType,
4
+ PluginDefinition,
5
+ } from '@sitecore-jss/sitecore-jss-dev-tools';
6
+
7
+ /*
8
+ PLUGINS GENERATION
9
+ NOTE: pluginName: the name of the plugin in the src/lib folder
10
+ Generates the `/src/temp/{pluginName}-plugins.ts` file, which exports list of plugins
11
+
12
+ Generating the plugins is optional, and it can be maintained manually if preferred.
13
+
14
+ The default convention uses the plugin's filename (without the extension) as the first part of the component
15
+ name. For example, the file `/lib/page-props-factory/plugins/exampleName.ts` would map to plugin `exampleNamePlugin`.
16
+ */
17
+
18
+ const pluginDefinitions: PluginDefinition[] = [
19
+ {
20
+ distPath: 'scripts/temp/config-plugins.ts',
21
+ rootPath: 'scripts/config/plugins',
22
+ moduleType: ModuleType.ESM,
23
+ },
24
+ ];
25
+
26
+ pluginDefinitions.forEach((definition) => {
27
+ generatePlugins(definition);
28
+ });
@@ -0,0 +1,2 @@
1
+ *
2
+ !.gitignore
@@ -1,6 +1,7 @@
1
- import * as fetch from 'isomorphic-fetch';
2
1
  import * as fs from 'fs';
3
2
  import { generateConfig } from './generate-config';
3
+ import clientFactory from 'lib/graphql-client-factory';
4
+ import { getGraphQLClientFactoryConfig } from 'lib/graphql-client-factory/config';
4
5
 
5
6
  // Apollo Client supports caching GraphQL responses, which can greatly reduce network traffic needs.
6
7
  // In order to work correctly with interfaces in GraphQL, it needs to know some basic information about
@@ -9,28 +10,23 @@ import { generateConfig } from './generate-config';
9
10
  //
10
11
  // The `jss graphql:update` command should be executed when Sitecore templates related to the site are altered.
11
12
 
12
- generateConfig();
13
+ generateConfig('src/environments/environment.js');
13
14
 
14
- let jssConfig;
15
+ const clientFactoryConfig = getGraphQLClientFactoryConfig();
15
16
 
16
- try {
17
- jssConfig = require('../src/environments/environment').environment;
18
- } catch (e) {
19
- console.error(
20
- 'Unable to require JSS config. Ensure `jss setup` has been run, and the app has been started at least once after setup.'
21
- );
22
- console.error(e);
23
- process.exit(1);
24
- }
17
+ console.log(`Updating GraphQL fragment type data from ${clientFactoryConfig.endpoint}...`);
25
18
 
26
- console.log(`Updating GraphQL fragment type data from ${jssConfig.graphQLEndpoint}...`);
27
-
28
- fetch(jssConfig.graphQLEndpoint, {
29
- method: 'POST',
30
- headers: { 'Content-Type': 'application/json', sc_apikey: jssConfig.sitecoreApiKey },
31
- body: JSON.stringify({
32
- query: `
33
- {
19
+ clientFactory()
20
+ .request<{
21
+ [key: string]: unknown;
22
+ __schema: {
23
+ kind: string;
24
+ name: string;
25
+ types: { possibleTypes?: { name: string } }[];
26
+ };
27
+ }>(
28
+ `
29
+ {
34
30
  __schema {
35
31
  types {
36
32
  kind
@@ -41,20 +37,18 @@ fetch(jssConfig.graphQLEndpoint, {
41
37
  }
42
38
  }
43
39
  }
44
- `,
45
- }),
46
- })
47
- .then((result) => result.json())
40
+ `
41
+ )
48
42
  .then((result) => {
49
43
  // here we're filtering out any type information unrelated to unions or interfaces
50
- const filteredData = result.data.__schema.types.filter((type: { possibleTypes: Array<string>; }) => type.possibleTypes !== null);
44
+ const filteredData = result.__schema.types.filter((type) => type.possibleTypes !== null);
51
45
 
52
46
  const filteredResult = { ...result };
53
- filteredResult.data.__schema.types = filteredData;
47
+ filteredResult.__schema.types = filteredData;
54
48
 
55
49
  fs.writeFile(
56
50
  './src/graphql-fragment-types.ts',
57
- `export default ${JSON.stringify(filteredResult.data, null, 2)}`,
51
+ `export default ${JSON.stringify(filteredResult, null, 2)}`,
58
52
  (err) => {
59
53
  if (err) {
60
54
  console.error('Error writing GraphQLFragmentTypes file', err);
@@ -6,6 +6,10 @@ import 'zone.js';
6
6
  import { JssRouteBuilderService } from './src/app/routing/jss-route-builder.service';
7
7
  import { environment } from './src/environments/environment';
8
8
  import { AppServerModule, renderModule } from './src/main.server';
9
+ import clientFactory from './src/app/lib/graphql-client-factory';
10
+ import { getGraphQLClientFactoryConfig } from './src/app/lib/graphql-client-factory/config';
11
+ import { dictionaryServiceFactory } from './src/app/lib/dictionary-service-factory';
12
+ import { layoutServiceFactory } from './src/app/lib/layout-service-factory';
9
13
 
10
14
  export * from './src/main.server';
11
15
 
@@ -99,5 +103,18 @@ function parseRouteUrl(url: string) {
99
103
 
100
104
  const apiKey = environment.sitecoreApiKey;
101
105
  const siteName = environment.sitecoreSiteName;
106
+ const defaultLanguage = environment.defaultLanguage;
107
+ const getClientFactoryConfig = getGraphQLClientFactoryConfig;
102
108
 
103
- export { renderView, parseRouteUrl, setUpDefaultAgents, apiKey, siteName };
109
+ export {
110
+ renderView,
111
+ parseRouteUrl,
112
+ setUpDefaultAgents,
113
+ apiKey,
114
+ siteName,
115
+ clientFactory,
116
+ getClientFactoryConfig,
117
+ dictionaryServiceFactory,
118
+ layoutServiceFactory,
119
+ defaultLanguage,
120
+ };
@@ -1,7 +1,4 @@
1
- import {
2
- RouteData,
3
- LayoutServiceContextData,
4
- } from '@sitecore-jss/sitecore-jss-angular';
1
+ import { RouteData, LayoutServiceContextData } from '@sitecore-jss/sitecore-jss-angular';
5
2
  import { LayoutServiceError } from './layout/jss-layout.service';
6
3
 
7
4
  export class JssState<Fields = Record<string, unknown>> {
@@ -10,7 +10,6 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
10
10
  import { JssTranslationClientLoaderService } from './i18n/jss-translation-client-loader.service';
11
11
  import { JssTranslationLoaderService } from './i18n/jss-translation-loader.service';
12
12
  import { GraphQLModule } from './jss-graphql.module';
13
- import { JssDataFetcherService } from './jss-data-fetcher.service';
14
13
  import { JssMetaService } from './jss-meta.service';
15
14
 
16
15
  @NgModule({
@@ -31,7 +30,6 @@ import { JssMetaService } from './jss-meta.service';
31
30
  // The token is needed in cases when multiple applications are bootstrapped on a page
32
31
  { provide: APP_ID, useValue: 'my-app' },
33
32
  JssContextService,
34
- JssDataFetcherService,
35
33
  JssLayoutService,
36
34
  JssMetaService,
37
35
  // IMPORTANT: you must set the base href with this token, not a <base> tag in the HTML.
@@ -3,7 +3,6 @@ import { CommonModule } from '@angular/common';
3
3
  import { FormsModule } from '@angular/forms';
4
4
  import { TranslateModule } from '@ngx-translate/core';
5
5
  import { RouterModule } from '@angular/router';
6
- import { StyleguideSpecimenComponent } from './shared/styleguide-specimen/styleguide-specimen.component';
7
6
  import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
8
7
 
9
8
  /*
@@ -14,22 +13,8 @@ import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
14
13
  Don't want code generation? See ./.gitignore for instructions to turn it off.
15
14
  */
16
15
  @NgModule({
17
- imports: [
18
- CommonModule,
19
- TranslateModule,
20
- RouterModule,
21
- JssModule,
22
- FormsModule,
23
- ],
24
- exports: [
25
- CommonModule,
26
- TranslateModule,
27
- RouterModule,
28
- FormsModule,
29
- StyleguideSpecimenComponent
30
- ],
31
- declarations: [
32
- StyleguideSpecimenComponent
33
- ],
16
+ imports: [CommonModule, TranslateModule, RouterModule, JssModule, FormsModule],
17
+ exports: [CommonModule, TranslateModule, RouterModule, FormsModule],
18
+ declarations: [],
34
19
  })
35
- export class AppComponentsSharedModule { }
20
+ export class AppComponentsSharedModule {}
@@ -2,7 +2,6 @@ import { Injectable, Inject, TransferState } from '@angular/core';
2
2
  import { JssContextService, jssKey } from './jss-context.service';
3
3
  import { JssState } from './JssState';
4
4
  import { Observable, of as observableOf } from 'rxjs';
5
- import { JssDataFetcherService } from './jss-data-fetcher.service';
6
5
  import { JssLayoutService } from './layout/jss-layout.service';
7
6
 
8
7
  /**
@@ -15,7 +14,6 @@ export class JssContextServerSideService extends JssContextService {
15
14
  constructor(
16
15
  protected transferState: TransferState,
17
16
  protected layoutService: JssLayoutService,
18
- protected dataFetcher: JssDataFetcherService,
19
17
  // this initial state from sitecore is injected by server.bundle for "integrated" mode
20
18
  @Inject('JSS_SERVER_LAYOUT_DATA') private serverToSsrState: JssState
21
19
  ) {
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Represents the type of config object available within the generated /environments/environment.js
3
+ */
4
+ export interface JssConfig extends Record<string, string | boolean | undefined> {
5
+ production?: false;
6
+ sitecoreApiKey?: string;
7
+ sitecoreApiHost?: string;
8
+ sitecoreSiteName?: string;
9
+ defaultLanguage?: string;
10
+ graphQLEndpoint?: string;
11
+ graphQLEndpointPath?: string;
12
+ <% if (!locals.xmcloud) { -%>
13
+ layoutServiceConfigurationName?: string;
14
+ <% } -%>
15
+ defaultServerRoute?: string;
16
+ }
@@ -1,30 +1,41 @@
1
1
  import {
2
2
  DictionaryService,
3
3
  GraphQLDictionaryService,
4
+ <% if (!locals.xmcloud) { -%>
4
5
  RestDictionaryService,
5
6
  constants,
7
+ <% } -%>
6
8
  } from '@sitecore-jss/sitecore-jss-angular';
7
9
  import { environment as env } from '../../environments/environment';
8
- import { clientFactory } from './client-factory';
10
+ import clientFactory from './graphql-client-factory';
9
11
 
10
12
  export class DictionaryServiceFactory {
11
13
  create(): DictionaryService {
12
- return process.env.FETCH_WITH === constants.FETCH_WITH.GRAPHQL
13
- ? new GraphQLDictionaryService({
14
- clientFactory,
15
- siteName: env.sitecoreSiteName,
16
- /*
17
- The Dictionary Service needs a root item ID in order to fetch dictionary phrases for the current
18
- app. If your Sitecore instance only has 1 JSS App, you can specify the root item ID here;
19
- otherwise, the service will attempt to figure out the root item for the current JSS App using GraphQL and app name.
20
- rootItemId: '{GUID}'
21
- */
22
- })
23
- : new RestDictionaryService({
14
+ const service =
15
+ <% if (!locals.xmcloud) { -%>
16
+ process.env.FETCH_WITH === constants.FETCH_WITH.REST
17
+ ? new RestDictionaryService({
24
18
  apiHost: env.sitecoreApiHost,
25
19
  apiKey: env.sitecoreApiKey,
26
20
  siteName: env.sitecoreSiteName,
21
+ })
22
+ :
23
+ <% } -%>
24
+ new GraphQLDictionaryService({
25
+ clientFactory,
26
+ siteName: env.sitecoreSiteName,
27
+ <% if (locals.xmcloud) { -%>
28
+ useSiteQuery: true,
29
+ <% } -%>
30
+ /*
31
+ The Dictionary Service needs a root item ID in order to fetch dictionary phrases for the current
32
+ app. If your Sitecore instance only has 1 JSS App, you can specify the root item ID here;
33
+ otherwise, the service will attempt to figure out the root item for the current JSS App using GraphQL and app name.
34
+ rootItemId: '{GUID}'
35
+ */
27
36
  });
37
+
38
+ return service;
28
39
  }
29
40
  }
30
41
 
@@ -0,0 +1,21 @@
1
+ import { GraphQLRequestClientFactoryConfig } from '@sitecore-jss/sitecore-jss-angular/cjs';
2
+ import { environment as env } from '../../../environments/environment';
3
+
4
+ /**
5
+ * Gets the configuration for the GraphQLRequestClientFactory
6
+ * @returns GraphQLRequestClientFactoryConfig
7
+ */
8
+ export const getGraphQLClientFactoryConfig = () => {
9
+ let clientConfig: GraphQLRequestClientFactoryConfig;
10
+
11
+ if (env.graphQLEndpoint && env.sitecoreApiKey) {
12
+ clientConfig = {
13
+ endpoint: env.graphQLEndpoint,
14
+ apiKey: env.sitecoreApiKey,
15
+ };
16
+ } else {
17
+ throw new Error('Please configure your graphQLEndpoint and sitecoreApiKey.');
18
+ }
19
+
20
+ return clientConfig;
21
+ };
@@ -0,0 +1,16 @@
1
+ import { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss-angular/cjs';
2
+ import { getGraphQLClientFactoryConfig } from './config';
3
+
4
+ // The GraphQLRequestClientFactory serves as the central hub for executing GraphQL requests within the application
5
+
6
+ /**
7
+ * Creates a new GraphQLRequestClientFactory instance
8
+ * @returns GraphQLRequestClientFactory instance
9
+ */
10
+ const createGraphQLClientFactory = () => {
11
+ const clientConfig = getGraphQLClientFactoryConfig();
12
+
13
+ return GraphQLRequestClient.createClientFactory(clientConfig);
14
+ };
15
+
16
+ export default createGraphQLClientFactory();
@@ -1,25 +1,33 @@
1
1
  import {
2
2
  LayoutService,
3
3
  GraphQLLayoutService,
4
+ <% if (!locals.xmcloud) { -%>
4
5
  RestLayoutService,
5
6
  constants,
7
+ <% } -%>
6
8
  } from '@sitecore-jss/sitecore-jss-angular';
7
9
  import { environment } from '../../environments/environment';
8
- import { clientFactory } from './client-factory';
10
+ import clientFactory from './graphql-client-factory';
9
11
 
10
12
  export class LayoutServiceFactory {
11
13
  create(): LayoutService {
12
- return process.env.FETCH_WITH === constants.FETCH_WITH.GRAPHQL
13
- ? new GraphQLLayoutService({
14
- clientFactory,
15
- siteName: environment.sitecoreSiteName,
16
- })
17
- : new RestLayoutService({
18
- apiHost: environment.sitecoreApiHost,
19
- apiKey: environment.sitecoreApiKey,
20
- siteName: environment.sitecoreSiteName,
21
- configurationName: environment.layoutServiceConfigurationName,
22
- });
14
+ const service =
15
+ <% if (!locals.xmcloud) { -%>
16
+ process.env.FETCH_WITH === constants.FETCH_WITH.REST
17
+ ? new RestLayoutService({
18
+ apiHost: environment.sitecoreApiHost,
19
+ apiKey: environment.sitecoreApiKey,
20
+ siteName: environment.sitecoreSiteName,
21
+ configurationName: environment.layoutServiceConfigurationName,
22
+ })
23
+ :
24
+ <% } -%>
25
+ new GraphQLLayoutService({
26
+ clientFactory,
27
+ siteName: environment.sitecoreSiteName,
28
+ });
29
+
30
+ return service;
23
31
  }
24
32
  }
25
33
 
@@ -1,7 +1,7 @@
1
1
  <app-navigation></app-navigation>
2
2
  <div class="container">
3
3
  <ng-container *ngIf="state === LayoutState.Layout">
4
- <app-visitor-identification></app-visitor-identification>
4
+ <app-scripts></app-scripts>
5
5
  <sc-placeholder
6
6
  name="<%- helper.getAppPrefix(appPrefix, appName) %>jss-main"
7
7
  [rendering]="route"
@@ -71,9 +71,8 @@ export class LayoutComponent implements OnInit, OnDestroy {
71
71
  }
72
72
  }
73
73
 
74
- onPlaceholderLoaded(placeholderName: string) {
74
+ onPlaceholderLoaded(_placeholderName: string) {
75
75
  // you may optionally hook to the loaded event for a placeholder,
76
76
  // which can be useful for analytics and other DOM-based things that need to know when a placeholder's content is available.
77
- console.debug(`layout.component.ts: placeholder component fired loaded event for the ${placeholderName} placeholder`);
78
77
  }
79
78
  }
@@ -1,4 +1,6 @@
1
- <div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom">
1
+ <div
2
+ class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom"
3
+ >
2
4
  <h5 class="my-0 me-md-auto fw-normal">
3
5
  <a routerLink="/" class="text-dark" class="logo"></a>
4
6
  </h5>
@@ -11,11 +13,8 @@
11
13
  >
12
14
  {{ 'Documentation' | translate }}
13
15
  </a>
14
- <a routerLink="/styleguide" class="p-2 text-dark">
15
- {{ 'Styleguide' | translate }}
16
- </a>
17
- <a routerLink="/graphql" class="p-2 text-dark">
18
- {{ 'GraphQL' | translate }}
16
+ <a href="https://github.com/Sitecore/jss" class="p-2 text-dark">
17
+ {{ 'JSS Repository' | translate }}
19
18
  </a>
20
19
  </nav>
21
20
  </div>
@@ -4,5 +4,4 @@ import { Component } from '@angular/core';
4
4
  selector: 'app-navigation',
5
5
  templateUrl: './navigation.component.html',
6
6
  })
7
- export class NavigationComponent {
8
- }
7
+ export class NavigationComponent {}
@@ -9,7 +9,7 @@ import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
9
9
  import { BrowserModule } from '@angular/platform-browser';
10
10
  import { NavigationComponent } from './navigation/navigation.component';
11
11
  import { TranslateModule } from '@ngx-translate/core';
12
- import { VisitorIdentificationComponent } from './visitor-identification/visitor-identification.component';
12
+ import { ScriptsModule } from './scripts/scripts.module';
13
13
 
14
14
  export function jssRouteMatcher(url: UrlSegment[]): UrlMatchResult {
15
15
  // use the route builder to parse out language / server route
@@ -27,7 +27,7 @@ export function jssRouteMatcher(url: UrlSegment[]): UrlMatchResult {
27
27
 
28
28
  return {
29
29
  consumed: url,
30
- posParams
30
+ posParams,
31
31
  };
32
32
  }
33
33
 
@@ -39,32 +39,25 @@ const routes: Routes = [
39
39
  matcher: jssRouteMatcher,
40
40
  component: LayoutComponent,
41
41
  resolve: {
42
- jssState: jssRouteResolver
42
+ jssState: jssRouteResolver,
43
43
  },
44
44
  runGuardsAndResolvers: 'always',
45
- }
45
+ },
46
46
  ];
47
47
 
48
48
  @NgModule({
49
49
  imports: [
50
- RouterModule.forRoot(routes, { onSameUrlNavigation: 'reload', initialNavigation: 'enabledBlocking' }),
50
+ RouterModule.forRoot(routes, {
51
+ onSameUrlNavigation: 'reload',
52
+ initialNavigation: 'enabledBlocking',
53
+ }),
51
54
  JssModule,
52
55
  TranslateModule,
53
- BrowserModule
54
- ],
55
- exports: [
56
- RouterModule,
57
- TranslateModule,
58
- ],
59
- declarations: [
60
- NotFoundComponent,
61
- ServerErrorComponent,
62
- LayoutComponent,
63
- NavigationComponent,
64
- VisitorIdentificationComponent
56
+ BrowserModule,
57
+ ScriptsModule,
65
58
  ],
66
- providers: [
67
- JssRouteBuilderService,
68
- ]
59
+ exports: [RouterModule, TranslateModule],
60
+ declarations: [NotFoundComponent, ServerErrorComponent, LayoutComponent, NavigationComponent],
61
+ providers: [JssRouteBuilderService],
69
62
  })
70
- export class RoutingModule { }
63
+ export class RoutingModule {}