@driveflux/cms 1.4.8 → 1.4.10

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.
@@ -1,905 +1,674 @@
1
- function _array_like_to_array(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _array_without_holes(arr) {
7
- if (Array.isArray(arr)) return _array_like_to_array(arr);
8
- }
9
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
- try {
11
- var info = gen[key](arg);
12
- var value = info.value;
13
- } catch (error) {
14
- reject(error);
15
- return;
16
- }
17
- if (info.done) {
18
- resolve(value);
19
- } else {
20
- Promise.resolve(value).then(_next, _throw);
21
- }
22
- }
23
- function _async_to_generator(fn) {
24
- return function() {
25
- var self = this, args = arguments;
26
- return new Promise(function(resolve, reject) {
27
- var gen = fn.apply(self, args);
28
- function _next(value) {
29
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
- }
31
- function _throw(err) {
32
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
- }
34
- _next(undefined);
35
- });
36
- };
37
- }
38
- function _check_private_redeclaration(obj, privateCollection) {
39
- if (privateCollection.has(obj)) {
40
- throw new TypeError("Cannot initialize the same private elements twice on an object");
41
- }
42
- }
43
- function _class_apply_descriptor_get(receiver, descriptor) {
44
- if (descriptor.get) {
45
- return descriptor.get.call(receiver);
46
- }
47
- return descriptor.value;
48
- }
49
- function _class_apply_descriptor_set(receiver, descriptor, value) {
50
- if (descriptor.set) {
51
- descriptor.set.call(receiver, value);
52
- } else {
53
- if (!descriptor.writable) {
54
- throw new TypeError("attempted to set read only private field");
55
- }
56
- descriptor.value = value;
57
- }
58
- }
59
- function _class_call_check(instance, Constructor) {
60
- if (!(instance instanceof Constructor)) {
61
- throw new TypeError("Cannot call a class as a function");
62
- }
63
- }
64
- function _class_extract_field_descriptor(receiver, privateMap, action) {
65
- if (!privateMap.has(receiver)) {
66
- throw new TypeError("attempted to " + action + " private field on non-instance");
67
- }
68
- return privateMap.get(receiver);
69
- }
70
- function _class_private_field_get(receiver, privateMap) {
71
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
72
- return _class_apply_descriptor_get(receiver, descriptor);
73
- }
74
- function _class_private_field_init(obj, privateMap, value) {
75
- _check_private_redeclaration(obj, privateMap);
76
- privateMap.set(obj, value);
77
- }
78
- function _class_private_field_set(receiver, privateMap, value) {
79
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
80
- _class_apply_descriptor_set(receiver, descriptor, value);
81
- return value;
82
- }
83
- function _defineProperties(target, props) {
84
- for(var i = 0; i < props.length; i++){
85
- var descriptor = props[i];
86
- descriptor.enumerable = descriptor.enumerable || false;
87
- descriptor.configurable = true;
88
- if ("value" in descriptor) descriptor.writable = true;
89
- Object.defineProperty(target, descriptor.key, descriptor);
90
- }
91
- }
92
- function _create_class(Constructor, protoProps, staticProps) {
93
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
94
- if (staticProps) _defineProperties(Constructor, staticProps);
95
- return Constructor;
96
- }
97
- function _define_property(obj, key, value) {
98
- if (key in obj) {
99
- Object.defineProperty(obj, key, {
100
- value: value,
101
- enumerable: true,
102
- configurable: true,
103
- writable: true
104
- });
105
- } else {
106
- obj[key] = value;
107
- }
108
- return obj;
109
- }
110
- function _iterable_to_array(iter) {
111
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
112
- }
113
- function _non_iterable_spread() {
114
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
115
- }
116
- function _object_spread(target) {
117
- for(var i = 1; i < arguments.length; i++){
118
- var source = arguments[i] != null ? arguments[i] : {};
119
- var ownKeys = Object.keys(source);
120
- if (typeof Object.getOwnPropertySymbols === "function") {
121
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
122
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
123
- }));
124
- }
125
- ownKeys.forEach(function(key) {
126
- _define_property(target, key, source[key]);
127
- });
128
- }
129
- return target;
130
- }
131
- function ownKeys(object, enumerableOnly) {
132
- var keys = Object.keys(object);
133
- if (Object.getOwnPropertySymbols) {
134
- var symbols = Object.getOwnPropertySymbols(object);
135
- if (enumerableOnly) {
136
- symbols = symbols.filter(function(sym) {
137
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
138
- });
139
- }
140
- keys.push.apply(keys, symbols);
141
- }
142
- return keys;
143
- }
144
- function _object_spread_props(target, source) {
145
- source = source != null ? source : {};
146
- if (Object.getOwnPropertyDescriptors) {
147
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
148
- } else {
149
- ownKeys(Object(source)).forEach(function(key) {
150
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
151
- });
152
- }
153
- return target;
154
- }
155
- function _object_without_properties(source, excluded) {
156
- if (source == null) return {};
157
- var target = _object_without_properties_loose(source, excluded);
158
- var key, i;
159
- if (Object.getOwnPropertySymbols) {
160
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
161
- for(i = 0; i < sourceSymbolKeys.length; i++){
162
- key = sourceSymbolKeys[i];
163
- if (excluded.indexOf(key) >= 0) continue;
164
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
165
- target[key] = source[key];
166
- }
167
- }
168
- return target;
169
- }
170
- function _object_without_properties_loose(source, excluded) {
171
- if (source == null) return {};
172
- var target = {};
173
- var sourceKeys = Object.keys(source);
174
- var key, i;
175
- for(i = 0; i < sourceKeys.length; i++){
176
- key = sourceKeys[i];
177
- if (excluded.indexOf(key) >= 0) continue;
178
- target[key] = source[key];
179
- }
180
- return target;
181
- }
182
- function _to_consumable_array(arr) {
183
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
184
- }
185
- function _unsupported_iterable_to_array(o, minLen) {
186
- if (!o) return;
187
- if (typeof o === "string") return _array_like_to_array(o, minLen);
188
- var n = Object.prototype.toString.call(o).slice(8, -1);
189
- if (n === "Object" && o.constructor) n = o.constructor.name;
190
- if (n === "Map" || n === "Set") return Array.from(n);
191
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
192
- }
193
- function _ts_generator(thisArg, body) {
194
- var f, y, t, g, _ = {
195
- label: 0,
196
- sent: function() {
197
- if (t[0] & 1) throw t[1];
198
- return t[1];
199
- },
200
- trys: [],
201
- ops: []
202
- };
203
- return g = {
204
- next: verb(0),
205
- "throw": verb(1),
206
- "return": verb(2)
207
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
208
- return this;
209
- }), g;
210
- function verb(n) {
211
- return function(v) {
212
- return step([
213
- n,
214
- v
215
- ]);
216
- };
217
- }
218
- function step(op) {
219
- if (f) throw new TypeError("Generator is already executing.");
220
- while(_)try {
221
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
222
- if (y = 0, t) op = [
223
- op[0] & 2,
224
- t.value
225
- ];
226
- switch(op[0]){
227
- case 0:
228
- case 1:
229
- t = op;
230
- break;
231
- case 4:
232
- _.label++;
233
- return {
234
- value: op[1],
235
- done: false
236
- };
237
- case 5:
238
- _.label++;
239
- y = op[1];
240
- op = [
241
- 0
242
- ];
243
- continue;
244
- case 7:
245
- op = _.ops.pop();
246
- _.trys.pop();
247
- continue;
248
- default:
249
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
250
- _ = 0;
251
- continue;
252
- }
253
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
254
- _.label = op[1];
255
- break;
256
- }
257
- if (op[0] === 6 && _.label < t[1]) {
258
- _.label = t[1];
259
- t = op;
260
- break;
261
- }
262
- if (t && _.label < t[2]) {
263
- _.label = t[2];
264
- _.ops.push(op);
265
- break;
266
- }
267
- if (t[2]) _.ops.pop();
268
- _.trys.pop();
269
- continue;
270
- }
271
- op = body.call(thisArg, _);
272
- } catch (e) {
273
- op = [
274
- 6,
275
- e
276
- ];
277
- y = 0;
278
- } finally{
279
- f = t = 0;
280
- }
281
- if (op[0] & 5) throw op[1];
282
- return {
283
- value: op[0] ? op[1] : void 0,
284
- done: true
285
- };
286
- }
287
- }
288
1
  import { cloneDeep } from '@driveflux/utils';
