@ninetailed/experience.js-gatsby 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/gatsby-node.js +61 -57
  2. package/package.json +3 -3
package/gatsby-node.js CHANGED
@@ -54,64 +54,68 @@ const createPages = ({
54
54
  graphql
55
55
  }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
56
56
  const ninetailedGatsbyPlugin = store.getState().flattenedPlugins.find(plugin => plugin.name === '@ninetailed/experience.js-gatsby');
57
- if (ninetailedGatsbyPlugin) {
58
- const {
59
- setPluginStatus
60
- } = actions;
61
- const ninetailedPreviewPlugin = ninetailedGatsbyPlugin.pluginOptions.ninetailedPlugins.find(plugin => plugin.name === '@ninetailed/experience.js-plugin-preview');
62
- if (!ninetailedPreviewPlugin.options.customOptions) {
63
- throw new Error('CustomOptions not found. CustomOptions are mandatory and need to be set in the preview plugin options.');
64
- }
65
- const {
66
- audienceQuery,
67
- experienceQuery,
68
- audienceMapper,
69
- experienceMapper
70
- } = ninetailedPreviewPlugin.options.customOptions;
71
- const audienceOptionsSet = audienceQuery && audienceMapper;
72
- const experienceOptionsSet = experienceQuery && experienceMapper;
73
- const passThroughReturn = {
74
- errors: null,
75
- data: null
76
- };
77
- if (!audienceOptionsSet) {
78
- console.warn('No audience query or mapper found. Please provide both to process audience data.');
79
- }
80
- const {
81
- errors: audienceErrors,
82
- data: audienceData
83
- } = audienceOptionsSet ? yield graphql(audienceQuery) : passThroughReturn;
84
- if (!experienceOptionsSet) {
85
- console.warn('No experience query or mapper found. Please provide both to process experience data.');
86
- }
87
- const {
88
- errors: experienceErrors,
89
- data: experienceData
90
- } = experienceOptionsSet ? yield graphql(experienceQuery) : passThroughReturn;
91
- if (audienceErrors) {
92
- throw new Error('Failed to query audience data. Check query configuration or data retrieval by the source plugin.');
93
- }
94
- const audiences = audienceOptionsSet ? audienceMapper(audienceData) : [];
95
- if (experienceErrors) {
96
- throw new Error('Failed to query experience data. Check query configuration or data retrieval by the source plugin.');
97
- }
98
- const experiences = experienceOptionsSet ? experienceMapper(experienceData) : [];
99
- const ninetailedPreviewPluginOverride = Object.assign(Object.assign({}, ninetailedPreviewPlugin), {
100
- options: Object.assign(Object.assign({}, ninetailedPreviewPlugin.options), {
101
- audiences,
102
- experiences
103
- })
104
- });
105
- const ninetailedPluginsOverwrite = ninetailedGatsbyPlugin.pluginOptions.ninetailedPlugins.map(plugin => {
106
- return plugin === ninetailedPreviewPlugin ? ninetailedPreviewPluginOverride : plugin;
107
- });
108
- ninetailedGatsbyPlugin.pluginOptions = Object.assign(Object.assign({}, ninetailedGatsbyPlugin.pluginOptions), {
109
- ninetailedPlugins: ninetailedPluginsOverwrite
110
- });
111
- setPluginStatus({
112
- pluginOptions: ninetailedGatsbyPlugin.pluginOptions
113
- }, ninetailedGatsbyPlugin);
57
+ if (!ninetailedGatsbyPlugin) {
58
+ return;
59
+ }
60
+ const ninetailedPreviewPlugin = ninetailedGatsbyPlugin.pluginOptions.ninetailedPlugins.find(plugin => plugin.name === '@ninetailed/experience.js-plugin-preview');
61
+ if (!ninetailedPreviewPlugin) {
62
+ return;
63
+ }
64
+ const {
65
+ setPluginStatus
66
+ } = actions;
67
+ if (!ninetailedPreviewPlugin.options.customOptions) {
68
+ throw new Error('CustomOptions not found. CustomOptions are mandatory and need to be set in the preview plugin options.');
114
69
  }
70
+ const {
71
+ audienceQuery,
72
+ experienceQuery,
73
+ audienceMapper,
74
+ experienceMapper
75
+ } = ninetailedPreviewPlugin.options.customOptions;
76
+ const audienceOptionsSet = audienceQuery && audienceMapper;
77
+ const experienceOptionsSet = experienceQuery && experienceMapper;
78
+ const passThroughReturn = {
79
+ errors: null,
80
+ data: null
81
+ };
82
+ if (!audienceOptionsSet) {
83
+ console.warn('No audience query or mapper found. Please provide both to process audience data.');
84
+ }
85
+ const {
86
+ errors: audienceErrors,
87
+ data: audienceData
88
+ } = audienceOptionsSet ? yield graphql(audienceQuery) : passThroughReturn;
89
+ if (!experienceOptionsSet) {
90
+ console.warn('No experience query or mapper found. Please provide both to process experience data.');
91
+ }
92
+ const {
93
+ errors: experienceErrors,
94
+ data: experienceData
95
+ } = experienceOptionsSet ? yield graphql(experienceQuery) : passThroughReturn;
96
+ if (audienceErrors) {
97
+ throw new Error('Failed to query audience data. Check query configuration or data retrieval by the source plugin.');
98
+ }
99
+ const audiences = audienceOptionsSet ? audienceMapper(audienceData) : [];
100
+ if (experienceErrors) {
101
+ throw new Error('Failed to query experience data. Check query configuration or data retrieval by the source plugin.');
102
+ }
103
+ const experiences = experienceOptionsSet ? experienceMapper(experienceData) : [];
104
+ const ninetailedPreviewPluginOverride = Object.assign(Object.assign({}, ninetailedPreviewPlugin), {
105
+ options: Object.assign(Object.assign({}, ninetailedPreviewPlugin.options), {
106
+ audiences,
107
+ experiences
108
+ })
109
+ });
110
+ const ninetailedPluginsOverwrite = ninetailedGatsbyPlugin.pluginOptions.ninetailedPlugins.map(plugin => {
111
+ return plugin === ninetailedPreviewPlugin ? ninetailedPreviewPluginOverride : plugin;
112
+ });
113
+ ninetailedGatsbyPlugin.pluginOptions = Object.assign(Object.assign({}, ninetailedGatsbyPlugin.pluginOptions), {
114
+ ninetailedPlugins: ninetailedPluginsOverwrite
115
+ });
116
+ setPluginStatus({
117
+ pluginOptions: ninetailedGatsbyPlugin.pluginOptions
118
+ }, ninetailedGatsbyPlugin);
115
119
  });
116
120
 
117
121
  exports.createPages = createPages;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-gatsby",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "keywords": [
5
5
  "gatsby",
6
6
  "gatsby-plugin",
@@ -18,8 +18,8 @@
18
18
  "type": "commonjs",
19
19
  "types": "./index.d.ts",
20
20
  "dependencies": {
21
- "@ninetailed/experience.js": "4.2.0",
22
- "@ninetailed/experience.js-react": "4.2.0",
21
+ "@ninetailed/experience.js": "4.2.1",
22
+ "@ninetailed/experience.js-react": "4.2.1",
23
23
  "gatsby-plugin-utils": "3.19.0"
24
24
  }
25
25
  }