create-sitecore-jss 22.8.0-canary.1 → 22.8.0-canary.3

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.
@@ -26,8 +26,6 @@
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
28
  "@sitecore-jss/sitecore-jss-nextjs": "<%- version %>",
29
- "graphql": "~15.8.0",
30
- "graphql-tag": "^2.12.6",
31
29
  "next": "^15.3.1",
32
30
  "next-localization": "^0.12.0",
33
31
  "react": "^19.1.0",
@@ -35,14 +33,6 @@
35
33
  "sharp": "0.32.6"
36
34
  },
37
35
  "devDependencies": {
38
- "@graphql-codegen/cli": "^5.0.0",
39
- "@graphql-codegen/import-types-preset": "^3.0.0",
40
- "@graphql-codegen/plugin-helpers": "^5.0.1",
41
- "@graphql-codegen/typed-document-node": "^5.0.1",
42
- "@graphql-codegen/typescript": "^4.0.1",
43
- "@graphql-codegen/typescript-operations": "^4.0.1",
44
- "@graphql-codegen/typescript-resolvers": "^4.0.1",
45
- "@graphql-typed-document-node/core": "^3.2.0",
46
36
  "@sitecore-jss/sitecore-jss-cli": "<%- version %>",
47
37
  "@sitecore-jss/sitecore-jss-dev-tools": "<%- version %>",
48
38
  "@types/node": "^22.9.0",
@@ -61,20 +51,17 @@
61
51
  "eslint-plugin-prettier": "^4.2.1",
62
52
  "eslint-plugin-react": "^7.37.5",
63
53
  "eslint-plugin-yaml": "^0.5.0",
64
- "graphql-let": "^0.18.6",
65
54
  "npm-run-all": "~4.1.5",
66
55
  "prettier": "^2.8.3",
67
56
  "ts-node": "^10.9.1",
68
57
  "tsconfig-paths": "^4.1.2",
69
- "typescript": "~5.4.0",
70
- "yaml-loader": "^0.8.0"
58
+ "typescript": "~5.4.0"
71
59
  },
72
60
  "scripts": {
73
61
  "jss": "jss",
74
62
  "lint": "eslint ./src/**/*.tsx ./src/**/*.ts ./scripts/**/*.ts",
75
- "bootstrap": "ts-node --require dotenv-flow/config --project tsconfig.scripts.json scripts/bootstrap.ts && graphql-let",
63
+ "bootstrap": "ts-node --require dotenv-flow/config --project tsconfig.scripts.json scripts/bootstrap.ts",
76
64
  "build": "cross-env NODE_ENV=production npm-run-all --serial bootstrap next:build",
77
- "graphql:update": "ts-node --project tsconfig.scripts.json ./scripts/fetch-graphql-introspection-data.ts",
78
65
  "next:build": "next build",
79
66
  "next:dev": "cross-env NODE_OPTIONS='--inspect' next dev",
80
67
  "next:start": "next start",
@@ -1,3 +1,2 @@
1
1
  *
2
2
  !.gitignore
3
- !GraphQLIntrospectionResult.json
@@ -6,7 +6,6 @@
6
6
  "lib/*": ["src/lib/*"],
7
7
  "temp/*": ["src/temp/*"],
8
8
  "assets/*": ["src/assets/*"],
9
- "graphql-types": ["node_modules/@types/graphql-let/__generated__/__types__"],
10
9
  "react": ["node_modules/react"]
11
10
  },
12
11
  "target": "es5",
@@ -0,0 +1,5 @@
1
+ declare module '*.graphql' {
2
+ import { DocumentNode } from 'graphql';
3
+ const document: DocumentNode;
4
+ export default document;
5
+ }
@@ -5,7 +5,9 @@
5
5
  },
6
6
  "devDependencies": {
7
7
  "@sitecore-jss/sitecore-jss-dev-tools": "<%- version %>",
8
- "@types/nprogress": "^0.2.0"
8
+ "@types/nprogress": "^0.2.0",
9
+ "graphql": "^16.11.0",
10
+ "graphql-tag": "^2.12.6"
9
11
  },
