@sanity/client 6.7.1 → 6.8.0-pink-lizard.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 (65) hide show
  1. package/README.md +79 -2
  2. package/dist/_chunks/browserMiddleware-Oa7zKwEN.js +1862 -0
  3. package/dist/_chunks/browserMiddleware-Oa7zKwEN.js.map +1 -0
  4. package/dist/_chunks/browserMiddleware-zle5A-pb.cjs +1877 -0
  5. package/dist/_chunks/browserMiddleware-zle5A-pb.cjs.map +1 -0
  6. package/dist/_chunks/createEditLink-FiifjNgi.cjs +222 -0
  7. package/dist/_chunks/createEditLink-FiifjNgi.cjs.map +1 -0
  8. package/dist/_chunks/createEditLink-f3l2nngi.js +212 -0
  9. package/dist/_chunks/createEditLink-f3l2nngi.js.map +1 -0
  10. package/dist/_chunks/nodeMiddleware-S6QZVGmT.cjs +1897 -0
  11. package/dist/_chunks/nodeMiddleware-S6QZVGmT.cjs.map +1 -0
  12. package/dist/_chunks/nodeMiddleware-XodpBhbR.js +1882 -0
  13. package/dist/_chunks/nodeMiddleware-XodpBhbR.js.map +1 -0
  14. package/dist/csm.cjs +71 -0
  15. package/dist/csm.cjs.map +1 -0
  16. package/dist/csm.d.ts +248 -0
  17. package/dist/csm.js +58 -0
  18. package/dist/csm.js.map +1 -0
  19. package/dist/index.browser.cjs +13 -1868
  20. package/dist/index.browser.cjs.map +1 -1
  21. package/dist/index.browser.js +3 -1858
  22. package/dist/index.browser.js.map +1 -1
  23. package/dist/index.cjs +13 -1888
  24. package/dist/index.cjs.js +2 -2
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.js +3 -1878
  27. package/dist/index.js.map +1 -1
  28. package/dist/stega.browser.cjs +629 -0
  29. package/dist/stega.browser.cjs.map +1 -0
  30. package/dist/stega.browser.js +598 -0
  31. package/dist/stega.browser.js.map +1 -0
  32. package/dist/stega.cjs +424 -0
  33. package/dist/stega.cjs.js +21 -0
  34. package/dist/stega.cjs.map +1 -0
  35. package/dist/stega.d.ts +2872 -0
  36. package/dist/stega.js +393 -0
  37. package/dist/stega.js.map +1 -0
  38. package/package.json +42 -2
  39. package/src/config.ts +6 -0
  40. package/src/csm/applySourceDocuments.test.ts +820 -0
  41. package/src/csm/applySourceDocuments.ts +87 -0
  42. package/src/csm/createEditLink.ts +75 -0
  43. package/src/csm/getPublishedId.ts +12 -0
  44. package/src/csm/index.ts +9 -0
  45. package/src/csm/isArray.ts +3 -0
  46. package/src/csm/isRecord.ts +3 -0
  47. package/src/csm/jsonpath.test.ts +33 -0
  48. package/src/csm/jsonpath.ts +93 -0
  49. package/src/csm/resolveMapping.ts +41 -0
  50. package/src/csm/resolvedKeyedSourcePath.ts +23 -0
  51. package/src/csm/simplifyPath.ts +20 -0
  52. package/src/csm/types.ts +72 -0
  53. package/src/csm/walkMap.ts +30 -0
  54. package/src/stega/SanityStegaClient.ts +244 -0
  55. package/src/stega/config.ts +56 -0
  56. package/src/stega/encodeIntoResult.test.ts +268 -0
  57. package/src/stega/encodeIntoResult.ts +59 -0
  58. package/src/stega/filterDefault.ts +49 -0
  59. package/src/stega/index.browser.ts +19 -0
  60. package/src/stega/index.ts +19 -0
  61. package/src/stega/shared.ts +4 -0
  62. package/src/stega/stegaEncodeSourceMap.ts +128 -0
  63. package/src/stega/types.ts +139 -0
  64. package/umd/sanityClient.js +5 -1
  65. package/umd/sanityClient.min.js +1 -1
