create-sitecore-jss 22.2.0-canary.9 → 22.3.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +17 -43
- package/dist/common/processes/next.js +4 -1
- package/dist/common/processes/transform.js +2 -12
- package/dist/common/prompts/base.js +0 -13
- package/dist/common/prompts/proxy.js +35 -0
- package/dist/common/prompts/sxp.js +16 -2
- package/dist/common/utils/helpers.js +27 -2
- package/dist/init-runner.js +1 -1
- package/dist/initializers/angular/prompts.js +4 -4
- package/dist/initializers/angular-xmcloud/index.js +21 -7
- package/dist/initializers/node-xmcloud-proxy/index.js +2 -1
- package/dist/templates/angular/.env +4 -5
- package/dist/templates/angular/.eslintrc +1 -0
- package/dist/templates/angular/gitignore +5 -0
- package/dist/templates/angular/package.json +6 -8
- package/dist/templates/angular/scripts/config/plugins/fallback.ts +0 -1
- package/dist/templates/angular/scripts/generate-component-factory/index.ts +45 -0
- package/dist/templates/angular/scripts/generate-component-factory/plugins/component-factory.ts +147 -0
- package/dist/templates/angular/scripts/generate-component-factory/plugins/components.ts +19 -0
- package/dist/templates/angular/scripts/generate-component-factory/plugins/packages.ts +29 -0
- package/dist/templates/angular/scripts/generate-component-factory/template.ts +46 -0
- package/dist/templates/angular/scripts/generate-config.ts +25 -6
- package/dist/templates/angular/scripts/generate-plugins.ts +5 -0
- package/dist/templates/angular/scripts/update-graphql-fragment-data.ts +21 -30
- package/dist/templates/angular/server.bundle.ts +3 -23
- package/dist/templates/angular/server.exports.ts +13 -0
- package/dist/templates/angular/src/app/JssState.ts +2 -9
- package/dist/templates/angular/src/app/app.module.ts +5 -4
- package/dist/templates/angular/src/app/app.server.module.ts +9 -6
- package/dist/templates/angular/src/app/components/gitignore +1 -1
- package/dist/templates/angular/src/app/i18n/jss-translation-client-loader.service.ts +15 -7
- package/dist/templates/angular/src/app/i18n/jss-translation-server-loader.service.ts +14 -2
- package/dist/templates/angular/src/app/jss-context.server-side.service.ts +4 -2
- package/dist/templates/angular/src/app/jss-context.service.ts +14 -11
- package/dist/templates/angular/src/app/jss-graphql.service.ts +7 -7
- package/dist/templates/angular/src/app/layout/jss-layout.service.ts +2 -2
- package/dist/templates/angular/src/app/lib/dictionary-service-factory.ts +4 -1
- package/dist/templates/angular/src/app/lib/graphql-client-factory/config.ts +21 -0
- package/dist/templates/angular/src/app/lib/graphql-client-factory/index.ts +16 -0
- package/dist/templates/angular/src/app/lib/layout-service-factory.ts +1 -1
- package/dist/templates/angular/src/app/routing/layout/layout.component.ts +10 -9
- package/dist/templates/angular/src/environments/gitignore +2 -1
- package/dist/templates/angular-sxp/.env +2 -0
- package/dist/templates/angular-sxp/scripts/config/plugins/disconnected.ts +4 -2
- package/dist/templates/angular-sxp/src/app/components/graph-ql-layout/graph-ql-layout.component.ts +1 -1
- package/dist/templates/angular-xmcloud/.env +15 -2
- package/dist/templates/angular-xmcloud/angular.json +0 -1
- package/dist/templates/angular-xmcloud/package.json +2 -0
- package/dist/templates/angular-xmcloud/scripts/bootstrap.ts +28 -0
- package/dist/templates/angular-xmcloud/scripts/config/plugins/xmcloud.ts +16 -0
- package/dist/templates/angular-xmcloud/scripts/generate-component-factory/plugins/packages.ts +34 -0
- package/dist/templates/angular-xmcloud/scripts/generate-component-factory/template.ts +57 -0
- package/dist/templates/angular-xmcloud/scripts/generate-metadata.ts +25 -0
- package/dist/templates/angular-xmcloud/server.exports.ts +24 -0
- package/dist/templates/angular-xmcloud/src/app/components/app-components.shared.module.ts +21 -0
- package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.html +5 -0
- package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.ts +40 -0
- package/dist/templates/angular-xmcloud/src/app/components/container/container.component.html +2 -3
- package/dist/templates/angular-xmcloud/src/app/components/image/image.component.html +36 -0
- package/dist/templates/angular-xmcloud/src/app/components/image/image.component.ts +67 -0
- package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.html +15 -0
- package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.ts +41 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.html +23 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.ts +65 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.html +21 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.ts +49 -0
- package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.html +5 -0
- package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.ts +39 -0
- package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.html +1 -0
- package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.ts +15 -0
- package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.html +21 -0
- package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.ts +13 -0
- package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.html +7 -12
- package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.ts +6 -1
- package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.html +11 -0
- package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.ts +35 -0
- package/dist/templates/angular-xmcloud/src/app/components/sxa.component.ts +3 -3
- package/dist/templates/angular-xmcloud/src/app/components/title/title.component.html +10 -0
- package/dist/templates/angular-xmcloud/src/app/components/title/title.component.ts +56 -0
- package/dist/templates/angular-xmcloud/src/app/jss-link.service.ts +55 -0
- package/dist/templates/angular-xmcloud/src/app/lib/config.ts +2 -0
- package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory/config.ts +58 -0
- package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.html +38 -0
- package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.ts +104 -0
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/cdp-page-view.component.ts +77 -0
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/cloud-sdk-init.component.ts +48 -0
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.component.html +5 -0
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.module.ts +12 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_header.scss +3 -1
- package/dist/templates/angular-xmcloud/src/assets/styles/main.scss +10 -0
- package/dist/templates/nextjs/package.json +5 -5
- package/dist/templates/nextjs/scripts/config/plugins/fallback.ts +0 -1
- package/dist/templates/nextjs/scripts/generate-config.ts +8 -1
- package/dist/templates/nextjs/src/lib/page-props-factory/plugins/component-props.ts +2 -1
- package/dist/templates/nextjs-styleguide/package.json +1 -1
- package/dist/templates/nextjs-styleguide/scripts/config/plugins/disconnected.ts +1 -0
- package/dist/templates/nextjs-sxa/src/assets/sass/components/common/_alignment.scss +34 -7
- package/dist/templates/nextjs-sxa/src/components/Container.tsx +6 -14
- package/dist/templates/nextjs-xmcloud/package.json +3 -2
- package/dist/templates/nextjs-xmcloud/src/Bootstrap.tsx +25 -10
- package/dist/templates/nextjs-xmcloud/src/byoc/{index.ts → index.tsx} +25 -8
- package/dist/templates/nextjs-xmcloud/src/components/CdpPageView.tsx +9 -14
- package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/component-themes.ts +2 -1
- package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/preview-mode.ts +2 -1
- package/dist/templates/node-headless-ssr-experience-edge/gitignore +19 -0
- package/dist/templates/node-headless-ssr-experience-edge/package.json +2 -2
- package/dist/templates/node-headless-ssr-proxy/gitignore +19 -0
- package/dist/templates/node-headless-ssr-proxy/package.json +3 -3
- package/dist/templates/node-headless-ssr-proxy/src/config.ts +3 -3
- package/dist/templates/node-headless-ssr-proxy/src/httpAgents.ts +2 -2
- package/dist/templates/node-headless-ssr-proxy/src/index.ts +9 -2
- package/dist/templates/node-xmcloud-proxy/.env +7 -1
- package/dist/templates/node-xmcloud-proxy/README.md +1 -1
- package/dist/templates/node-xmcloud-proxy/gitignore +33 -0
- package/dist/templates/node-xmcloud-proxy/package.json +3 -2
- package/dist/templates/node-xmcloud-proxy/src/config.ts +9 -3
- package/dist/templates/node-xmcloud-proxy/src/index.ts +54 -5
- package/dist/templates/node-xmcloud-proxy/src/types.ts +10 -42
- package/dist/templates/react/package.json +5 -5
- package/dist/templates/react/scripts/generate-config.js +10 -3
- package/dist/templates/react-native/package.json +4 -4
- package/dist/templates/vue/package.json +4 -4
- package/dist/templates/vue/scripts/generate-config.js +5 -0
- package/package.json +2 -2
- package/dist/templates/angular/scripts/generate-component-factory.ts +0 -166
- package/dist/templates/angular/src/app/lib/graphql-client-factory.ts +0 -28
- package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory.ts +0 -44
- package/dist/templates/nextjs-xmcloud/src/lib/context/index.ts +0 -22
- package/dist/templates/nextjs-xmcloud/src/lib/context/sdk/events.ts +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-sitecore-jss",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.3.0-canary.1",
|
|
4
4
|
"description": "Sitecore JSS initializer",
|
|
5
5
|
"bin": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"ts-node": "^10.9.1",
|
|
64
64
|
"typescript": "~4.9.5"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "204eb3427f26d4ba8c08f44cf9c772f19f2820a8"
|
|
67
67
|
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const chokidar = require('chokidar');
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
COMPONENT FACTORY GENERATION
|
|
7
|
-
Generates the /src/app/components/app-components.module.ts file which maps Angular components
|
|
8
|
-
to JSS components.
|
|
9
|
-
|
|
10
|
-
The component factory module defines a mapping between a string component name and a Angular component instance.
|
|
11
|
-
When the Sitecore Layout service returns a layout definition, it returns named components.
|
|
12
|
-
This mapping is used to construct the component hierarchy for the layout.
|
|
13
|
-
|
|
14
|
-
NOTE: this script can run in two modes. The default mode, the component factory file is written once.
|
|
15
|
-
But if `--watch` is a process argument, the component factory source folder will be watched,
|
|
16
|
-
and the componentFactory.js rewritten on added or deleted files.
|
|
17
|
-
This is used during `jss start` to pick up new or removed components at runtime.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export interface PackageDefinition {
|
|
21
|
-
name: string;
|
|
22
|
-
components: {
|
|
23
|
-
moduleName: string;
|
|
24
|
-
componentName: string;
|
|
25
|
-
}[];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const componentFactoryPath = path.resolve('src/app/components/app-components.module.ts');
|
|
29
|
-
const componentRootPath = 'src/app/components';
|
|
30
|
-
|
|
31
|
-
const isWatch = process.argv.some((arg) => arg === '--watch');
|
|
32
|
-
|
|
33
|
-
if (isWatch) {
|
|
34
|
-
watchComponentFactory();
|
|
35
|
-
} else {
|
|
36
|
-
writeComponentFactory();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function watchComponentFactory() {
|
|
40
|
-
console.log(`Watching for changes to component factory sources in ${componentRootPath}...`);
|
|
41
|
-
|
|
42
|
-
chokidar
|
|
43
|
-
.watch(componentRootPath, { ignoreInitial: true, awaitWriteFinish: true })
|
|
44
|
-
.on('add', writeComponentFactory)
|
|
45
|
-
.on('unlink', writeComponentFactory);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function writeComponentFactory() {
|
|
49
|
-
const componentFactory = generateComponentFactory();
|
|
50
|
-
|
|
51
|
-
console.log(`Writing component factory to ${componentFactoryPath}`);
|
|
52
|
-
|
|
53
|
-
fs.writeFileSync(componentFactoryPath, componentFactory, { encoding: 'utf8' });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function generateComponentFactory() {
|
|
57
|
-
// By convention, we expect to find Angular components
|
|
58
|
-
// under /src/app/components/component-name/component-name.component.ts
|
|
59
|
-
// If a component-name.module.ts file exists, we will treat it as lazy loaded.
|
|
60
|
-
// If you'd like to use your own convention, encode it below.
|
|
61
|
-
// NOTE: generating the component factory module is also totally optional,
|
|
62
|
-
// and it can be maintained manually if preferred.
|
|
63
|
-
|
|
64
|
-
const imports: string[] = [];
|
|
65
|
-
/**
|
|
66
|
-
* You can specify components which you want to import from external/internal packages
|
|
67
|
-
* in format:
|
|
68
|
-
* {
|
|
69
|
-
* name: 'package name',
|
|
70
|
-
* components: [
|
|
71
|
-
* {
|
|
72
|
-
* componentName: 'component name', // component rendering name,
|
|
73
|
-
* moduleName: 'module name' // component name to import from the package
|
|
74
|
-
* }
|
|
75
|
-
* ]
|
|
76
|
-
* }
|
|
77
|
-
*/
|
|
78
|
-
const packages: PackageDefinition[] = [];
|
|
79
|
-
const registrations: string[] = [];
|
|
80
|
-
const lazyRegistrations: string[] = [];
|
|
81
|
-
const declarations: string[] = [];
|
|
82
|
-
|
|
83
|
-
packages.forEach((p) => {
|
|
84
|
-
const variables = p.components
|
|
85
|
-
.map((c) => {
|
|
86
|
-
registrations.push(`{ name: '${c.componentName}', type: ${c.moduleName} },`);
|
|
87
|
-
declarations.push(`${c.moduleName},`);
|
|
88
|
-
|
|
89
|
-
return c.moduleName;
|
|
90
|
-
})
|
|
91
|
-
.join(', ');
|
|
92
|
-
imports.push(`import { ${variables} } from '${p.name}'`);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
fs.readdirSync(componentRootPath).forEach((componentFolder) => {
|
|
96
|
-
// ignore ts files in component root folder
|
|
97
|
-
if (componentFolder.endsWith('.ts') || componentFolder === '.gitignore') {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const componentFilePath = path.join(componentRootPath, componentFolder, `${componentFolder}.component.ts`);
|
|
102
|
-
|
|
103
|
-
if (!fs.existsSync(componentFilePath)) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const componentFileContents = fs.readFileSync(componentFilePath, 'utf8');
|
|
108
|
-
|
|
109
|
-
// ASSUMPTION: your component should export a class directly that follows Angular conventions,
|
|
110
|
-
// i.e. `export class FooComponent` - so we can detect the component's name for auto registration.
|
|
111
|
-
const componentClassMatch = /export class (.+?)Component\b/g.exec(componentFileContents);
|
|
112
|
-
|
|
113
|
-
if (componentClassMatch === null) {
|
|
114
|
-
console.debug(`Component ${componentFilePath} did not seem to export a component class. It will be skipped.`);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const componentName = componentClassMatch[1];
|
|
119
|
-
const importVarName = `${componentName}Component`;
|
|
120
|
-
|
|
121
|
-
// check for lazy loading needs
|
|
122
|
-
const moduleFilePath = path.join(componentRootPath, componentFolder, `${componentFolder}.module.ts`);
|
|
123
|
-
const isLazyLoaded = fs.existsSync(moduleFilePath);
|
|
124
|
-
|
|
125
|
-
if (isLazyLoaded) {
|
|
126
|
-
console.debug(`Registering JSS component (lazy) ${componentName}`);
|
|
127
|
-
lazyRegistrations.push(`{ path: '${componentName}', loadChildren: () => import('./${componentFolder}/${componentFolder}.module').then(m => m.${componentName}Module) },`);
|
|
128
|
-
} else {
|
|
129
|
-
console.debug(`Registering JSS component ${componentName}`);
|
|
130
|
-
imports.push(`import { ${importVarName} } from './${componentFolder}/${componentFolder}.component';`);
|
|
131
|
-
registrations.push(`{ name: '${componentName}', type: ${importVarName} },`);
|
|
132
|
-
declarations.push(`${importVarName},`);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
return `// Do not edit this file, it is auto-generated at build time!
|
|
137
|
-
// See scripts/generate-component-factory.js to modify the generation of this file.
|
|
138
|
-
// Use app-components.shared.module.ts to modify the imports, etc of this module.
|
|
139
|
-
// Note: code-generation is optional! See ./.gitignore for directions to remove it,
|
|
140
|
-
// if you do not want it.
|
|
141
|
-
|
|
142
|
-
import { NgModule } from '@angular/core';
|
|
143
|
-
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
144
|
-
import { AppComponentsSharedModule } from './app-components.shared.module';
|
|
145
|
-
${imports.join('\n')}
|
|
146
|
-
|
|
147
|
-
@NgModule({
|
|
148
|
-
imports: [
|
|
149
|
-
AppComponentsSharedModule,
|
|
150
|
-
JssModule.withComponents([
|
|
151
|
-
${registrations.join('\n ')}
|
|
152
|
-
], [
|
|
153
|
-
${lazyRegistrations.join('\n ')}
|
|
154
|
-
]),
|
|
155
|
-
],
|
|
156
|
-
exports: [
|
|
157
|
-
JssModule,
|
|
158
|
-
AppComponentsSharedModule,
|
|
159
|
-
],
|
|
160
|
-
declarations: [
|
|
161
|
-
${declarations.join('\n ')}
|
|
162
|
-
],
|
|
163
|
-
})
|
|
164
|
-
export class AppComponentsModule { }
|
|
165
|
-
`;
|
|
166
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GraphQLRequestClientFactoryConfig,
|
|
3
|
-
GraphQLRequestClient,
|
|
4
|
-
} from '@sitecore-jss/sitecore-jss-angular';
|
|
5
|
-
import { environment as env } from '../../environments/environment';
|
|
6
|
-
|
|
7
|
-
// The GraphQLRequestClientFactory serves as the central hub for executing GraphQL requests within the application
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new GraphQLRequestClientFactory instance
|
|
11
|
-
* @returns GraphQLRequestClientFactory instance
|
|
12
|
-
*/
|
|
13
|
-
export const createGraphQLClientFactory = () => {
|
|
14
|
-
let clientConfig: GraphQLRequestClientFactoryConfig;
|
|
15
|
-
|
|
16
|
-
if (env.graphQLEndpoint && env.sitecoreApiKey) {
|
|
17
|
-
clientConfig = {
|
|
18
|
-
endpoint: env.graphQLEndpoint,
|
|
19
|
-
apiKey: env.sitecoreApiKey,
|
|
20
|
-
};
|
|
21
|
-
} else {
|
|
22
|
-
throw new Error('Please configure your graphQLEndpoint and sitecoreApiKey.');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return GraphQLRequestClient.createClientFactory(clientConfig);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const clientFactory = createGraphQLClientFactory();
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GraphQLRequestClientFactoryConfig,
|
|
3
|
-
GraphQLRequestClient,
|
|
4
|
-
} from '@sitecore-jss/sitecore-jss-angular';
|
|
5
|
-
import { environment as env } from '../../environments/environment';
|
|
6
|
-
|
|
7
|
-
// The GraphQLRequestClientFactory serves as the central hub for executing GraphQL requests within the application
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new GraphQLRequestClientFactory instance
|
|
11
|
-
* @returns GraphQLRequestClientFactory instance
|
|
12
|
-
*/
|
|
13
|
-
export const createGraphQLClientFactory = () => {
|
|
14
|
-
let clientConfig: GraphQLRequestClientFactoryConfig;
|
|
15
|
-
|
|
16
|
-
// If we are in a production environment we are going to use Node XM Cloud proxy
|
|
17
|
-
if (env.production === 'true') {
|
|
18
|
-
if (env.proxyHost && env.sitecoreApiKey && env.graphQLEndpoint) {
|
|
19
|
-
// Server side requests should go directly to the Sitecore, browser requests should go through the proxy.
|
|
20
|
-
clientConfig = {
|
|
21
|
-
endpoint:
|
|
22
|
-
typeof window === 'undefined'
|
|
23
|
-
? env.graphQLEndpoint
|
|
24
|
-
: `${env.proxyHost}${env.graphQLEndpointPath}`,
|
|
25
|
-
apiKey: env.sitecoreApiKey,
|
|
26
|
-
};
|
|
27
|
-
} else {
|
|
28
|
-
throw new Error('Please configure your proxyHost, sitecoreApiKey, graphQLEndpoint.');
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
if (env.graphQLEndpoint && env.sitecoreApiKey) {
|
|
32
|
-
clientConfig = {
|
|
33
|
-
endpoint: env.graphQLEndpoint,
|
|
34
|
-
apiKey: env.sitecoreApiKey,
|
|
35
|
-
};
|
|
36
|
-
} else {
|
|
37
|
-
throw new Error('Please configure your graphQLEndpoint and sitecoreApiKey.');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return GraphQLRequestClient.createClientFactory(clientConfig);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const clientFactory = createGraphQLClientFactory();
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Context } from '@sitecore-jss/sitecore-jss-nextjs/context';
|
|
2
|
-
import config from 'temp/config';
|
|
3
|
-
|
|
4
|
-
import Events from './sdk/events';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* List of SDKs to be initialized.
|
|
8
|
-
* Each SDK is defined as a module with the @type {SDK} type.
|
|
9
|
-
*/
|
|
10
|
-
const sdks = {
|
|
11
|
-
Events,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
16
|
-
*/
|
|
17
|
-
export const context = new Context<typeof sdks>({
|
|
18
|
-
sitecoreEdgeUrl: config.sitecoreEdgeUrl,
|
|
19
|
-
sitecoreEdgeContextId: config.sitecoreEdgeContextId,
|
|
20
|
-
siteName: config.sitecoreSiteName,
|
|
21
|
-
sdks,
|
|
22
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as Events from '@sitecore-cloudsdk/events/browser';
|
|
2
|
-
import { SDK } from '@sitecore-jss/sitecore-jss-nextjs/context';
|
|
3
|
-
|
|
4
|
-
const sdkModule: SDK<typeof Events> = {
|
|
5
|
-
sdk: Events,
|
|
6
|
-
init: async (props) => {
|
|
7
|
-
// Events module can't be initialized on the server side
|
|
8
|
-
// We also don't want to initialize it in development mode
|
|
9
|
-
if (typeof window === 'undefined')
|
|
10
|
-
throw 'Browser Events SDK is not initialized in server context';
|
|
11
|
-
if (process.env.NODE_ENV === 'development')
|
|
12
|
-
throw 'Browser Events SDK is not initialized in development environment';
|
|
13
|
-
|
|
14
|
-
await Events.init({
|
|
15
|
-
siteName: props.siteName,
|
|
16
|
-
sitecoreEdgeUrl: props.sitecoreEdgeUrl,
|
|
17
|
-
sitecoreEdgeContextId: props.sitecoreEdgeContextId,
|
|
18
|
-
// Replace with the top level cookie domain of the website that is being integrated e.g ".example.com" and not "www.example.com"
|
|
19
|
-
cookieDomain: window.location.hostname.replace(/^www\./, ''),
|
|
20
|
-
// Cookie may be created in personalize middleware (server), but if not we should create it here
|
|
21
|
-
enableBrowserCookie: true,
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default sdkModule;
|