forked from TryGhost/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-generator.js
2023 lines (1895 loc) · 96.2 KB
/
data-generator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const _ = require('lodash');
const uuid = require('uuid');
const ObjectId = require('bson-objectid').default;
const moment = require('moment');
const constants = require('@tryghost/constants');
const DataGenerator = {};
DataGenerator.markdownToMobiledoc = function markdownToMobiledoc(content) {
const mobiledoc = {
version: '0.3.1',
markups: [],
atoms: [],
cards: [
['markdown', {
markdown: content || ''
}]
],
sections: [[10, 0]]
};
return JSON.stringify(mobiledoc);
};
DataGenerator.Content = {
posts: [
{
id: '618ba1ffbe2896088840a6df',
title: 'HTML Ipsum',
slug: 'html-ipsum',
mobiledoc: DataGenerator.markdownToMobiledoc('<h1>HTML Ipsum Presents</h1><p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p><h2>Header Level 2</h2><ol><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ol><blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote><h3>Header Level 3</h3><ul><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ul><pre><code>#header h1 a{display: block;width: 300px;height: 80px;}</code></pre>'),
published_at: new Date('2015-01-01'),
custom_excerpt: 'This is my custom excerpt!',
feature_image: 'https://example.com/super_photo.jpg'
},
{
id: '618ba1ffbe2896088840a6e1',
title: 'Ghostly Kitchen Sink',
slug: 'ghostly-kitchen-sink',
mobiledoc: DataGenerator.markdownToMobiledoc('<h1>HTML Ipsum Presents</h1><img src="__GHOST_URL__/content/images/lol.jpg"><p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p><h2>Header Level 2</h2><ol><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ol><blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote><h3>Header Level 3</h3><ul><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ul><pre><code>#header h1 a{display: block;width: 300px;height: 80px;}</code></pre>'),
published_at: new Date('2015-01-02'),
feature_image: '__GHOST_URL__/content/images/2018/hey.jpg'
},
{
id: '618ba1ffbe2896088840a6e3',
title: 'Short and Sweet',
slug: 'short-and-sweet',
mobiledoc: DataGenerator.markdownToMobiledoc('## testing\n\nmctesters\n\n- test\n- line\n- items'),
html: '<!--kg-card-begin: markdown--><h2 id=\"testing\">testing</h2>\n<p>mctesters</p>\n<ul>\n<li>test</li>\n<li>line</li>\n<li>items</li>\n</ul>\n<!--kg-card-end: markdown-->',
plaintext: 'testing\nmctesters\n\n * test\n * line\n * items',
feature_image: 'http://placekitten.com/500/200',
published_at: new Date('2015-01-03'),
featured: true,
uuid: '2ac6b4f6-e1f3-406c-9247-c94a0496d39d'
},
{
id: '618ba1ffbe2896088840a6e5',
title: 'Not finished yet',
slug: 'unfinished',
mobiledoc: DataGenerator.markdownToMobiledoc('<h1>HTML Ipsum Presents</h1><p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p><h2>Header Level 2</h2><ol><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ol><blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote><h3>Header Level 3</h3><ul><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ul><pre><code>#header h1 a{display: block;width: 300px;height: 80px;}</code></pre>'),
status: 'draft',
uuid: 'd52c42ae-2755-455c-80ec-70b2ec55c903'
},
{
id: '618ba1ffbe2896088840a6e7',
title: 'Not so short, bit complex',
slug: 'not-so-short-bit-complex',
// NOTE: this has some invalid HTML, has a missing `</p>` after `</nav>`
mobiledoc: DataGenerator.markdownToMobiledoc('<p><nav><ul><li><a href=\"#nowhere\" title=\"Anchor URL\">Lorem</a></li><li><a href=\"__GHOST_URL__/about#nowhere\" title=\"Relative URL\">Aliquam</a></li><li><a href=\"//somewhere.com/link#nowhere\" title=\"Protocol Relative URL\">Tortor</a></li><li><a href=\"http://somewhere.com/link#nowhere\" title=\"Absolute URL\">Morbi</a></li><li><a href=\"#nowhere\" title=\"Praesent dapibus, neque id cursus faucibus\">Praesent</a></li><li><a href=\"#nowhere\" title=\"Pellentesque fermentum dolor\">Pellentesque</a></li></ul></nav><p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p><table><thead><tr><th>1</th><th>2</th><th>3</th><th>4</th></tr></thead><tbody><tr><td>a</td><td>b</td><td>c</td><td>d</td></tr><tr><td>e</td><td>f</td><td>g</td><td>h</td></tr><tr><td>i</td><td>j</td><td>k</td><td>l</td></tr></tbody></table><dl><dt>Definition list</dt><dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd><dt>Lorem ipsum dolor sit amet</dt><dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd></dl><ul><li>Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.</li><li>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.</li><li>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</li><li>Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.</li></ul></p>'),
published_at: new Date('2015-01-04'),
featured: true
},
{
id: '618ba1ffbe2896088840a6e9',
title: 'This is a static page',
slug: 'static-page-test',
mobiledoc: DataGenerator.markdownToMobiledoc('<h1>Static page test is what this is for.</h1><p>Hopefully you don\'t find it a bore.</p>'),
type: 'page'
},
{
id: '618ba1ffbe2896088840a6eb',
title: 'This is a draft static page',
slug: 'static-page-draft',
mobiledoc: DataGenerator.markdownToMobiledoc('<h1>Static page test is what this is for.</h1><p>Hopefully you don\'t find it a bore.</p>'),
type: 'page',
status: 'draft',
uuid: 'd52c42ae-2755-455c-80ec-70b2ec55c904'
},
{
id: '618ba1ffbe2896088840a6ed',
title: 'This is a scheduled post!!',
slug: 'scheduled-post',
mobiledoc: DataGenerator.markdownToMobiledoc('<h1>Welcome to my invisible post!</h1>'),
status: 'scheduled',
published_at: moment().add(2, 'days').toDate()
}
],
tags: [
{
id: '618ba1febe2896088840a6db',
name: 'kitchen sink',
slug: 'kitchen-sink',
feature_image: 'https://example.com/super_photo.jpg'
},
{
id: '9451f5fca366002ebd5dbea6',
name: 'bacon',
slug: 'bacon'
},
{
id: '618ba1fdbe2896088840a675',
name: 'chorizo',
slug: 'chorizo'
},
{
id: '6193c6d5e792de832cd08148',
name: 'pollo',
slug: 'pollo'
},
{
id: '6193c6dfe792de832cd08149',
name: 'injection',
slug: 'injection'
}
],
// Password = Sl1m3rson99
users: [
{
// owner (owner is still id 1 because of permissions)
id: '1',
name: 'Joe Bloggs',
slug: 'joe-bloggs',
email: 'jbloggs@example.com',
password: 'Sl1m3rson99',
profile_image: 'https://example.com/super_photo.jpg'
},
{
// admin
id: '6193c65ee792de832cd08130',
name: 'Smith Wellingsworth',
slug: 'smith-wellingsworth',
email: 'swellingsworth@example.com',
password: 'Sl1m3rson99'
},
{
// editor
id: '6193c672e792de832cd0813c',
name: 'Jimothy Bogendath',
slug: 'jimothy-bogendath',
email: 'jbOgendAth@example.com',
password: 'Sl1m3rson99'
},
{
// author
id: '6193c685e792de832cd08141',
name: 'Slimer McEctoplasm',
slug: 'slimer-mcectoplasm',
email: 'smcectoplasm@example.com',
password: 'Sl1m3rson99'
},
{
// editor 2
id: '6193c693e792de832cd08142',
name: 'Ivan Email',
slug: 'ivan-email',
email: 'info1@ghost.org',
password: 'Sl1m3rson99'
},
{
// author 2
id: '6193c6a1e792de832cd08143',
name: 'Author2',
slug: 'a-2',
email: 'info2@ghost.org',
password: 'Sl1m3rson99'
},
{
// admin 2
id: '6193c6abe792de832cd08144',
name: 'admin2',
slug: 'ad-2',
email: 'info3@ghost.org',
password: 'Sl1m3rson99'
},
{
// contributor
id: '6193c6bae792de832cd08146',
name: 'Contributor',
slug: 'contributor',
email: 'contributor@ghost.org',
password: 'Sl1m3rson99'
},
{
// contributor
id: '6193c6c5e792de832cd08147',
name: 'contributor2',
slug: 'contrib-2',
email: 'contributor2@ghost.org',
password: 'Sl1m3rson99'
}
],
permissions: [
{
id: ObjectId().toHexString(),
name: 'Browse posts',
action_type: 'browse',
object_type: 'post'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'edit',
object_type: 'post'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'edit',
object_type: 'tag'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'edit',
object_type: 'user'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'edit',
object_type: 'page'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'add',
object_type: 'post'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'add',
object_type: 'user'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'add',
object_type: 'page'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'destroy',
object_type: 'post'
},
{
id: ObjectId().toHexString(),
name: 'test',
action_type: 'destroy',
object_type: 'user'
}
],
roles: [
{
id: ObjectId().toHexString(),
name: 'Administrator',
description: 'Administrators'
},
{
id: ObjectId().toHexString(),
name: 'Editor',
description: 'Editors'
},
{
id: ObjectId().toHexString(),
name: 'Author',
description: 'Authors'
},
{
id: ObjectId().toHexString(),
name: 'Owner',
description: 'Blog Owner'
},
{
id: ObjectId().toHexString(),
name: 'Contributor',
description: 'Contributors'
},
{
id: ObjectId().toHexString(),
name: 'Admin Integration',
description: 'External Apps'
}
],
members: [
{
id: ObjectId().toHexString(),
email: 'member1@test.com',
name: 'Mr Egg',
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b340',
status: 'free',
email_disabled: false
},
{
id: ObjectId().toHexString(),
email: 'member2@test.com',
email_open_rate: 50,
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b341',
status: 'free',
email_disabled: false
},
{
id: ObjectId().toHexString(),
email: 'paid@test.com',
name: 'Egon Spengler',
email_open_rate: 80,
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b342',
status: 'paid',
email_disabled: false
},
{
id: ObjectId().toHexString(),
email: 'trialing@test.com',
name: 'Ray Stantz',
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b343',
status: 'paid',
email_disabled: false
},
{
id: ObjectId().toHexString(),
email: 'comped@test.com',
name: 'Vinz Clortho',
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b344',
status: 'paid',
email_disabled: false
},
{
id: ObjectId().toHexString(),
email: 'vip@test.com',
name: 'Winston Zeddemore',
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b345',
status: 'free',
email_disabled: false
},
{
id: ObjectId().toHexString(),
email: 'vip-paid@test.com',
name: 'Peter Venkman',
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b346',
status: 'paid',
subscribed: false,
email_disabled: false
},
{
id: ObjectId().toHexString(),
email: 'with-product@test.com',
name: 'Dana Barrett',
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b347',
status: 'paid',
subscribed: false,
email_disabled: false
}
],
newsletters: [
{
id: ObjectId().toHexString(),
name: 'Daily newsletter',
slug: 'daily-newsletter',
description: '',
sender_name: 'Jamie',
sender_email: 'jamie@example.com',
sender_reply_to: 'newsletter',
status: 'active',
subscribe_on_signup: false,
title_font_category: 'serif',
body_font_category: 'serif',
show_header_icon: true,
show_header_title: true,
show_badge: true,
sort_order: 1,
header_image: '__GHOST_URL__/content/images/2022/05/test.jpg'
},
{
id: ObjectId().toHexString(),
name: 'Weekly newsletter',
slug: 'weekly-newsletter',
description: '',
sender_name: 'Jamie',
sender_email: 'jamie@example.com',
sender_reply_to: 'newsletter',
status: 'active',
subscribe_on_signup: true,
title_font_category: 'serif',
body_font_category: 'serif',
show_header_icon: true,
show_header_title: true,
show_badge: true,
sort_order: 2,
header_image: '__GHOST_URL__/content/images/2022/05/test.jpg'
},
{
id: ObjectId().toHexString(),
name: 'Old newsletter',
slug: 'old-newsletter',
description: '',
sender_name: 'Jamie',
sender_email: 'jamie@example.com',
sender_reply_to: 'newsletter',
status: 'archived',
subscribe_on_signup: true,
title_font_category: 'serif',
body_font_category: 'serif',
show_header_icon: true,
show_header_title: true,
show_badge: true,
sort_order: 2,
header_image: '__GHOST_URL__/content/images/2022/05/test.jpg'
}
],
products: [
{
// No ID because these are in the core fixtures.json
slug: 'free',
// slug is to match the product, the below are updated for the product
welcome_page_url: '/welcome-free',
currency: null,
monthly_price: null,
yearly_price: null
},
{
// No ID because these are in the core fixtures.json
slug: 'default-product',
// slug is to match the product, the below are updated for the product
welcome_page_url: '/welcome-paid',
currency: 'usd',
monthly_price: 500,
yearly_price: 5000
}
],
labels: [
{
id: ObjectId().toHexString(),
name: 'Label 1',
slug: 'label-1'
},
{
id: ObjectId().toHexString(),
name: 'Label 2',
slug: 'label-2'
},
{
id: ObjectId().toHexString(),
name: 'VIP',
slug: 'vip'
}
],
members_stripe_customers: [
{
id: ObjectId().toHexString(),
member_id: null, // relation added later
customer_id: 'cus_HR3tBmNhx4QsZY',
name: 'Egon Spengler',
email: 'paid@test.com'
},
{
id: ObjectId().toHexString(),
member_id: null, // relation added later
customer_id: 'cus_HR3tBmNhx4QsZZ',
name: 'Ray Stantz',
email: 'trialing@test.com'
},
{
id: ObjectId().toHexString(),
member_id: null, // relation added later
customer_id: 'cus_HR3tBmNhx4QsZ0',
name: 'Vinz Clortho',
email: 'comped@test.com'
},
{
id: ObjectId().toHexString(),
member_id: null, // relation added later
customer_id: 'cus_HR3tBmNhx4QsZ1',
name: 'Peter Venkman',
email: 'vip-paid@test.com'
},
{
id: ObjectId().toHexString(),
member_id: null, // relation added later
customer_id: 'cus_HR3tBmNhx4QsZ2',
name: 'Dana Barrett',
email: 'with-product@test.com'
}
],
members_paid_subscription_events: [
{
id: ObjectId().toHexString(),
type: 'created',
mrr_delta: 1000,
currency: 'usd',
source: 'stripe',
created_at: null,
subscription_id: null,
member_id: null,
from_plan: null,
to_plan: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730bb8'
}, {
id: ObjectId().toHexString(),
type: 'created',
mrr_delta: 0,
currency: 'usd',
source: 'stripe',
created_at: null,
subscription_id: null,
member_id: null,
from_plan: null,
to_plan: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730bb9'
}, {
id: ObjectId().toHexString(),
type: 'created',
mrr_delta: 0,
currency: 'usd',
source: 'stripe',
created_at: null,
subscription_id: null,
member_id: null,
from_plan: null,
to_plan: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730ba0'
}
],
members_stripe_customers_subscriptions: [
{
id: ObjectId().toHexString(),
customer_id: 'cus_HR3tBmNhx4QsZY',
subscription_id: 'sub_HR3tLNgGAHsa7b',
plan_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730bb8',
stripe_price_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730bb8',
status: 'active',
cancel_at_period_end: false,
current_period_end: '2020-07-09 19:01:20',
start_date: '2020-06-09 19:01:20',
default_payment_card_last4: '4242',
plan_nickname: 'Monthly',
plan_interval: 'month',
plan_amount: '1000',
plan_currency: 'usd',
mrr: 1000
},
{
id: ObjectId().toHexString(),
customer_id: 'cus_HR3tBmNhx4QsZZ',
subscription_id: 'sub_HR3tLNgGAHsa7c',
plan_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730bb9',
stripe_price_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730bb9',
status: 'trialing',
cancel_at_period_end: true,
current_period_end: '2025-07-09 19:01:20',
start_date: '2020-06-09 19:01:20',
default_payment_card_last4: '4242',
plan_nickname: 'Monthly',
plan_interval: 'month',
plan_amount: '1000',
plan_currency: 'usd',
mrr: 0
},
{
id: ObjectId().toHexString(),
customer_id: 'cus_HR3tBmNhx4QsZ0',
subscription_id: 'sub_HR3tLNgGAHsa7d',
plan_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730ba0',
stripe_price_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730ba0',
status: 'active',
cancel_at_period_end: true,
current_period_end: '2025-07-09 19:01:20',
start_date: '2020-06-09 19:01:20',
default_payment_card_last4: '4242',
plan_nickname: 'Complimentary',
plan_interval: 'year',
plan_amount: '0',
plan_currency: 'usd',
mrr: 0
}
],
stripe_prices: [
{
id: ObjectId().toHexString(),
stripe_price_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730b12',
stripe_product_id: '109c85c734fb9992e7bc30a26af66c22f5c94d8dc62e0a33cb797be902c06b2d',
active: true,
nickname: 'Monthly',
currency: 'USD',
amount: 500,
type: 'recurring',
interval: 'month'
},
{
id: ObjectId().toHexString(),
stripe_price_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730bb8',
stripe_product_id: '109c85c734fb9992e7bc30a26af66c22f5c94d8dc62e0a33cb797be902c06b2d',
active: true,
nickname: 'Monthly',
currency: 'GBP',
amount: 1200,
type: 'recurring',
interval: 'month'
},
{
id: ObjectId().toHexString(),
stripe_price_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730ba0',
stripe_product_id: '109c85c734fb9992e7bc30a26af66c22f5c94d8dc62e0a33cb797be902c06b2d',
active: true,
nickname: 'Yearly',
currency: 'GBP',
amount: 12000,
type: 'recurring',
interval: 'year'
},
{
id: ObjectId().toHexString(),
stripe_price_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730bb9',
stripe_product_id: '109c85c734fb9992e7bc30a26af66c22f5c94d8dc62e0a33cb797be902c06b2d',
active: true,
nickname: 'Yearly',
currency: 'GBP',
amount: 15000,
type: 'recurring',
interval: 'year'
},
{
id: ObjectId().toHexString(),
stripe_price_id: '173e16a1fffa7d232b398e4a9b08d266a456ae8f3d23e5f11cc608ced6730b13',
stripe_product_id: '109c85c734fb9992e7bc30a26af66c22f5c94d8dc62e0a33cb797be902c06b2d',
active: true,
nickname: 'Yearly',
currency: 'USD',
amount: 5000,
type: 'recurring',
interval: 'year'
}
],
stripe_products: [
{
id: ObjectId().toHexString(),
product_id: '',
stripe_product_id: '109c85c734fb9992e7bc30a26af66c22f5c94d8dc62e0a33cb797be902c06b2d'
}
],
webhooks: [
{
id: ObjectId().toHexString(),
event: 'member.added',
target_url: 'https://example.com/webhooks/subscriber-added'
},
{
id: ObjectId().toHexString(),
event: 'member.removed',
target_url: 'https://example.com/webhooks/subscriber-removed'
}
],
integrations: [
{
id: ObjectId().toHexString(),
name: 'Test Integration',
slug: 'test-integration'
},
{
id: ObjectId().toHexString(),
name: 'Test Internal Integration',
slug: 'test-internal-integration',
type: 'internal'
},
{
id: ObjectId().toHexString(),
name: 'Test Builtin Integration',
slug: 'test-builtin-integration',
type: 'builtin'
},
{
id: ObjectId().toHexString(),
name: 'Test Core Integration',
slug: 'test-core-integration',
type: 'core'
}
],
api_keys: [
{
id: ObjectId().toHexString(),
type: 'admin',
secret: _.repeat('a', 64)
// integration_id: DataGenerator.Content.integrations[0].id
},
{
id: ObjectId().toHexString(),
type: 'content',
secret: _.repeat('c', 26)
// integration_id: DataGenerator.Content.integrations[0].id
},
{
id: ObjectId().toHexString(),
type: 'admin',
secret: _.repeat('b', 64),
integration_id: undefined // "internal"
},
{
id: ObjectId().toHexString(),
type: 'admin',
secret: _.repeat('d', 26),
integration_id: undefined // "builtin"
},
{
id: ObjectId().toHexString(),
type: 'admin',
secret: _.repeat('e', 64),
integration_id: undefined // "core"
}
],
emails: [
{
id: ObjectId().toHexString(),
uuid: '6b6afda6-4b5e-4893-bff6-f16859e8349a',
status: 'submitted',
email_count: 6, // match the number of email_recipients relations below
recipient_filter: 'all',
subject: 'You got mailed!',
html: '<p>Look! I\'m an email</p>',
plaintext: 'Waba-daba-dab-da',
track_opens: false,
submitted_at: moment().toDate(),
newsletter_id: null // newsletter[0] relation added later
},
{
id: ObjectId().toHexString(),
uuid: '365daa11-4bf0-4614-ad43-6346387ffa00',
status: 'failed',
error: 'Everything went south',
email_count: 3, // doesn't match the number of email_recipients relations below, some calculations may be off
subject: 'You got mailed! Again!',
html: '<p>What\'s that? Another email!</p>',
plaintext: 'yes this is an email',
track_opens: false,
submitted_at: moment().toDate(),
newsletter_id: null // newsletter[1] relation added later
}
],
email_batches: [
{
id: ObjectId().toHexString(),
email_id: null, // emails[0] relation added later
provider_id: 'email1@testing.mailgun.net',
status: 'submitted'
}
],
email_recipients: [
{
id: ObjectId().toHexString(),
email_id: null, // emails[0] relation added later
member_id: null, // members[0] relation added later
batch_id: null, // email_batches[0] relation added later
processed_at: moment().toDate(),
failed_at: null,
delivered_at: null,
member_uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b340',
member_email: null, // members[1] relation added later
member_name: 'Mr Egg'
},
{
id: ObjectId().toHexString(),
email_id: null, // emails[0] relation added later
member_id: null, // members[1] relation added later
batch_id: null, // email_batches[0] relation added later
processed_at: moment().toDate(),
failed_at: null,
delivered_at: null,
member_uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b341',
member_email: null, // members[2] relation added later
member_name: null
},
{
id: ObjectId().toHexString(),
email_id: null, // emails[0] relation added later
member_id: null, // members[2] relation added later
batch_id: null, // email_batches[0] relation added later
processed_at: moment().toDate(),
failed_at: null,
delivered_at: null,
member_uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b342',
member_email: null, // members[3] relation added later
member_name: 'Mr Egg'
},
{
id: ObjectId().toHexString(),
email_id: null, // emails[0] relation added later
member_id: null, // members[3] relation added later
batch_id: null, // email_batches[0] relation added later
processed_at: moment().toDate(),
failed_at: null,
delivered_at: null,
member_uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b343',
member_email: null, // members[4] relation added later
member_name: 'Mr Egg'
},
{
id: ObjectId().toHexString(),
email_id: null, // emails[0] relation added later
member_id: null, // members[4] relation added later
batch_id: null, // email_batches[0] relation added later
processed_at: moment().toDate(),
delivered_at: moment().toDate(),
opened_at: moment().toDate(),
failed_at: null,
member_uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b344',
member_email: null, // members[5] relation added later
member_name: 'Mr Egg'
},
{
id: ObjectId().toHexString(),
email_id: null, // emails[0] relation added later
member_id: null, // members[5] relation added later
batch_id: null, // email_batches[0] relation added later
processed_at: moment().toDate(),
delivered_at: null,
opened_at: null,
failed_at: moment().toDate(),
member_uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b344',
member_email: null, // members[6] relation added later
member_name: 'Mr Egg'
}
],
snippets: [
{
id: ObjectId().toHexString(),
name: 'Test snippet 1',
mobiledoc: '{}'
}
],
custom_theme_settings: [
{
id: ObjectId().toHexString(),
theme: 'casper',
key: 'header_typography',
type: 'select',
value: 'Serif'
},
{
id: ObjectId().toHexString(),
theme: 'casper',
key: 'footer_type',
type: 'select',
value: 'Full'
}
],
comments: [
{
id: '6195c6a1e792de832cd08144',
html: '<p>First.</p>',
member_index: 0
},
{
id: '6195c6a1e792de832cd08145',
html: '<p>Really original</p>',
parent_id: '6195c6a1e792de832cd08144',
member_index: 1
}
],
links: [
{
id: ObjectId().toHexString(),
from: '/r/70b0129a',
to: '__GHOST_URL__/blog/email/01cd4df3-83fa-4921-83be-3bb9a465ef83/?ref=Test-newsletter&attribution_id=6343994e7216ffcbce491716&attribution_type=post',
created_at: null,
updated_at: null
},
{
id: ObjectId().toHexString(),
from: '/r/a0b0129a',
to: '__GHOST_URL__/blog/email/01cd4df3-83fa-4921-83be-3bb9a465ef83/?ref=Test-newsletter&attribution_id=6343994e7216ffcbce491716&attribution_type=post',
created_at: null,
updated_at: null
},
{
id: ObjectId().toHexString(),
from: '/r/20b0129a',
to: 'https://example.com/subscripe?ref=Test-newsletter',
created_at: null,
updated_at: null
}
],
// TODO: build mentions for testing browse endpoint
mentions: [
// source: webmention.source,
// target: webmention.target,
// timestamp: new Date(),
// payload: webmention.payload,
// resourceId: resourceInfo.type === 'post' ? resourceInfo.id : null,
// sourceTitle: metadata.title,
// sourceSiteTitle: metadata.siteTitle,
// sourceAuthor: metadata.author,
// sourceExcerpt: metadata.excerpt,
// sourceFavicon: metadata.favicon,
// sourceFeaturedImage: metadata.image
{
id: ObjectId().toHexString(),
source: 'https://source.com',
target: 'https://target.com',
sourceTitle: 'Title!',
sourceExcerpt: 'Excerpt!'
},
{
id: ObjectId().toHexString(),
source: 'https://anothersource.com',
target: 'https://anothertarget.com',
sourceTitle: 'Another Title!',
sourceExcerpt: 'Another Excerpt!'
},
{
id: ObjectId().toHexString(),
source: 'https://src.com',
target: 'https://target.com',
sourceTitle: 'Title goes here',
sourceExcerpt: 'Excerpt goes here'
}
]
};
// set up belongs_to relationships
DataGenerator.Content.api_keys[0].integration_id = DataGenerator.Content.integrations[0].id;
DataGenerator.Content.api_keys[1].integration_id = DataGenerator.Content.integrations[0].id;
DataGenerator.Content.api_keys[3].integration_id = DataGenerator.Content.integrations[2].id;
DataGenerator.Content.api_keys[4].integration_id = DataGenerator.Content.integrations[3].id;
DataGenerator.Content.webhooks[0].integration_id = DataGenerator.Content.integrations[0].id;
DataGenerator.Content.webhooks[1].integration_id = DataGenerator.Content.integrations[0].id;
DataGenerator.Content.emails[0].post_id = DataGenerator.Content.posts[0].id;
DataGenerator.Content.emails[1].post_id = DataGenerator.Content.posts[1].id;
DataGenerator.Content.email_batches[0].email_id = DataGenerator.Content.emails[0].id;
DataGenerator.Content.email_recipients[0].batch_id = DataGenerator.Content.email_batches[0].id;
DataGenerator.Content.email_recipients[0].email_id = DataGenerator.Content.email_batches[0].email_id;
DataGenerator.Content.email_recipients[0].member_id = DataGenerator.Content.members[0].id;
DataGenerator.Content.email_recipients[0].member_email = DataGenerator.Content.members[0].email;
DataGenerator.Content.email_recipients[1].batch_id = DataGenerator.Content.email_batches[0].id;
DataGenerator.Content.email_recipients[1].email_id = DataGenerator.Content.email_batches[0].email_id;
DataGenerator.Content.email_recipients[1].member_id = DataGenerator.Content.members[1].id;
DataGenerator.Content.email_recipients[1].member_email = DataGenerator.Content.members[1].email;
DataGenerator.Content.email_recipients[2].batch_id = DataGenerator.Content.email_batches[0].id;
DataGenerator.Content.email_recipients[2].email_id = DataGenerator.Content.email_batches[0].email_id;
DataGenerator.Content.email_recipients[2].member_id = DataGenerator.Content.members[2].id;
DataGenerator.Content.email_recipients[2].member_email = DataGenerator.Content.members[2].email;
DataGenerator.Content.email_recipients[3].batch_id = DataGenerator.Content.email_batches[0].id;
DataGenerator.Content.email_recipients[3].email_id = DataGenerator.Content.email_batches[0].email_id;
DataGenerator.Content.email_recipients[3].member_id = DataGenerator.Content.members[3].id;
DataGenerator.Content.email_recipients[3].member_email = DataGenerator.Content.members[3].email;
DataGenerator.Content.email_recipients[4].batch_id = DataGenerator.Content.email_batches[0].id;
DataGenerator.Content.email_recipients[4].email_id = DataGenerator.Content.email_batches[0].email_id;
DataGenerator.Content.email_recipients[4].member_id = DataGenerator.Content.members[4].id;
DataGenerator.Content.email_recipients[4].member_email = DataGenerator.Content.members[4].email;
DataGenerator.Content.email_recipients[5].batch_id = DataGenerator.Content.email_batches[0].id;
DataGenerator.Content.email_recipients[5].email_id = DataGenerator.Content.email_batches[0].email_id;
DataGenerator.Content.email_recipients[5].member_id = DataGenerator.Content.members[5].id;
DataGenerator.Content.email_recipients[5].member_email = DataGenerator.Content.members[5].email;
DataGenerator.Content.members_stripe_customers[0].member_id = DataGenerator.Content.members[2].id;
DataGenerator.Content.members_stripe_customers[1].member_id = DataGenerator.Content.members[3].id;
DataGenerator.Content.members_stripe_customers[2].member_id = DataGenerator.Content.members[4].id;
DataGenerator.Content.members_stripe_customers[3].member_id = DataGenerator.Content.members[6].id;
DataGenerator.Content.members_stripe_customers[4].member_id = DataGenerator.Content.members[7].id;
DataGenerator.Content.members_paid_subscription_events[0].member_id = DataGenerator.Content.members[2].id;
DataGenerator.Content.members_paid_subscription_events[1].member_id = DataGenerator.Content.members[3].id;
DataGenerator.Content.members_paid_subscription_events[2].member_id = DataGenerator.Content.members[4].id;
DataGenerator.Content.links[0].post_id = DataGenerator.Content.posts[0].id;
DataGenerator.Content.links[1].post_id = DataGenerator.Content.posts[0].id;
DataGenerator.Content.links[2].post_id = DataGenerator.Content.posts[0].id;
DataGenerator.forKnex = (function () {
function createBasic(overrides) {
const newObj = _.cloneDeep(overrides);
return _.defaults(newObj, {
id: ObjectId().toHexString(),
created_by: DataGenerator.Content.users[0].id,
created_at: new Date(),
updated_by: DataGenerator.Content.users[0].id,
updated_at: new Date()
});