@@ -0,0 +1,820 @@
1
+ import {expect, test} from 'vitest'
2
+
3
+ import type {ContentSourceMap} from '../types'
4
+ import {applySourceDocuments} from './applySourceDocuments'
5
+
6
+ test('Can apply an array keyed field update', () => {
7
+ const result = {
8
+ page: {
9
+ _type: 'page',
10
+ _id: 'drafts.home',
11
+ title: 'Home',
12
+ sections: [
13
+ {
14
+ symbol: null,
15
+ products: null,
16
+ _type: 'hero',
17
+ tagline: 'ACME’s elegant construction is both minimal and inviting.',
18
+ headline: 'Touch of Texture ',
19
+ subline: 'You can follow us on Twitter, Twitch, LinkedIn, and GitHub.',
20
+ style: {
21
+ _type: 'sectionStyle',
22
+ variant: 'default',
23
+ },
24
+ _key: '44540ccd70c3',
25
+ product: null,
26
+ },
27
+ {
28
+ headline: 'Duplicate',
29
+ product: null,
30
+ products: null,
31
+ _type: 'hero',
32
+ _key: '50692538e3551f1805206202c8838ea5',
33
+ subline: 'You can follow us on Twitter, Twitch, LinkedIn, and GitHub..',
34
+ symbol: null,
35
+ tagline: 'ACME’s elegant construction is both minimal and inviting.',
36
+ style: {
37
+ _type: 'sectionStyle',
38
+ variant: 'default',
39
+ },
40
+ },
41
+ {
42
+ product: {
43
+ _type: 'product',
44
+ _id: 'drafts.462efcc6-3c8b-47c6-8474-5544e1a4acde',
45
+ title: 'Akoya',
46
+ slug: {
47
+ current: 'akoya',
48
+ _type: 'slug',
49
+ },
50
+ media: {
51
+ _type: 'image',
52
+ _key: 'cee5fbb69da2',
53
+ asset: {
54
+ _ref: 'image-a75b03fdd5b5fa36947bf2b776a542e0c940f682-1000x1500-jpg',
55
+ _type: 'reference',
56
+ },
57
+ },
58
+ },
59
+ description:
60
+ 'ACME partnered with industrial designer Jonas Damon to create Highline, an adaptable, easy-to-install system that marries the flexibility of a linear fixture with the thoughtful design of a pendant.',
61
+ style: {
62
+ _type: 'sectionStyle',
63
+ variant: 'default',
64
+ },
65
+ _key: '6b875593a9e1',
66
+ symbol: null,
67
+ _type: 'featureHighlight',
68
+ ctas: [
69
+ {
70
+ _key: '53685454c2c9',
71
+ title: 'Explore highline',
72
+ _type: 'cta',
73
+ href: '/highline',
74
+ },
75
+ ],
76
+ headline: 'Highlines',
77
+ image: {
78
+ _type: 'image',
79
+ asset: {
80
+ _ref: 'image-9d18bc376926c8e0b27a71adf95002d64ef65684-2200x2500-jpg',
81
+ _type: 'reference',
82
+ },
83
+ },
84
+ tagline: null,
85
+ subline: null,
86
+ products: null,
87
+ },
88
+ {
89
+ _key: 'e77f7c827ba4',
90
+ headline: 'Some Featured Products Here',
91
+ tagline: null,
92
+ subline: null,
93
+ product: null,
94
+ products: [
95
+ {
96
+ slug: {
97
+ _type: 'slug',
98
+ current: 'ripple-sconce',
99
+ },
100
+ media: {
101
+ _key: 'c51dda81eb69',
102
+ asset: {
103
+ _ref: 'image-9d18bc376926c8e0b27a71adf95002d64ef65684-2200x2500-jpg',
104
+ _type: 'reference',
105
+ },
106
+ _type: 'image',
107
+ },
108
+ _key: 'drafts.e1bf9f1f-efdb-4105-8c26-6b64f897e9c1',
109
+ _type: 'product',
110
+ _id: 'drafts.e1bf9f1f-efdb-4105-8c26-6b64f897e9c1',
111
+ title: 'Ripple Sconce',
112
+ },
113
+ {
114
+ media: {
115
+ _type: 'image',
116
+ _key: 'cee5fbb69da2',
117
+ asset: {
118
+ _ref: 'image-a75b03fdd5b5fa36947bf2b776a542e0c940f682-1000x1500-jpg',
119
+ _type: 'reference',
120
+ },
121
+ },
122
+ _key: 'drafts.462efcc6-3c8b-47c6-8474-5544e1a4acde',
123
+ _type: 'product',
124
+ _id: 'drafts.462efcc6-3c8b-47c6-8474-5544e1a4acde',
125
+ title: 'Akoya',
126
+ slug: {
127
+ current: 'akoya',
128
+ _type: 'slug',
129
+ },
130
+ },
131
+ {
132
+ media: {
133
+ _type: 'image',
134
+ _key: '55659c72ec46',
135
+ asset: {
136
+ _ref: 'image-c46098d15d7e75080ba279c09f2ea88f24736eb0-1000x1500-jpg',
137
+ _type: 'reference',
138
+ },
139
+ },
140
+ _key: 'drafts.807cc05c-8c4c-443a-a9c1-198fd3fd7b16',
141
+ _type: 'product',
142
+ _id: 'drafts.807cc05c-8c4c-443a-a9c1-198fd3fd7b16',
143
+ title: 'All sew',
144
+ slug: {
145
+ _type: 'slug',
146
+ current: 'all-sew',
147
+ },
148
+ },
149
+ ],
150
+ _type: 'featuredProducts',
151
+ style: {
152
+ _type: 'sectionStyle',
153
+ variant: 'default',
154
+ },
155
+ symbol: null,
156
+ },
157
+ {
158
+ style: {
159
+ _type: 'sectionStyle',
160
+ variant: 'default',
161
+ },
162
+ headline: 'Look at the person walking on this dune!',
163
+ tagline: null,
164
+ _key: '0bd049fc047a',
165
+ symbol: null,
166
+ subline: null,
167
+ product: null,
168
+ products: null,
169
+ image: {
170
+ _type: 'image',
171
+ asset: {
172
+ _ref: 'image-97bdac62b5809e77b80831823de7e8ff8cd20b43-8640x5760-jpg',
173
+ _type: 'reference',
174
+ },
175
+ },
176
+ _type: 'featureHighlight',
177
+ description: 'Lalala',
178
+ },
179
+ ],
180
+ style: null,
181
+ },
182
+ siteSettings: {
183
+ title: 'ACME',
184
+ copyrightText: 'ACME © 2023 — All Rights Reserved',
185
+ },
186
+ }
187
+ const resultSourceMap = {
188
+ documents: [
189
+ {
190
+ _id: 'drafts.home',
191
+ _type: 'page',
192
+ },
193
+ {
194
+ _id: 'drafts.462efcc6-3c8b-47c6-8474-5544e1a4acde',
195
+ _type: 'product',
196
+ },
197
+ {
198
+ _id: 'drafts.e1bf9f1f-efdb-4105-8c26-6b64f897e9c1',
199
+ _type: 'product',
200
+ },
201
+ {
202
+ _id: 'drafts.807cc05c-8c4c-443a-a9c1-198fd3fd7b16',
203
+ _type: 'product',
204
+ },
205
+ {
206
+ _id: 'drafts.siteSettings',
207
+ _type: 'siteSettings',
208
+ },
209
+ ],
210
+ paths: [
211
+ "$['_type']",
212
+ "$['_id']",
213
+ "$['title']",
214
+ "$['sections'][?(@._key=='44540ccd70c3')]['style']",
215
+ "$['sections'][?(@._key=='44540ccd70c3')]['_key']",
216
+ "$['sections'][?(@._key=='44540ccd70c3')]['_type']",
217
+ "$['sections'][?(@._key=='44540ccd70c3')]['tagline']",
218
+ "$['sections'][?(@._key=='44540ccd70c3')]['headline']",
219
+ "$['sections'][?(@._key=='44540ccd70c3')]['subline']",
220
+ "$['sections'][?(@._key=='50692538e3551f1805206202c8838ea5')]['_type']",
221
+ "$['sections'][?(@._key=='50692538e3551f1805206202c8838ea5')]['_key']",
222
+ "$['sections'][?(@._key=='50692538e3551f1805206202c8838ea5')]['headline']",
223
+ "$['sections'][?(@._key=='50692538e3551f1805206202c8838ea5')]['tagline']",
224
+ "$['sections'][?(@._key=='50692538e3551f1805206202c8838ea5')]['style']",
225
+ "$['sections'][?(@._key=='50692538e3551f1805206202c8838ea5')]['subline']",
226
+ "$['slug']",
227
+ "$['media'][?(@._key=='cee5fbb69da2')]",
228
+ "$['sections'][?(@._key=='6b875593a9e1')]['description']",
229
+ "$['sections'][?(@._key=='6b875593a9e1')]['style']",
230
+ "$['sections'][?(@._key=='6b875593a9e1')]['_key']",
231
+ "$['sections'][?(@._key=='6b875593a9e1')]['_type']",
232
+ "$['sections'][?(@._key=='6b875593a9e1')]['ctas']",
233
+ "$['sections'][?(@._key=='6b875593a9e1')]['headline']",
234
+ "$['sections'][?(@._key=='6b875593a9e1')]['image']",
235
+ "$['sections'][?(@._key=='e77f7c827ba4')]['_key']",
236
+ "$['sections'][?(@._key=='e77f7c827ba4')]['headline']",
237
+ "$['media'][?(@._key=='c51dda81eb69')]",
238
+ "$['media'][?(@._key=='55659c72ec46')]",
239
+ "$['sections'][?(@._key=='e77f7c827ba4')]['_type']",
240
+ "$['sections'][?(@._key=='e77f7c827ba4')]['style']",
241
+ "$['sections'][?(@._key=='0bd049fc047a')]['_type']",
242
+ "$['sections'][?(@._key=='0bd049fc047a')]['description']",
243
+ "$['sections'][?(@._key=='0bd049fc047a')]['_key']",
244
+ "$['sections'][?(@._key=='0bd049fc047a')]['image']",
245
+ "$['sections'][?(@._key=='0bd049fc047a')]['headline']",
246
+ "$['sections'][?(@._key=='0bd049fc047a')]['style']",
247
+ "$['copyrightText']",
248
+ ],
249
+ mappings: {
250
+ "$['page']['_id']": {
251
+ source: {
252
+ document: 0,
253
+ path: 1,
254
+ type: 'documentValue',
255
+ },
256
+ type: 'value',
257
+ },
258
+ "$['page']['_type']": {
259
+ source: {
260
+ document: 0,
261
+ path: 0,
262
+ type: 'documentValue',
263
+ },
264
+ type: 'value',
265
+ },
266
+ "$['page']['sections'][0]['_key']": {
267
+ source: {
268
+ document: 0,
269
+ path: 4,
270
+ type: 'documentValue',
271
+ },
272
+ type: 'value',
273
+ },
274
+ "$['page']['sections'][0]['_type']": {
275
+ source: {
276
+ document: 0,
277
+ path: 5,
278
+ type: 'documentValue',
279
+ },
280
+ type: 'value',
281
+ },
282
+ "$['page']['sections'][0]['headline']": {
283
+ source: {
284
+ document: 0,
285
+ path: 7,
286
+ type: 'documentValue',
287
+ },
288
+ type: 'value',
289
+ },
290
+ "$['page']['sections'][0]['style']": {
291
+ source: {
292
+ document: 0,
293
+ path: 3,
294
+ type: 'documentValue',
295
+ },
296
+ type: 'value',
297
+ },
298
+ "$['page']['sections'][0]['subline']": {
299
+ source: {
300
+ document: 0,
301
+ path: 8,
302
+ type: 'documentValue',
303
+ },
304
+ type: 'value',
305
+ },
306
+ "$['page']['sections'][0]['tagline']": {
307
+ source: {
308
+ document: 0,
309
+ path: 6,
310
+ type: 'documentValue',
311
+ },
312
+ type: 'value',
313
+ },
314
+ "$['page']['sections'][1]['_key']": {
315
+ source: {
316
+ document: 0,
317
+ path: 10,
318
+ type: 'documentValue',
319
+ },
320
+ type: 'value',
321
+ },
322
+ "$['page']['sections'][1]['_type']": {
323
+ source: {
324
+ document: 0,
325
+ path: 9,
326
+ type: 'documentValue',
327
+ },
328
+ type: 'value',
329
+ },
330
+ "$['page']['sections'][1]['headline']": {
331
+ source: {
332
+ document: 0,
333
+ path: 11,
334
+ type: 'documentValue',
335
+ },
336
+ type: 'value',
337
+ },
338
+ "$['page']['sections'][1]['style']": {
339
+ source: {
340
+ document: 0,
341
+ path: 13,
342
+ type: 'documentValue',
343
+ },
344
+ type: 'value',
345
+ },
346
+ "$['page']['sections'][1]['subline']": {
347
+ source: {
348
+ document: 0,
349
+ path: 14,
350
+ type: 'documentValue',
351
+ },
352
+ type: 'value',
353
+ },
354
+ "$['page']['sections'][1]['tagline']": {
355
+ source: {
356
+ document: 0,
357
+ path: 12,
358
+ type: 'documentValue',
359
+ },
360
+ type: 'value',
361
+ },
362
+ "$['page']['sections'][2]['_key']": {
363
+ source: {
364
+ document: 0,
365
+ path: 19,
366
+ type: 'documentValue',
367
+ },
368
+ type: 'value',
369
+ },
370
+ "$['page']['sections'][2]['_type']": {
371
+ source: {
372
+ document: 0,
373
+ path: 20,
374
+ type: 'documentValue',
375
+ },
376
+ type: 'value',
377
+ },
378
+ "$['page']['sections'][2]['ctas']": {
379
+ source: {
380
+ document: 0,
381
+ path: 21,
382
+ type: 'documentValue',
383
+ },
384
+ type: 'value',
385
+ },
386
+ "$['page']['sections'][2]['description']": {
387
+ source: {
388
+ document: 0,
389
+ path: 17,
390
+ type: 'documentValue',
391
+ },
392
+ type: 'value',
393
+ },
394
+ "$['page']['sections'][2]['headline']": {
395
+ source: {
396
+ document: 0,
397
+ path: 22,
398
+ type: 'documentValue',
399
+ },
400
+ type: 'value',
401
+ },
402
+ "$['page']['sections'][2]['image']": {
403
+ source: {
404
+ document: 0,
405
+ path: 23,
406
+ type: 'documentValue',
407
+ },
408
+ type: 'value',
409
+ },
410
+ "$['page']['sections'][2]['product']['_id']": {
411
+ source: {
412
+ document: 1,
413
+ path: 1,
414
+ type: 'documentValue',
415
+ },
416
+ type: 'value',
417
+ },
418
+ "$['page']['sections'][2]['product']['_type']": {
419
+ source: {
420
+ document: 1,
421
+ path: 0,
422
+ type: 'documentValue',
423
+ },
424
+ type: 'value',
425
+ },
426
+ "$['page']['sections'][2]['product']['media']": {
427
+ source: {
428
+ document: 1,
429
+ path: 16,
430
+ type: 'documentValue',
431
+ },
432
+ type: 'value',
433
+ },
434
+ "$['page']['sections'][2]['product']['slug']": {
435
+ source: {
436
+ document: 1,
437
+ path: 15,
438
+ type: 'documentValue',
439
+ },
440
+ type: 'value',
441
+ },
442
+ "$['page']['sections'][2]['product']['title']": {
443
+ source: {
444
+ document: 1,
445
+ path: 2,
446
+ type: 'documentValue',
447
+ },
448
+ type: 'value',
449
+ },
450
+ "$['page']['sections'][2]['style']": {
451
+ source: {
452
+ document: 0,
453
+ path: 18,
454
+ type: 'documentValue',
455
+ },
456
+ type: 'value',
457
+ },
458
+ "$['page']['sections'][3]['_key']": {
459
+ source: {
460
+ document: 0,
461
+ path: 24,
462
+ type: 'documentValue',
463
+ },
464
+ type: 'value',
465
+ },
466
+ "$['page']['sections'][3]['_type']": {
467
+ source: {
468
+ document: 0,
469
+ path: 28,
470
+ type: 'documentValue',
471
+ },
472
+ type: 'value',
473
+ },
474
+ "$['page']['sections'][3]['headline']": {
475
+ source: {
476
+ document: 0,
477
+ path: 25,
478
+ type: 'documentValue',
479
+ },
480
+ type: 'value',
481
+ },
482
+ "$['page']['sections'][3]['products'][0]['_id']": {
483
+ source: {
484
+ document: 2,
485
+ path: 1,
486
+ type: 'documentValue',
487
+ },
488
+ type: 'value',
489
+ },
490
+ "$['page']['sections'][3]['products'][0]['_key']": {
491
+ source: {
492
+ document: 2,
493
+ path: 1,
494
+ type: 'documentValue',
495
+ },
496
+ type: 'value',
497
+ },
498
+ "$['page']['sections'][3]['products'][0]['_type']": {
499
+ source: {
500
+ document: 2,
501
+ path: 0,
502
+ type: 'documentValue',
503
+ },
504
+ type: 'value',
505
+ },
506
+ "$['page']['sections'][3]['products'][0]['media']": {
507
+ source: {
508
+ document: 2,
509
+ path: 26,
510
+ type: 'documentValue',
511
+ },
512
+ type: 'value',
513
+ },
514
+ "$['page']['sections'][3]['products'][0]['slug']": {
515
+ source: {
516
+ document: 2,
517
+ path: 15,
518
+ type: 'documentValue',
519
+ },
520
+ type: 'value',
521
+ },
522
+ "$['page']['sections'][3]['products'][0]['title']": {
523
+ source: {
524
+ document: 2,
525
+ path: 2,
526
+ type: 'documentValue',
527
+ },
528
+ type: 'value',
529
+ },
530
+ "$['page']['sections'][3]['products'][1]['_id']": {
531
+ source: {
532
+ document: 1,
533
+ path: 1,
534
+ type: 'documentValue',
535
+ },
536
+ type: 'value',
537
+ },
538
+ "$['page']['sections'][3]['products'][1]['_key']": {
539
+ source: {
540
+ document: 1,
541
+ path: 1,
542
+ type: 'documentValue',
543
+ },
544
+ type: 'value',
545
+ },
546
+ "$['page']['sections'][3]['products'][1]['_type']": {
547
+ source: {
548
+ document: 1,
549
+ path: 0,
550
+ type: 'documentValue',
551
+ },
552
+ type: 'value',
553
+ },
554
+ "$['page']['sections'][3]['products'][1]['media']": {
555
+ source: {
556
+ document: 1,
557
+ path: 16,
558
+ type: 'documentValue',
559
+ },
560
+ type: 'value',
561
+ },
562
+ "$['page']['sections'][3]['products'][1]['slug']": {
563
+ source: {
564
+ document: 1,
565
+ path: 15,
566
+ type: 'documentValue',
567
+ },
568
+ type: 'value',
569
+ },
570
+ "$['page']['sections'][3]['products'][1]['title']": {
571
+ source: {
572
+ document: 1,
573
+ path: 2,
574
+ type: 'documentValue',
575
+ },
576
+ type: 'value',
577
+ },
578
+ "$['page']['sections'][3]['products'][2]['_id']": {
579
+ source: {
580
+ document: 3,
581
+ path: 1,
582
+ type: 'documentValue',
583
+ },
584
+ type: 'value',
585
+ },
586
+ "$['page']['sections'][3]['products'][2]['_key']": {
587
+ source: {
588
+ document: 3,
589
+ path: 1,
590
+ type: 'documentValue',
591
+ },
592
+ type: 'value',
593
+ },
594
+ "$['page']['sections'][3]['products'][2]['_type']": {
595
+ source: {
596
+ document: 3,
597
+ path: 0,
598
+ type: 'documentValue',
599
+ },
600
+ type: 'value',
601
+ },
602
+ "$['page']['sections'][3]['products'][2]['media']": {
603
+ source: {
604
+ document: 3,
605
+ path: 27,
606
+ type: 'documentValue',
607
+ },
608
+ type: 'value',
609
+ },
610
+ "$['page']['sections'][3]['products'][2]['slug']": {
611
+ source: {
612
+ document: 3,
613
+ path: 15,
614
+ type: 'documentValue',
615
+ },
616
+ type: 'value',
617
+ },
618
+ "$['page']['sections'][3]['products'][2]['title']": {
619
+ source: {
620
+ document: 3,
621
+ path: 2,
622
+ type: 'documentValue',
623
+ },
624
+ type: 'value',
625
+ },
626
+ "$['page']['sections'][3]['style']": {
627
+ source: {
628
+ document: 0,
629
+ path: 29,
630
+ type: 'documentValue',
631
+ },
632
+ type: 'value',
633
+ },
634
+ "$['page']['sections'][4]['_key']": {
635
+ source: {
636
+ document: 0,
637
+ path: 32,
638
+ type: 'documentValue',
639
+ },
640
+ type: 'value',
641
+ },
642
+ "$['page']['sections'][4]['_type']": {
643
+ source: {
644
+ document: 0,
645
+ path: 30,
646
+ type: 'documentValue',
647
+ },
648
+ type: 'value',
649
+ },
650
+ "$['page']['sections'][4]['description']": {
651
+ source: {
652
+ document: 0,
653
+ path: 31,
654
+ type: 'documentValue',
655
+ },
656
+ type: 'value',
657
+ },
658
+ "$['page']['sections'][4]['headline']": {
659
+ source: {
660
+ document: 0,
661
+ path: 34,
662
+ type: 'documentValue',
663
+ },
664
+ type: 'value',
665
+ },
666
+ "$['page']['sections'][4]['image']": {
667
+ source: {
668
+ document: 0,
669
+ path: 33,
670
+ type: 'documentValue',
671
+ },
672
+ type: 'value',
673
+ },
674
+ "$['page']['sections'][4]['style']": {
675
+ source: {
676
+ document: 0,
677
+ path: 35,
678
+ type: 'documentValue',
679
+ },
680
+ type: 'value',
681
+ },
682
+ "$['page']['title']": {
683
+ source: {
684
+ document: 0,
685
+ path: 2,
686
+ type: 'documentValue',
687
+ },
688
+ type: 'value',
689
+ },
690
+ "$['siteSettings']['copyrightText']": {
691
+ source: {
692
+ document: 4,
693
+ path: 36,
694
+ type: 'documentValue',
695
+ },
696
+ type: 'value',
697
+ },
698
+ "$['siteSettings']['title']": {
699
+ source: {
700
+ document: 4,
701
+ path: 2,
702
+ type: 'documentValue',
703
+ },
704
+ type: 'value',
705
+ },
706
+ },
707
+ } satisfies ContentSourceMap
708
+ // In this draft the headline "Touch of Texture 1" is changed
709
+ const draft = {
710
+ _createdAt: '2023-06-27T14:35:36Z',
711
+ _id: 'drafts.home',
712
+ _rev: '3b8d3273-43ec-471c-9629-1ab5e0e894fa',
713
+ _type: 'page',
714
+ _updatedAt: '2023-10-26T13:22:12.692Z',
715
+ sections: [
716
+ {
717
+ _key: '44540ccd70c3',
718
+ _type: 'hero',
719
+ headline: 'Touch of Texture 1',
720
+ style: {
721
+ _type: 'sectionStyle',
722
+ variant: 'default',
723
+ },
724
+ subline: 'You can follow us on Twitter, Twitch, LinkedIn, and GitHub.',
725
+ tagline: 'ACME’s elegant construction is both minimal and inviting.',
726
+ },
727
+ {
728
+ _key: '50692538e3551f1805206202c8838ea5',
729
+ _type: 'hero',
730
+ headline: 'Duplicate',
731
+ style: {
732
+ _type: 'sectionStyle',
733
+ variant: 'default',
734
+ },
735
+ subline: 'You can follow us on Twitter, Twitch, LinkedIn, and GitHub..',
736
+ tagline: 'ACME’s elegant construction is both minimal and inviting.',
737
+ },
738
+ {
739
+ _key: '6b875593a9e1',
740
+ _type: 'featureHighlight',
741
+ ctas: [
742
+ {
743
+ _key: '53685454c2c9',
744
+ _type: 'cta',
745
+ href: '/highline',
746
+ title: 'Explore highline',
747
+ },
748
+ ],
749
+ description:
750
+ 'ACME partnered with industrial designer Jonas Damon to create Highline, an adaptable, easy-to-install system that marries the flexibility of a linear fixture with the thoughtful design of a pendant.',
751
+ headline: 'Highlines',
752
+ image: {
753
+ _type: 'image',
754
+ asset: {
755
+ _ref: 'image-9d18bc376926c8e0b27a71adf95002d64ef65684-2200x2500-jpg',
756
+ _type: 'reference',
757
+ },
758
+ },
759
+ product: {
760
+ _ref: '462efcc6-3c8b-47c6-8474-5544e1a4acde',
761
+ _type: 'reference',
762
+ },
763
+ style: {
764
+ _type: 'sectionStyle',
765
+ variant: 'default',
766
+ },
767
+ },
768
+ {
769
+ _key: 'e77f7c827ba4',
770
+ _type: 'featuredProducts',
771
+ headline: 'Some Featured Products Here',
772
+ products: [
773
+ {
774
+ _key: '2152e6edd551',
775
+ _ref: 'e1bf9f1f-efdb-4105-8c26-6b64f897e9c1',
776
+ _type: 'reference',
777
+ },
778
+ {
779
+ _key: 'e4e0ade0a4a8',
780
+ _ref: '462efcc6-3c8b-47c6-8474-5544e1a4acde',
781
+ _type: 'reference',
782
+ },
783
+ {
784
+ _key: '5bdb67c793ae',
785
+ _ref: '807cc05c-8c4c-443a-a9c1-198fd3fd7b16',
786
+ _type: 'reference',
787
+ },
788
+ ],
789
+ style: {
790
+ _type: 'sectionStyle',
791
+ variant: 'default',
792
+ },
793
+ },
794
+ {
795
+ _key: '0bd049fc047a',
796
+ _type: 'featureHighlight',
797
+ description: 'Lalala',
798
+ headline: 'Look at the person walking on this dune!',
799
+ image: {
800
+ _type: 'image',
801
+ asset: {
802
+ _ref: 'image-97bdac62b5809e77b80831823de7e8ff8cd20b43-8640x5760-jpg',
803
+ _type: 'reference',
804
+ },
805
+ },
806
+ style: {
807
+ _type: 'sectionStyle',
808
+ variant: 'default',
809
+ },
810
+ },
811
+ ],
812
+ title: 'Home',
813
+ }
814
+
815
+ const optimisticResult = applySourceDocuments(result, resultSourceMap, (sourceDocument) =>
816
+ sourceDocument._id === draft._id ? draft : undefined,
817
+ )
818
+ expect(result.page.sections[0].headline).not.toBe(draft.sections[0].headline)
819
+ expect(optimisticResult.page.sections[0].headline).toBe(draft.sections[0].headline)
820
+ })