@ninetailed/experience.js-gatsby 4.2.0 → 4.2.2-beta.0

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