289
2
  import pThrottle from 'p-throttle';
290
- var headerProps = function(param) {
291
- var header = param.header, forceHeaderAlign = param.forceHeaderAlign;
292
- return {
293
- header: header,
294
- forceHeaderAlign: forceHeaderAlign
295
- };
296
- };
297
- var buttonProps = function(param) {
298
- var buttonLink = param.buttonLink, buttonText = param.buttonText;
299
- return {
300
- buttonLink: buttonLink,
301
- buttonText: buttonText
302
- };
303
- };
304
- var DEFAULT_SECTION_HANDLERS = {
305
- Reviews: function(section) {
306
- return _object_spread_props(_object_spread({
307
- __typename: section.__typename
308
- }, headerProps(section), buttonProps(section)), {
309
- reviews: section.names.map(function(name, i) {
310
- var _section_images, _section_vehicles, _section_reviews;
311
- var data = {
312
- name: name,
313
- image: (_section_images = section.images) === null || _section_images === void 0 ? void 0 : _section_images[i],
314
- vehicle: (_section_vehicles = section.vehicles) === null || _section_vehicles === void 0 ? void 0 : _section_vehicles[i],
315
- review: (_section_reviews = section.reviews) === null || _section_reviews === void 0 ? void 0 : _section_reviews[i]
3
+ const headerProps = ({ header, forceHeaderAlign })=>({
4
+ header,
5
+ forceHeaderAlign
6
+ });
7
+ const buttonProps = ({ buttonLink, buttonText })=>({
8
+ buttonLink,
9
+ buttonText
10
+ });
11
+ const DEFAULT_SECTION_HANDLERS = {
12
+ Reviews: (section)=>{
13
+ return {
14
+ __typename: section.__typename,
15
+ ...headerProps(section),
16
+ ...buttonProps(section),
17
+ reviews: section.names.map((name, i)=>{
18
+ const data = {
19
+ name,
20
+ image: section.images?.[i],
21
+ vehicle: section.vehicles?.[i],
22
+ review: section.reviews?.[i]
316
23
  };
317
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
318
- try {
319
- for(var _iterator = Object.keys(data)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
320
- var key = _step.value;
321
- if (data[key] === undefined) {
322
- delete data[key];
323
- }
324
- }
325
- } catch (err) {
326
- _didIteratorError = true;
327
- _iteratorError = err;
328
- } finally{
329
- try {
330
- if (!_iteratorNormalCompletion && _iterator.return != null) {
331
- _iterator.return();
332
- }
333
- } finally{
334
- if (_didIteratorError) {
335
- throw _iteratorError;
336
- }
24
+ for (const key of Object.keys(data)){
25
+ if (data[key] === undefined) {
26
+ delete data[key];
337
27
  }
338
28
  }
339
29
  return data;
340
30
  })
341
- });
31
+ };
342
32
  },
343
- VehicleShowcase: function(section) {
344
- return _object_spread_props(_object_spread({
345
- __typename: section.__typename
346
- }, headerProps(section), buttonProps(section)), {
347
- vehicles: section.topTitles.map(function(topTitle, i) {
348
- var _section_secondaryTitles, _section_photos, _section_contents;
349
- var data = {
350
- topTitle: topTitle,
351
- secondaryTitle: (_section_secondaryTitles = section.secondaryTitles) === null || _section_secondaryTitles === void 0 ? void 0 : _section_secondaryTitles[i],
352
- photo: (_section_photos = section.photos) === null || _section_photos === void 0 ? void 0 : _section_photos[i],
353
- content: (_section_contents = section.contents) === null || _section_contents === void 0 ? void 0 : _section_contents[i]
33
+ VehicleShowcase: (section)=>{
34
+ return {
35
+ __typename: section.__typename,
36
+ ...headerProps(section),
37
+ ...buttonProps(section),
38
+ vehicles: section.topTitles.map((topTitle, i)=>{
39
+ const data = {
40
+ topTitle,
41
+ secondaryTitle: section.secondaryTitles?.[i],
42
+ photo: section.photos?.[i],
43
+ content: section.contents?.[i]
354
44
  };
355
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
356
- try {
357
- for(var _iterator = Object.keys(data)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
358
- var key = _step.value;
359
- if (data[key] === undefined) {
360
- delete data[key];
361
- }
362
- }
363
- } catch (err) {
364
- _didIteratorError = true;
365
- _iteratorError = err;
366
- } finally{
367
- try {
368
- if (!_iteratorNormalCompletion && _iterator.return != null) {
369
- _iterator.return();
370
- }
371
- } finally{
372
- if (_didIteratorError) {
373
- throw _iteratorError;
374
- }
45
+ for (const key of Object.keys(data)){
46
+ if (data[key] === undefined) {
47
+ delete data[key];
375
48
  }
376
49
  }
377
50
  return data;
378
51
  })
379
- });
52
+ };
380
53
  },
381
- MultiplePhotoCaption: function(section) {
382
- return _object_spread_props(_object_spread({
383
- __typename: section.__typename
384
- }, headerProps(section), buttonProps(section)), {
54
+ MultiplePhotoCaption: (section)=>{
55
+ return {
56
+ __typename: section.__typename,
57
+ ...headerProps(section),
58
+ ...buttonProps(section),
385
59
  useIconSize: section.useIconSize,
386
- photoCaptions: section.photos.map(function(photo, i) {
387
- var _section_descriptions, _section_titles;
388
- var data = {
389
- photo: photo,
390
- description: (_section_descriptions = section.descriptions) === null || _section_descriptions === void 0 ? void 0 : _section_descriptions[i],
391
- title: (_section_titles = section.titles) === null || _section_titles === void 0 ? void 0 : _section_titles[i]
60
+ photoCaptions: section.photos.map((photo, i)=>{
61
+ const data = {
62
+ photo,
63
+ description: section.descriptions?.[i],
64
+ title: section.titles?.[i]
392
65
  };
393
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
394
- try {
395
- for(var _iterator = Object.keys(data)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
396
- var key = _step.value;
397
- if (data[key] === undefined) {
398
- delete data[key];
399
- }
400
- }
401
- } catch (err) {
402
- _didIteratorError = true;
403
- _iteratorError = err;
404
- } finally{
405
- try {
406
- if (!_iteratorNormalCompletion && _iterator.return != null) {
407
- _iterator.return();
408
- }
409
- } finally{
410
- if (_didIteratorError) {
411
- throw _iteratorError;
412
- }
66
+ for (const key of Object.keys(data)){
67
+ if (data[key] === undefined) {
68
+ delete data[key];
413
69
  }
414
70
  }
415
71
  return data;
416
72
  })
417
- });
73
+ };
418
74
  },
419
- PhotoCarousel: function(section) {
420
- return _object_spread_props(_object_spread({
421
- __typename: section.__typename
422
- }, headerProps(section), buttonProps(section)), {
423
- photos: section.photos.map(function(photo, i) {
424
- var _section_titles, _section_hrefs;
425
- var data = {
426
- photo: photo,
427
- title: (_section_titles = section.titles) === null || _section_titles === void 0 ? void 0 : _section_titles[i],
428
- href: (_section_hrefs = section.hrefs) === null || _section_hrefs === void 0 ? void 0 : _section_hrefs[i]
75
+ PhotoCarousel: (section)=>{
76
+ return {
77
+ __typename: section.__typename,
78
+ ...headerProps(section),
79
+ ...buttonProps(section),
80
+ photos: section.photos.map((photo, i)=>{
81
+ const data = {
82
+ photo,
83
+ title: section.titles?.[i],
84
+ href: section.hrefs?.[i]
429
85
  };
430
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
431
- try {
432
- for(var _iterator = Object.keys(data)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
433
- var key = _step.value;
434
- if (data[key] === undefined) {
435
- delete data[key];
436
- }
437
- }
438
- } catch (err) {
439
- _didIteratorError = true;
440
- _iteratorError = err;
441
- } finally{
442
- try {
443
- if (!_iteratorNormalCompletion && _iterator.return != null) {
444
- _iterator.return();
445
- }
446
- } finally{
447
- if (_didIteratorError) {
448
- throw _iteratorError;
449
- }
86
+ for (const key of Object.keys(data)){
87
+ if (data[key] === undefined) {
88
+ delete data[key];
450
89
  }
451
90
  }
452
91
  return data;
453
92
  })
454
- });
93
+ };
455
94
  },
456
- BigTextColumns: function(section) {
457
- return _object_spread_props(_object_spread({
458
- __typename: section.__typename
459
- }, headerProps(section), buttonProps(section)), {
95
+ BigTextColumns: (section)=>{
96
+ return {
97
+ __typename: section.__typename,
98
+ ...headerProps(section),
99
+ ...buttonProps(section),
460
100
  content: section.content,
461
- columns: section.bigTitles.map(function(bigTitle, i) {
462
- var _section_smallTitles, _section_descriptions;
463
- var data = {
464
- bigTitle: bigTitle,
465
- smallTitle: (_section_smallTitles = section.smallTitles) === null || _section_smallTitles === void 0 ? void 0 : _section_smallTitles[i],
466
- description: (_section_descriptions = section.descriptions) === null || _section_descriptions === void 0 ? void 0 : _section_descriptions[i]
101
+ columns: section.bigTitles.map((bigTitle, i)=>{
102
+ const data = {
103
+ bigTitle,
104
+ smallTitle: section.smallTitles?.[i],
105
+ description: section.descriptions?.[i]
467
106
  };
468
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
469
- try {
470
- for(var _iterator = Object.keys(data)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
471
- var key = _step.value;
472
- if (data[key] === undefined) {
473
- delete data[key];
474
- }
475
- }
476
- } catch (err) {
477
- _didIteratorError = true;
478
- _iteratorError = err;
479
- } finally{
480
- try {
481
- if (!_iteratorNormalCompletion && _iterator.return != null) {
482
- _iterator.return();
483
- }
484
- } finally{
485
- if (_didIteratorError) {
486
- throw _iteratorError;
487
- }
107
+ for (const key of Object.keys(data)){
108
+ if (data[key] === undefined) {
109
+ delete data[key];
488
110
  }
489
111
  }
490
112
  return data;
491
113
  })
492
- });
114
+ };
493
115
  }
494
116
  };
495
- var throttle = pThrottle({
117
+ const throttle = pThrottle({
496
118
  limit: 5,
497
119
  interval: 1000
498
120
  });
499
- export var throttledFetch = throttle(/*#__PURE__*/ function() {
500
- var _ref = _async_to_generator(function(req, init) {
501
- return _ts_generator(this, function(_state) {
502
- return [
503
- 2,
504
- fetch(req, init)
505
- ];
506
- });
507
- });
508
- return function(req, init) {
509
- return _ref.apply(this, arguments);
510
- };
511
- }());
512
- var _config = /*#__PURE__*/ new WeakMap(), _locale = /*#__PURE__*/ new WeakMap(), _sectionHandlers = /*#__PURE__*/ new WeakMap();
513
- export var GraphCMS = /*#__PURE__*/ function() {
514
- "use strict";
515
- function GraphCMS(config) {
516
- var preview = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, locale = arguments.length > 2 ? arguments[2] : void 0;
517
- _class_call_check(this, GraphCMS);
518
- _define_property(this, "preview", void 0);
519
- _class_private_field_init(this, _config, {
520
- writable: true,
521
- value: void 0
522
- });
523
- _class_private_field_init(this, _locale, {
524
- writable: true,
525
- value: void 0
526
- });
527
- _class_private_field_init(this, _sectionHandlers, {
528
- writable: true,
529
- value: void 0
530
- });
121
+ export const throttledFetch = throttle(async (req, init)=>fetch(req, init));
122
+ export class GraphCMS {
123
+ preview;
124
+ #config;
125
+ #locale;
126
+ #sectionHandlers;
127
+ constructor(config, preview = false, locale){
531
128
  this.preview = preview;
532
- _class_private_field_set(this, _config, config);
533
- _class_private_field_set(this, _locale, locale);
534
- _class_private_field_set(this, _sectionHandlers, DEFAULT_SECTION_HANDLERS);
129
+ this.#config = config;
130
+ this.#locale = locale;
131
+ this.#sectionHandlers = DEFAULT_SECTION_HANDLERS;
535
132
  }
536
- _create_class(GraphCMS, [
537
- {
538
- key: "fetchAPI",
539
- value: function fetchAPI(query, variables) {
540
- var _this = this;
541
- return _async_to_generator(function() {
542
- var headers, res, json, error;
543
- return _ts_generator(this, function(_state) {
544
- switch(_state.label){
545
- case 0:
546
- // TODO
547
- //@ts-expect-error - this is a browser import, we will fix it later!
548
- headers = {
549
- 'Content-Type': 'application/json',
550
- Authorization: "Bearer ".concat(_this.preview ? _class_private_field_get(_this, _config).devAuthToken : _class_private_field_get(_this, _config).prodAuthToken)
551
- };
552
- if (_class_private_field_get(_this, _locale)) {
553
- headers['gcms-locales'] = "".concat(_class_private_field_get(_this, _locale), ",en");
554
- }
555
- return [
556
- 4,
557
- throttledFetch(_class_private_field_get(_this, _config).projectApi, {
558
- method: 'POST',
559
- headers: headers,
560
- body: JSON.stringify({
561
- query: query,
562
- variables: _object_spread_props(_object_spread({}, variables), {
563
- stage: _this.stage()
564
- })
565
- })
566
- })
567
- ];
568
- case 1:
569
- res = _state.sent();
570
- return [
571
- 4,
572
- res.json()
573
- ];
574
- case 2:
575
- json = _state.sent();
576
- if (json.errors) {
577
- console.error('GraphCMS Error:', JSON.stringify(json.errors, undefined, 2));
578
- error = new Error('Failed to fetch API');
579
- if (res.status === 429) {
580
- // @ts-expect-error
581
- error.limitsReached = true;
582
- }
583
- throw error;
584
- }
585
- return [
586
- 2,
587
- json.data
588
- ];
589
- }
590
- });
591
- })();
133
+ async fetchAPI(query, variables) {
134
+ // TODO
135
+ //@ts-expect-error - this is a browser import, we will fix it later!
136
+ const headers = {
137
+ 'Content-Type': 'application/json',
138
+ Authorization: `Bearer ${this.preview ? this.#config.devAuthToken : this.#config.prodAuthToken}`
139
+ };
140
+ if (this.#locale) {
141
+ headers['gcms-locales'] = `${this.#locale},en`;
142
+ }
143
+ const res = await throttledFetch(this.#config.projectApi, {
144
+ method: 'POST',
145
+ headers,
146
+ body: JSON.stringify({
147
+ query,
148
+ variables: {
149
+ ...variables,
150
+ stage: this.stage()
151
+ }
152
+ })
153
+ });
154
+ const json = await res.json();
155
+ if (json.errors) {
156
+ console.error('GraphCMS Error:', JSON.stringify(json.errors, undefined, 2));
157
+ const error = new Error('Failed to fetch API');
158
+ if (res.status === 429) {
159
+ // @ts-expect-error
160
+ error.limitsReached = true;
592
161
  }
593
- },
594
- {
595
- key: "stage",
596
- value: function stage() {
597
- return this.preview ? 'DRAFT' : 'PUBLISHED';
162
+ throw error;
163
+ }
164
+ return json.data;
165
+ }
166
+ stage() {
167
+ return this.preview ? 'DRAFT' : 'PUBLISHED';
168
+ }
169
+ async getPostById(id) {
170
+ const data = await this.fetchAPI(`
171
+ query PostById($id: ID!, $stage: Stage!) {
172
+ post(where: {id: $id}, stage: $stage) {
173
+ id
174
+ title
175
+ slug
176
+ date
177
+ excerpt
178
+ content {
179
+ json
180
+ references {
181
+ __typename
182
+ ... on Asset {
183
+ url
184
+ handle
185
+ }
186
+ }
187
+ }
188
+
189
+ coverImage {
190
+ url(transformation: {
191
+ image: {
192
+ resize: {
193
+ fit:crop,
194
+ width:585,
195
+ height:350
196
+ }
197
+ }
198
+ })
199
+ }
200
+
201
+ author {
202
+ name
203
+ picture {
204
+ url(transformation: {
205
+ image: {
206
+ resize: {
207
+ fit:crop,
208
+ width:60,
209
+ height:60
210
+ }
211
+ }
212
+ })
598
213
  }
599
- },
600
- {
601
- key: "getPostById",
602
- value: function getPostById(id) {
603
- var _this = this;
604
- return _async_to_generator(function() {
605
- var data;
606
- return _ts_generator(this, function(_state) {
607
- switch(_state.label){
608
- case 0:
609
- return [
610
- 4,
611
- _this.fetchAPI("\n query PostById($id: ID!, $stage: Stage!) {\n post(where: {id: $id}, stage: $stage) {\n id\n title\n slug\n date\n excerpt\n content {\n json\n references {\n __typename\n ... on Asset {\n url\n handle\n }\n }\n }\n \n coverImage {\n url(transformation: {\n image: {\n resize: {\n fit:crop,\n width:585,\n height:350\n }\n }\n })\n }\n\n author {\n name\n picture {\n url(transformation: {\n image: {\n resize: {\n fit:crop,\n width:60,\n height:60\n }\n }\n })\n }\n }\n \n featured\n category\n }\n }\n ", {
612
- id: id
613
- })
614
- ];
615
- case 1:
616
- data = _state.sent();
617
- return [
618
- 2,
619
- data.post
620
- ];
621
- }
622
- });
623
- })();
214
+ }
215
+
216
+ featured
217
+ category
218
+ }
219
+ }
220
+ `, {
221
+ id
222
+ });
223
+ return data.post;
224
+ }
225
+ async getPost(slug) {
226
+ const data1 = await this.fetchAPI(`
227
+ query PostBySlug($slug: String!, $stage: Stage!) {
228
+ post(where: {slug: $slug}, stage: $stage) {
229
+ id
230
+ title
231
+ slug
232
+ date
233
+ excerpt
234
+ content {
235
+ json
236
+ references {
237
+ __typename
238
+ ... on Asset {
239
+ url
240
+ handle
241
+ }
624
242
  }
625
- },
626
- {
627
- key: "getPost",
628
- value: function getPost(slug) {
629
- var _this = this;
630
- return _async_to_generator(function() {
631
- var _data2_next, _data2_previous, data1, post, data2;
632
- return _ts_generator(this, function(_state) {
633
- switch(_state.label){
634
- case 0:
635
- return [
636
- 4,
637
- _this.fetchAPI("\n query PostBySlug($slug: String!, $stage: Stage!) {\n post(where: {slug: $slug}, stage: $stage) {\n id\n title\n slug\n date\n excerpt\n content {\n json\n references {\n __typename\n ... on Asset {\n url\n handle\n }\n }\n }\n \n coverImage {\n url(transformation: {\n image: {\n resize: {\n fit:crop,\n width:585,\n height:350\n }\n }\n })\n }\n\n author {\n name\n picture {\n url(transformation: {\n image: {\n resize: {\n fit:crop,\n width:60,\n height:60\n }\n }\n })\n }\n }\n \n featured\n category\n }\n }\n ", {
638
- slug: slug
639
- })
640
- ];
641
- case 1:
642
- data1 = _state.sent();
643
- post = data1.post;
644
- if (!post) {
645
- return [
646
- 2,
647
- null
648
- ];
649
- }
650
- return [
651
- 4,
652
- _this.fetchAPI("\n query PostsMeta($postId: String!, $stage: Stage!) {\n next: posts(first: 1, after: $postId, stage: $stage) {\n title\n slug\n }\n previous: posts(first: 1, before: $postId, stage: $stage) {\n title\n slug\n }\n\n latest: posts(first: 3) {\n title\n slug\n excerpt\n coverImage {\n url(transformation: {\n image: {\n resize: {\n fit:crop,\n width:585,\n height:350\n }\n }\n }) \n }\n category\n }\n }\n ", {
653
- postId: post.id
654
- })
655
- ];
656
- case 2:
657
- data2 = _state.sent();
658
- return [
659
- 2,
660
- _object_spread_props(_object_spread({}, data1), {
661
- next: (_data2_next = data2.next) === null || _data2_next === void 0 ? void 0 : _data2_next[0],
662
- previous: (_data2_previous = data2.previous) === null || _data2_previous === void 0 ? void 0 : _data2_previous[0],
663
- latest: data2.latest
664
- })
665
- ];
666
- }
667
- });
668
- })();
243
+ }
244
+
245
+ coverImage {
246
+ url(transformation: {
247
+ image: {
248
+ resize: {
249
+ fit:crop,
250
+ width:585,
251
+ height:350
252
+ }
253
+ }
254
+ })
255
+ }
256
+
257
+ author {
258
+ name
259
+ picture {
260
+ url(transformation: {
261
+ image: {
262
+ resize: {
263
+ fit:crop,
264
+ width:60,
265
+ height:60
266
+ }
267
+ }
268
+ })
669
269
  }
670
- },
671
- {
672
- key: "getPostsForBlog",
673
- value: /**
270
+ }
271
+
272
+ featured
273
+ category
274
+ }
275
+ }
276
+ `, {
277
+ slug
278
+ });
279
+ const post = data1.post;
280
+ if (!post) {
281
+ return null;
282
+ }
283
+ const data2 = await this.fetchAPI(`
284
+ query PostsMeta($postId: String!, $stage: Stage!) {
285
+ next: posts(first: 1, after: $postId, stage: $stage) {
286
+ title
287
+ slug
288
+ }
289
+ previous: posts(first: 1, before: $postId, stage: $stage) {
290
+ title
291
+ slug
292
+ }
293
+
294
+ latest: posts(first: 3) {
295
+ title
296
+ slug
297
+ excerpt
298
+ coverImage {
299
+ url(transformation: {
300
+ image: {
301
+ resize: {
302
+ fit:crop,
303
+ width:585,
304
+ height:350
305
+ }
306
+ }
307
+ })
308
+ }
309
+ category
310
+ }
311
+ }
312
+ `, {
313
+ postId: post.id
314
+ });
315
+ return {
316
+ ...data1,
317
+ next: data2.next?.[0],
318
+ previous: data2.previous?.[0],
319
+ latest: data2.latest
320
+ };
321
+ }
322
+ /**
674
323
  * Get a list of posts
675
324
  *
676
325
  * @param first take first X elements
677
326
  * @param after after ID
678
- */ function getPostsForBlog(first, after) {
679
- var _this = this;
680
- return _async_to_generator(function() {
681
- var data;
682
- return _ts_generator(this, function(_state) {
683
- switch(_state.label){
684
- case 0:
685
- return [
686
- 4,
687
- _this.fetchAPI("\n query Posts($first: Int!, $after: String, $stage: Stage!) {\n posts(first: $first, after: $after, stage: $stage, where: {OR:[{featured: null}, {featured_not: true}]}, orderBy: date_DESC) {\n id\n title\n slug\n excerpt\n coverImage {\n url(transformation: {\n image: {\n resize: {\n fit:crop,\n width:585,\n height:350\n }\n }\n }) \n }\n category\n }\n\n ".concat(!after ? "featured: posts(first: 3, stage: $stage, where: { featured: true }, orderBy: date_DESC) {\n title\n slug\n excerpt\n coverImage {\n url(transformation: {\n image: {\n resize: {\n fit:crop,\n width:585,\n height:350\n }\n }\n }) \n }\n category\n }" : '', "\n }\n "), {
688
- first: first,
689
- after: after
690
- })
691
- ];
692
- case 1:
693
- data = _state.sent();
694
- return [
695
- 2,
696
- data
697
- ];
698
- }
699
- });
700
- })();
701
- }
702
- },
703
- {
704
- key: "getPostsSlugs",
705
- value: /**
327
+ */ async getPostsForBlog(first, after) {
328
+ const data = await this.fetchAPI(`
329
+ query Posts($first: Int!, $after: String, $stage: Stage!) {
330
+ posts(first: $first, after: $after, stage: $stage, where: {OR:[{featured: null}, {featured_not: true}]}, orderBy: date_DESC) {
331
+ id
332
+ title
333
+ slug
334
+ excerpt
335
+ coverImage {
336
+ url(transformation: {
337
+ image: {
338
+ resize: {
339
+ fit:crop,
340
+ width:585,
341
+ height:350
342
+ }
343
+ }
344
+ })
345
+ }
346
+ category
347
+ }
348
+
349
+ ${!after ? `featured: posts(first: 3, stage: $stage, where: { featured: true }, orderBy: date_DESC) {
350
+ title
351
+ slug
352
+ excerpt
353
+ coverImage {
354
+ url(transformation: {
355
+ image: {
356
+ resize: {
357
+ fit:crop,
358
+ width:585,
359
+ height:350
360
+ }
361
+ }
362
+ })
363
+ }
364
+ category
365
+ }` : ''}
366
+ }
367
+ `, {
368
+ first,
369
+ after
370
+ });
371
+ return data;
372
+ }
373
+ /**
706
374
  * Get a list of post slugs. This is used for getStaticPaths()
707
375
  *
708
376
  * @param first take first X elements
709
- */ function getPostsSlugs(first) {
710
- var _this = this;
711
- return _async_to_generator(function() {
712
- var data;
713
- return _ts_generator(this, function(_state) {
714
- switch(_state.label){
715
- case 0:
716
- return [
717
- 4,
718
- _this.fetchAPI("\n query PostsWithSlugs($first: Int!) {\n posts(first: $first) {\n slug\n }\n }", {
719
- first: first
720
- })
721
- ];
722
- case 1:
723
- data = _state.sent();
724
- return [
725
- 2,
726
- data.posts.map(function(p) {
727
- return p.slug;
728
- })
729
- ];
730
- }
731
- });
732
- })();
733
- }
734
- },
735
- {
736
- key: "getPagesSlugs",
737
- value: /**
377
+ */ async getPostsSlugs(first) {
378
+ const data = await this.fetchAPI(`
379
+ query PostsWithSlugs($first: Int!) {
380
+ posts(first: $first) {
381
+ slug
382
+ }
383
+ }`, {
384
+ first
385
+ });
386
+ return data.posts.map((p)=>p.slug);
387
+ }
388
+ /**
738
389
  * Get a list of page slugs. This is used for getStaticPaths()
739
390
  *
740
391
  * @param first take first X elements
741
- */ function getPagesSlugs(first) {
742
- var _this = this;
743
- return _async_to_generator(function() {
744
- var data;
745
- return _ts_generator(this, function(_state) {
746
- switch(_state.label){
747
- case 0:
748
- return [
749
- 4,
750
- _this.fetchAPI("\n query PagesSlugs($first: Int!) {\n pages(first: $first) {\n slug\n }\n }", {
751
- first: first
752
- })
753
- ];
754
- case 1:
755
- data = _state.sent();
756
- return [
757
- 2,
758
- data.pages.map(function(p) {
759
- return p.slug;
760
- })
761
- ];
762
- }
763
- });
764
- })();
765
- }
766
- },
767
- {
768
- key: "getSitemap",
769
- value: /**
392
+ */ async getPagesSlugs(first) {
393
+ const data = await this.fetchAPI(`
394
+ query PagesSlugs($first: Int!) {
395
+ pages(first: $first) {
396
+ slug
397
+ }
398
+ }`, {
399
+ first
400
+ });
401
+ return data.pages.map((p)=>p.slug);
402
+ }
403
+ /**
770
404
  * Get a list of entries for the sitemap
771
405
  *
772
- */ function getSitemap() {
773
- var _this = this;
774
- return _async_to_generator(function() {
775
- var _data_pages, _data_posts, data;
776
- return _ts_generator(this, function(_state) {
777
- switch(_state.label){
778
- case 0:
779
- return [
780
- 4,
781
- _this.fetchAPI("\n query Sitemap() {\n pages() {\n slug\n updatedAt\n }\n posts {\n slug\n updatedAt\n }\n }")
782
- ];
783
- case 1:
784
- data = _state.sent();
785
- return [
786
- 2,
787
- _to_consumable_array(((_data_pages = data.pages) === null || _data_pages === void 0 ? void 0 : _data_pages.map(function(p) {
788
- return {
789
- type: 'page',
790
- slug: p.slug,
791
- lastModifiedAt: p.updatedAt
792
- };
793
- })) || []).concat(_to_consumable_array(((_data_posts = data.posts) === null || _data_posts === void 0 ? void 0 : _data_posts.map(function(p) {
794
- return {
795
- type: 'post',
796
- slug: p.slug,
797
- lastModifiedAt: p.updatedAt
798
- };
799
- })) || []))
800
- ];
801
- }
802
- });
803
- })();
804
- }
805
- },
806
- {
807
- key: "getPage",
808
- value: /**
406
+ */ async getSitemap() {
407
+ const data = await this.fetchAPI(`
408
+ query Sitemap() {
409
+ pages() {
410
+ slug
411
+ updatedAt
412
+ }
413
+ posts {
414
+ slug
415
+ updatedAt
416
+ }
417
+ }`);
418
+ return [
419
+ ...data.pages?.map((p)=>({
420
+ type: 'page',
421
+ slug: p.slug,
422
+ lastModifiedAt: p.updatedAt
423
+ })) || [],
424
+ ...data.posts?.map((p)=>({
425
+ type: 'post',
426
+ slug: p.slug,
427
+ lastModifiedAt: p.updatedAt
428
+ })) || []
429
+ ];
430
+ }
431
+ /**
809
432
  * Get a page
810
433
  *
811
434
  * @param slug slug of the page
812
- */ function getPage(slug) {
813
- var _this = this;
814
- return _async_to_generator(function() {
815
- var data, _data_page, sections, pageData;
816
- return _ts_generator(this, function(_state) {
817
- switch(_state.label){
818
- case 0:
819
- return [
820
- 4,
821
- _this.fetchAPI("\n query PageBySlug($slug: String!, $stage: Stage!) {\n page(where: { slug: $slug }, stage: $stage) {\n title\n slug\n seo {\n title\n description\n keywords\n image {\n url(transformation: {\n image: {\n resize: {\n fit: crop,\n width: 1200,\n height: 627\n }\n }\n })\n }\n }\n sections {\n __typename\n ... on AvailableVehiclesForSubscription {\n header\n forceHeaderAlign\n make\n vehicleIDs\n inquiryType\n buttonText\n buttonLink\n }\n ... on CenteredHighlight {\n header\n forceHeaderAlign\n description\n inquiryType\n buttonText\n buttonLink\n }\n ... on DualPhotoContentSection {\n header\n description\n bigPhoto { url, width, height }\n smallPhoto { url, width, height }\n inquiryType\n buttonText\n buttonLink\n }\n ... on DualPhotoHeading {\n smallTitle\n make\n tagline\n image1 { url, width, height }\n image2 { url, width, height }\n inquiryType\n buttonText\n buttonLink\n }\n ... on FullWidthGallery {\n images { url, width, height }\n mobileImages { url, width, height }\n }\n ... on Reviews {\n header\n forceHeaderAlign\n images { url, width, height }\n names\n vehicles\n reviews\n inquiryType\n buttonText\n buttonLink\n }\n ... on VehicleShowcase {\n header\n forceHeaderAlign\n topTitles\n secondaryTitles\n photos { url, width, height }\n contents { raw }\n inquiryType\n buttonText\n buttonLink\n }\n ... on LineSeparator {\n id\n }\n ... on HeroHeading {\n header\n forceHeaderAlign\n subHeader\n description\n _dedupeHeroHeading_image: image { url, width, height }\n mobileImage { url, width, height }\n inquiryType\n buttonText\n buttonLink\n buttonVariant\n textColor\n }\n ... on RichTextSection {\n header\n forceHeaderAlign\n content { raw }\n inquiryType\n buttonText\n buttonLink\n }\n ... on ImageStepFlows {\n images { url, width, height }\n inquiryType\n buttonText\n buttonLink\n }\n ... on TermsCondition {\n header\n forceHeaderAlign\n content { raw }\n inquiryType\n buttonText\n buttonLink\n }\n ... on MultiplePhotoCaption {\n header\n forceHeaderAlign\n titles\n descriptions { raw }\n useIconSize\n photos { url, width, height }\n inquiryType\n buttonText\n buttonLink\n }\n ... on SinglePhotoContent {\n header\n content { raw }\n image { url, width, height }\n orientation\n inquiryType\n buttonText\n buttonLink\n }\n ... on DualBigImage {\n header\n forceHeaderAlign\n content { raw }\n leftImage { url, width, height }\n leftTitle\n leftCaption { raw }\n leftDarkBackground\n rightImage { url, width, height }\n rightTitle\n rightCaption { raw }\n rightDarkBackground\n inquiryType\n buttonText\n buttonLink\n }\n ... on PhotoCarousel {\n header\n forceHeaderAlign\n photos { url, width, height }\n titles\n hrefs\n inquiryType\n buttonText\n buttonLink\n }\n ... on TextPageBreak {\n headers\n aligns\n bgColor\n textColor\n }\n ... on BigTextColumns {\n header\n forceHeaderAlign\n content { raw }\n bigTitles\n smallTitles\n descriptions { raw }\n inquiryType\n buttonText\n buttonLink\n }\n ... on PhotoWithTextBox {\n header\n forceHeaderAlign\n content { raw }\n orientation\n image { url, width, height }\n isLightBackground\n inquiryType\n buttonText\n buttonLink\n }\n ... on PhotoGrid {\n header\n forceHeaderAlign\n images { url, width, height }\n inquiryType\n buttonText\n buttonLink\n }\n }\n }\n }", {
822
- slug: slug
823
- })
824
- ];
825
- case 1:
826
- data = _state.sent();
827
- if (!data.page) {
828
- return [
829
- 2,
830
- null
831
- ];
832
- }
833
- _data_page = data.page, sections = _data_page.sections, pageData = _object_without_properties(_data_page, [
834
- "sections"
835
- ]);
836
- return [
837
- 2,
838
- _object_spread_props(_object_spread({}, pageData), {
839
- sections: _this.fixSectionArrays(sections)
840
- })
841
- ];
842
- }
843
- });
844
- })();
435
+ */ async getPage(slug) {
436
+ const data = await this.fetchAPI(`
437
+ query PageBySlug($slug: String!, $stage: Stage!) {
438
+ page(where: { slug: $slug }, stage: $stage) {
439
+ title
440
+ slug
441
+ seo {
442
+ title
443
+ description
444
+ keywords
445
+ image {
446
+ url(transformation: {
447
+ image: {
448
+ resize: {
449
+ fit: crop,
450
+ width: 1200,
451
+ height: 627
452
+ }
453
+ }
454
+ })
845
455
  }
846
- },
847
- {
848
- key: "fixSectionArrays",
849
- value: function fixSectionArrays(sections) {
850
- var newSections = [];
851
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
852
- try {
853
- for(var _iterator = sections[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
854
- var section = _step.value;
855
- var fixedSection = cloneDeep(section);
856
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
857
- try {
858
- for(var _iterator1 = Object.keys(fixedSection)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
859
- var key = _step1.value;
860
- if (key.startsWith('_dedupe')) {
861
- var parts = key.split('_');
862
- // Remove the first two
863
- parts.shift();
864
- parts.shift();
865
- fixedSection[parts.join('')] = fixedSection[key];
866
- // @ts-expect-error // TODO
867
- delete fixedSection[key];
868
- }
869
- }
870
- } catch (err) {
871
- _didIteratorError1 = true;
872
- _iteratorError1 = err;
873
- } finally{
874
- try {
875
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
876
- _iterator1.return();
877
- }
878
- } finally{
879
- if (_didIteratorError1) {
880
- throw _iteratorError1;
881
- }
882
- }
883
- }
884
- newSections.push(_class_private_field_get(this, _sectionHandlers)[section.__typename] ? _class_private_field_get(this, _sectionHandlers)[section.__typename](fixedSection) : fixedSection);
885
- }
886
- } catch (err) {
887
- _didIteratorError = true;
888
- _iteratorError = err;
889
- } finally{
890
- try {
891
- if (!_iteratorNormalCompletion && _iterator.return != null) {
892
- _iterator.return();
893
- }
894
- } finally{
895
- if (_didIteratorError) {
896
- throw _iteratorError;
897
- }
898
- }
456
+ }
457
+ sections {
458
+ __typename
459
+ ... on AvailableVehiclesForSubscription {
460
+ header
461
+ forceHeaderAlign
462
+ make
463
+ vehicleIDs
464
+ inquiryType
465
+ buttonText
466
+ buttonLink
467
+ }
468
+ ... on CenteredHighlight {
469
+ header
470
+ forceHeaderAlign
471
+ description
472
+ inquiryType
473
+ buttonText
474
+ buttonLink
475
+ }
476
+ ... on DualPhotoContentSection {
477
+ header
478
+ description
479
+ bigPhoto { url, width, height }
480
+ smallPhoto { url, width, height }
481
+ inquiryType
482
+ buttonText
483
+ buttonLink
484
+ }
485
+ ... on DualPhotoHeading {
486
+ smallTitle
487
+ make
488
+ tagline
489
+ image1 { url, width, height }
490
+ image2 { url, width, height }
491
+ inquiryType
492
+ buttonText
493
+ buttonLink
494
+ }
495
+ ... on FullWidthGallery {
496
+ images { url, width, height }
497
+ mobileImages { url, width, height }
498
+ }
499
+ ... on Reviews {
500
+ header
501
+ forceHeaderAlign
502
+ images { url, width, height }
503
+ names
504
+ vehicles
505
+ reviews
506
+ inquiryType
507
+ buttonText
508
+ buttonLink
509
+ }
510
+ ... on VehicleShowcase {
511
+ header
512
+ forceHeaderAlign
513
+ topTitles
514
+ secondaryTitles
515
+ photos { url, width, height }
516
+ contents { raw }
517
+ inquiryType
518
+ buttonText
519
+ buttonLink
520
+ }
521
+ ... on LineSeparator {
522
+ id
523
+ }
524
+ ... on HeroHeading {
525
+ header
526
+ forceHeaderAlign
527
+ subHeader
528
+ description
529
+ _dedupeHeroHeading_image: image { url, width, height }
530
+ mobileImage { url, width, height }
531
+ inquiryType
532
+ buttonText
533
+ buttonLink
534
+ buttonVariant
535
+ textColor
536
+ }
537
+ ... on RichTextSection {
538
+ header
539
+ forceHeaderAlign
540
+ content { raw }
541
+ inquiryType
542
+ buttonText
543
+ buttonLink
544
+ }
545
+ ... on ImageStepFlows {
546
+ images { url, width, height }
547
+ inquiryType
548
+ buttonText
549
+ buttonLink
550
+ }
551
+ ... on TermsCondition {
552
+ header
553
+ forceHeaderAlign
554
+ content { raw }
555
+ inquiryType
556
+ buttonText
557
+ buttonLink
558
+ }
559
+ ... on MultiplePhotoCaption {
560
+ header
561
+ forceHeaderAlign
562
+ titles
563
+ descriptions { raw }
564
+ useIconSize
565
+ photos { url, width, height }
566
+ inquiryType
567
+ buttonText
568
+ buttonLink
569
+ }
570
+ ... on SinglePhotoContent {
571
+ header
572
+ content { raw }
573
+ image { url, width, height }
574
+ orientation
575
+ inquiryType
576
+ buttonText
577
+ buttonLink
578
+ }
579
+ ... on DualBigImage {
580
+ header
581
+ forceHeaderAlign
582
+ content { raw }
583
+ leftImage { url, width, height }
584
+ leftTitle
585
+ leftCaption { raw }
586
+ leftDarkBackground
587
+ rightImage { url, width, height }
588
+ rightTitle
589
+ rightCaption { raw }
590
+ rightDarkBackground
591
+ inquiryType
592
+ buttonText
593
+ buttonLink
594
+ }
595
+ ... on PhotoCarousel {
596
+ header
597
+ forceHeaderAlign
598
+ photos { url, width, height }
599
+ titles
600
+ hrefs
601
+ inquiryType
602
+ buttonText
603
+ buttonLink
604
+ }
605
+ ... on TextPageBreak {
606
+ headers
607
+ aligns
608
+ bgColor
609
+ textColor
610
+ }
611
+ ... on BigTextColumns {
612
+ header
613
+ forceHeaderAlign
614
+ content { raw }
615
+ bigTitles
616
+ smallTitles
617
+ descriptions { raw }
618
+ inquiryType
619
+ buttonText
620
+ buttonLink
621
+ }
622
+ ... on PhotoWithTextBox {
623
+ header
624
+ forceHeaderAlign
625
+ content { raw }
626
+ orientation
627
+ image { url, width, height }
628
+ isLightBackground
629
+ inquiryType
630
+ buttonText
631
+ buttonLink
632
+ }
633
+ ... on PhotoGrid {
634
+ header
635
+ forceHeaderAlign
636
+ images { url, width, height }
637
+ inquiryType
638
+ buttonText
639
+ buttonLink
640
+ }
641
+ }
642
+ }
643
+ }`, {
644
+ slug
645
+ });
646
+ if (!data.page) {
647
+ return null;
648
+ }
649
+ const { sections, ...pageData } = data.page;
650
+ return {
651
+ ...pageData,
652
+ sections: this.fixSectionArrays(sections)
653
+ };
654
+ }
655
+ fixSectionArrays(sections) {
656
+ const newSections = [];
657
+ for (const section of sections){
658
+ const fixedSection = cloneDeep(section);
659
+ for (const key of Object.keys(fixedSection)){
660
+ if (key.startsWith('_dedupe')) {
661
+ const parts = key.split('_');
662
+ // Remove the first two
663
+ parts.shift();
664
+ parts.shift();
665
+ fixedSection[parts.join('')] = fixedSection[key];
666
+ // @ts-expect-error // TODO
667
+ delete fixedSection[key];
899
668
  }
900
- return newSections;
901
669
  }
670
+ newSections.push(this.#sectionHandlers[section.__typename] ? this.#sectionHandlers[section.__typename](fixedSection) : fixedSection);
902
671
  }
903
- ]);
904
- return GraphCMS;
905
- }();
672
+ return newSections;
673
+ }
674
+ }