10
12
  "scripts": {
11
13
  "start": "cross-env NODE_ENV=development JSS_MODE=disconnected \"npm-run-all --serial bootstrap --parallel next:dev start:disconnected-proxy start:watch-components\"",
@@ -8,24 +8,67 @@ import {
8
8
  withDatasourceCheck,
9
9
  } from '@sitecore-jss/sitecore-jss-nextjs';
10
10
  import { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss-nextjs/graphql';
11
- import {
12
- resetEditorChromes
13
- } from '@sitecore-jss/sitecore-jss-nextjs/utils';
11
+ import { resetEditorChromes } from '@sitecore-jss/sitecore-jss-nextjs/utils';
14
12
  import NextLink from 'next/link';
15
- import { ConnectedDemoQueryDocument } from './GraphQL-ConnectedDemo.dynamic.graphql';
16
- import {
17
- <%- helper.getAppPrefix(appPrefix, appName, false) %>AppRoute as AppRoute,
18
- Item,
19
- <%- helper.getAppPrefix(appPrefix, appName, false) %>GraphQlConnectedDemo as GrapQLConnectedDemoDatasource,
20
- } from 'graphql-types';
13
+ import ConnectedDemoQuery from './GraphQL-ConnectedDemo.dynamic.graphql';
21
14
  import { ComponentProps } from 'lib/component-props';
22
15
  import config from 'temp/config';
23
16
 
24
- type RouteItem = AppRoute & Item;
17
+ type GraphQLConnectedDemoDataSource = {
18
+ sample1: {
19
+ jsonValue: {
20
+ value: string;
21
+ };
22
+ value: string;
23
+ };
24
+ sample2: {
25
+ definition: {
26
+ type: string;
27
+ shared: boolean;
28
+ };
29
+ jsonValue: {
30
+ value: {
31
+ href: string;
32
+ linktype: string;
33
+ target: string;
34
+ text: string;
35
+ url: string;
36
+ };
37
+ };
38
+ target: string;
39
+ text: string;
40
+ url: string;
41
+ };
42
+ name: string;
43
+ id: string;
44
+ };
45
+
46
+ type Item = {
47
+ id: string;
48
+ url: {
49
+ path: string;
50
+ };
51
+ pageTitle: {
52
+ value: string;
53
+ jsonValue: {
54
+ value: string;
55
+ };
56
+ };
57
+ };
58
+
59
+ type ItemSearchResults = {
60
+ results: Item[];
61
+ };
25
62
 
26
63
  type GraphQLConnectedDemoData = {
27
- datasource: GrapQLConnectedDemoDatasource;
28
- contextItem: RouteItem;
64
+ datasource: GraphQLConnectedDemoDataSource;
65
+ contextItem: {
66
+ id: string;
67
+ children: ItemSearchResults;
68
+ pageTitle: {
69
+ value: string;
70
+ };
71
+ };
29
72
  };
30
73
 
31
74
  type GraphQLConnectedDemoProps = ComponentProps & GraphQLConnectedDemoData;
@@ -82,7 +125,7 @@ const GraphQLConnectedDemo = (props: GraphQLConnectedDemoProps): JSX.Element =>
82
125
  children:
83
126
  <ul>
84
127
  {props.contextItem.children.results.map((child) => {
85
- const routeItem = child as RouteItem;
128
+ const routeItem = child as Item;
86
129
 
87
130
  return (
88
131
  <li key={routeItem.id}>
@@ -115,7 +158,7 @@ export const getStaticProps: GetStaticComponentProps = async (rendering, layoutD
115
158
 
116
159
  const result = await graphQLClient.request<GraphQLConnectedDemoData>(
117
160
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
118
- ConnectedDemoQueryDocument as any,
161
+ ConnectedDemoQuery,
119
162
  {
120
163
  datasource: rendering.dataSource,
121
164
  contextItem: layoutData?.sitecore?.route?.itemId,
@@ -143,7 +186,7 @@ export const getServerSideProps: GetServerSideComponentProps = async (rendering,
143
186
 
144
187
  const result = await graphQLClient.request<GraphQLConnectedDemoData>(
145
188
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
- ConnectedDemoQueryDocument as any,
189
+ ConnectedDemoQuery,
147
190
  {
148
191
  datasource: rendering.dataSource,
149
192
  contextItem: layoutData?.sitecore?.route?.itemId,
@@ -8,13 +8,15 @@ import {
8
8
  } from '@sitecore-jss/sitecore-jss-nextjs';
9
9
  import { ComponentProps } from 'lib/component-props';
10
10
 
11
- type StyleguideLayoutTabsTabProps = ComponentProps & {
11
+ export type TabProps = {
12
12
  fields: {
13
13
  content: Field<string>;
14
14
  title: Field<string>;
15
15
  };
16
16
  };
17
17
 
18
+ type StyleguideLayoutTabsTabProps = ComponentProps & TabProps;
19
+
18
20
  /**
19
21
  * This is a single tab within the tabs sample component. These are added to the tabs placeholder.
20
22
  * This component demonstrates conditionally altering rendering when in the Sitecore Experience Editor to improve
@@ -3,6 +3,7 @@ import { withPlaceholder, withSitecoreContext, Text } from '@sitecore-jss/siteco
3
3
  import StyleguideSpecimen from './Styleguide-Specimen';
4
4
  import { ComponentWithContextProps } from 'lib/component-props';
5
5
  import { StyleguideSpecimenFields } from 'lib/component-props/styleguide';
6
+ import { TabProps } from './Styleguide-Layout-Tabs-Tab';
6
7
 
7
8
  interface StyleguideLayoutTabsState {
8
9
  activeTabIndex: number;
@@ -55,7 +56,7 @@ class StyleguideLayoutTabs extends React.Component<
55
56
  */}
56
57
  {!isEditing &&
57
58
  (tabsPlaceholder || [])
58
- .filter((tab: ReactElement) => tab.props && tab.props.fields)
59
+ .filter((tab: ReactElement) => tab.props && (tab.props as TabProps).fields)
59
60
  .map((tab: ReactElement, index: number) => (
60
61
  <li className="nav-item" key={`tab${index}`}>
61
62
  <a
@@ -63,14 +64,14 @@ class StyleguideLayoutTabs extends React.Component<
63
64
  onClick={() => this.setActiveTab(index)}
64
65
  href="#t"
65
66
  >
66
- <Text field={tab.props.fields.title} />
67
+ <Text field={(tab.props as TabProps).fields.title} />
67
68
  </a>
68
69
  </li>
69
70
  ))}
70
71
  </ul>
71
72
  <div className="p-3 border-left border-right border-bottom">
72
73
  {(tabsPlaceholder || []).map((tab: ReactElement) => {
73
- const isValid = tab.props && tab.props.fields;
74
+ const isValid = tab.props && (tab.props as TabProps).fields;
74
75
 
75
76
  // allow experience editor markup components to render
76
77
  if (!isValid && isEditing) return tab;
@@ -7,19 +7,7 @@ const graphqlPlugin = (nextConfig = {}) => {
7
7
  config.module.rules.push({
8
8
  test: /\.graphql$/,
9
9
  exclude: /node_modules/,
10
- use: [options.defaultLoaders.babel, { loader: 'graphql-let/loader' }],
11
- });
12
-
13
- config.module.rules.push({
14
- test: /\.graphqls$/,
15
- exclude: /node_modules/,
16
- use: ['graphql-let/schema/loader'],
17
- });
18
-
19
- config.module.rules.push({
20
- test: /\.ya?ml$/,
21
- type: 'json',
22
- use: 'yaml-loader',
10
+ loader: 'graphql-tag/loader',
23
11
  });
24
12
 
25
13
  // Overload the Webpack config if it was already overloaded
@@ -28,7 +16,7 @@ const graphqlPlugin = (nextConfig = {}) => {
28
16
  }
29
17
 
30
18
  return config;
31
- }
19
+ },
32
20
  });
33
21
  };
34
22
 
@@ -18,13 +18,13 @@ type StyleguideTrackingProps = ComponentWithContextProps & StyleguideSpecimenFie
18
18
  * Demonstrates analytics tracking patterns (xDB)
19
19
  */
20
20
  class StyleguideTracking extends React.Component<StyleguideTrackingProps> {
21
- private event: RefObject<HTMLInputElement>;
22
- private goal: RefObject<HTMLInputElement>;
23
- private outcomeName: RefObject<HTMLInputElement>;
24
- private outcomeValue: RefObject<HTMLInputElement>;
25
- private campaign: RefObject<HTMLInputElement>;
26
- private pageId: RefObject<HTMLInputElement>;
27
- private pageUrl: RefObject<HTMLInputElement>;
21
+ private event: RefObject<HTMLInputElement | null>;
22
+ private goal: RefObject<HTMLInputElement | null>;
23
+ private outcomeName: RefObject<HTMLInputElement | null>;
24
+ private outcomeValue: RefObject<HTMLInputElement | null>;
25
+ private campaign: RefObject<HTMLInputElement | null>;
26
+ private pageId: RefObject<HTMLInputElement | null>;
27
+ private pageUrl: RefObject<HTMLInputElement | null>;
28
28
 
29
29
  private trackingApiOptions: TrackingRequestOptions;
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sitecore-jss",
3
- "version": "22.8.0-canary.1",
3
+ "version": "22.8.0-canary.3",
4
4
  "description": "Sitecore JSS initializer",
5
5
  "bin": "./dist/index.js",
6
6
  "scripts": {
@@ -65,5 +65,5 @@
65
65
  "ts-node": "^10.9.1",
66
66
  "typescript": "~5.6.3"
67
67
  },
68
- "gitHead": "970cbaf93d540940cc9b85ebec0023011e92d73c"
68
+ "gitHead": "79696336a6cfd4ee3fd533cc28ebd87dd748ad41"
69
69
  }
@@ -1,8 +0,0 @@
1
- schema:
2
- - './src/temp/GraphQLIntrospectionResult.json'
3
- documents: 'src/**/*.graphql'
4
- plugins:
5
- - typescript-operations
6
- - typed-document-node
7
- config:
8
- useIndexSignature: true
@@ -1,46 +0,0 @@
1
- import { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss-nextjs/graphql';
2
- import fs from 'fs';
3
- import { getIntrospectionQuery } from 'graphql';
4
-
5
- // This script load graphql introspection data in order to use graphql code generator and generate typescript types
6
- // The `jss graphql:update` command should be executed when Sitecore templates related to the site are altered.
7
-
8
- let jssConfig;
9
-
10
- try {
11
- // eslint-disable-next-line
12
- jssConfig = require('../src/temp/config');
13
- } catch (e) {
14
- console.error(
15
- 'Unable to require JSS config. Ensure `jss setup` has been run, and the app has been started at least once after setup.'
16
- );
17
- console.error(e);
18
- process.exit(1);
19
- }
20
-
21
- console.log(`Fetch graphql introspection data from ${jssConfig.graphQLEndpoint}...`);
22
-
23
- const client = new GraphQLRequestClient(jssConfig.graphQLEndpoint, {
24
- apiKey: jssConfig.sitecoreApiKey,
25
- });
26
-
27
- client
28
- .request(getIntrospectionQuery())
29
- .then(result => {
30
- fs.writeFile(
31
- './src/temp/GraphQLIntrospectionResult.json',
32
- JSON.stringify(result, null, 2),
33
- err => {
34
- if (err) {
35
- console.error('Error writing GraphQLIntrospectionResult file', err);
36
- return;
37
- }
38
-
39
- console.log('GraphQL Introspection Data successfully fetched!');
40
- }
41
- );
42
- })
43
- .catch(e => {
44
- console.error(e);
45
- process.exit(1);
46
- });