@financial-times/content-curation-client 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.cts +31 -0
- package/dist/_tsup-dts-rollup.d.ts +31 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -492,6 +492,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
492
492
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
493
493
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
494
494
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
495
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
495
496
|
}, "strip", z.ZodTypeAny, {
|
|
496
497
|
title: string;
|
|
497
498
|
pageId: string;
|
|
@@ -501,6 +502,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
501
502
|
conceptId?: string | undefined;
|
|
502
503
|
metaDescription?: string | undefined;
|
|
503
504
|
pageTheme?: string | undefined;
|
|
505
|
+
pageCategory?: string | undefined;
|
|
504
506
|
}, {
|
|
505
507
|
title: string;
|
|
506
508
|
pageId: string;
|
|
@@ -510,6 +512,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
510
512
|
conceptId?: string | undefined;
|
|
511
513
|
metaDescription?: string | undefined;
|
|
512
514
|
pageTheme?: string | undefined;
|
|
515
|
+
pageCategory?: string | undefined;
|
|
513
516
|
}>;
|
|
514
517
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
515
518
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -1334,6 +1337,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1334
1337
|
conceptId?: string | undefined;
|
|
1335
1338
|
metaDescription?: string | undefined;
|
|
1336
1339
|
pageTheme?: string | undefined;
|
|
1340
|
+
pageCategory?: string | undefined;
|
|
1337
1341
|
};
|
|
1338
1342
|
children: ({
|
|
1339
1343
|
type: "Interactive";
|
|
@@ -1463,6 +1467,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1463
1467
|
conceptId?: string | undefined;
|
|
1464
1468
|
metaDescription?: string | undefined;
|
|
1465
1469
|
pageTheme?: string | undefined;
|
|
1470
|
+
pageCategory?: string | undefined;
|
|
1466
1471
|
};
|
|
1467
1472
|
children: ({
|
|
1468
1473
|
type: "Interactive";
|
|
@@ -1604,6 +1609,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1604
1609
|
conceptId?: string | undefined;
|
|
1605
1610
|
metaDescription?: string | undefined;
|
|
1606
1611
|
pageTheme?: string | undefined;
|
|
1612
|
+
pageCategory?: string | undefined;
|
|
1607
1613
|
};
|
|
1608
1614
|
children: ({
|
|
1609
1615
|
type: "Interactive";
|
|
@@ -1745,6 +1751,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1745
1751
|
conceptId?: string | undefined;
|
|
1746
1752
|
metaDescription?: string | undefined;
|
|
1747
1753
|
pageTheme?: string | undefined;
|
|
1754
|
+
pageCategory?: string | undefined;
|
|
1748
1755
|
};
|
|
1749
1756
|
children: ({
|
|
1750
1757
|
type: "Interactive";
|
|
@@ -2967,6 +2974,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
2967
2974
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
2968
2975
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
2969
2976
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
2977
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
2970
2978
|
}, "strip", z.ZodTypeAny, {
|
|
2971
2979
|
title: string;
|
|
2972
2980
|
pageId: string;
|
|
@@ -2976,6 +2984,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
2976
2984
|
conceptId?: string | undefined;
|
|
2977
2985
|
metaDescription?: string | undefined;
|
|
2978
2986
|
pageTheme?: string | undefined;
|
|
2987
|
+
pageCategory?: string | undefined;
|
|
2979
2988
|
}, {
|
|
2980
2989
|
title: string;
|
|
2981
2990
|
pageId: string;
|
|
@@ -2985,6 +2994,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
2985
2994
|
conceptId?: string | undefined;
|
|
2986
2995
|
metaDescription?: string | undefined;
|
|
2987
2996
|
pageTheme?: string | undefined;
|
|
2997
|
+
pageCategory?: string | undefined;
|
|
2988
2998
|
}>;
|
|
2989
2999
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
2990
3000
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -3809,6 +3819,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
3809
3819
|
conceptId?: string | undefined;
|
|
3810
3820
|
metaDescription?: string | undefined;
|
|
3811
3821
|
pageTheme?: string | undefined;
|
|
3822
|
+
pageCategory?: string | undefined;
|
|
3812
3823
|
};
|
|
3813
3824
|
children: ({
|
|
3814
3825
|
type: "Interactive";
|
|
@@ -3938,6 +3949,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
3938
3949
|
conceptId?: string | undefined;
|
|
3939
3950
|
metaDescription?: string | undefined;
|
|
3940
3951
|
pageTheme?: string | undefined;
|
|
3952
|
+
pageCategory?: string | undefined;
|
|
3941
3953
|
};
|
|
3942
3954
|
children: ({
|
|
3943
3955
|
type: "Interactive";
|
|
@@ -4079,6 +4091,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4079
4091
|
conceptId?: string | undefined;
|
|
4080
4092
|
metaDescription?: string | undefined;
|
|
4081
4093
|
pageTheme?: string | undefined;
|
|
4094
|
+
pageCategory?: string | undefined;
|
|
4082
4095
|
};
|
|
4083
4096
|
children: ({
|
|
4084
4097
|
type: "Interactive";
|
|
@@ -4220,6 +4233,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4220
4233
|
conceptId?: string | undefined;
|
|
4221
4234
|
metaDescription?: string | undefined;
|
|
4222
4235
|
pageTheme?: string | undefined;
|
|
4236
|
+
pageCategory?: string | undefined;
|
|
4223
4237
|
};
|
|
4224
4238
|
children: ({
|
|
4225
4239
|
type: "Interactive";
|
|
@@ -4363,6 +4377,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
4363
4377
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
4364
4378
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
4365
4379
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
4380
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
4366
4381
|
}, "strip", z.ZodTypeAny, {
|
|
4367
4382
|
title: string;
|
|
4368
4383
|
pageId: string;
|
|
@@ -4372,6 +4387,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
4372
4387
|
conceptId?: string | undefined;
|
|
4373
4388
|
metaDescription?: string | undefined;
|
|
4374
4389
|
pageTheme?: string | undefined;
|
|
4390
|
+
pageCategory?: string | undefined;
|
|
4375
4391
|
}, {
|
|
4376
4392
|
title: string;
|
|
4377
4393
|
pageId: string;
|
|
@@ -4381,6 +4397,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
4381
4397
|
conceptId?: string | undefined;
|
|
4382
4398
|
metaDescription?: string | undefined;
|
|
4383
4399
|
pageTheme?: string | undefined;
|
|
4400
|
+
pageCategory?: string | undefined;
|
|
4384
4401
|
}>;
|
|
4385
4402
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
4386
4403
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -5204,6 +5221,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
5204
5221
|
conceptId?: string | undefined;
|
|
5205
5222
|
metaDescription?: string | undefined;
|
|
5206
5223
|
pageTheme?: string | undefined;
|
|
5224
|
+
pageCategory?: string | undefined;
|
|
5207
5225
|
};
|
|
5208
5226
|
children: ({
|
|
5209
5227
|
type: "Interactive";
|
|
@@ -5331,6 +5349,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
5331
5349
|
conceptId?: string | undefined;
|
|
5332
5350
|
metaDescription?: string | undefined;
|
|
5333
5351
|
pageTheme?: string | undefined;
|
|
5352
|
+
pageCategory?: string | undefined;
|
|
5334
5353
|
};
|
|
5335
5354
|
children: ({
|
|
5336
5355
|
type: "Interactive";
|
|
@@ -5472,6 +5491,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
5472
5491
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
5473
5492
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
5474
5493
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
5494
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
5475
5495
|
}, "strip", z.ZodTypeAny, {
|
|
5476
5496
|
title: string;
|
|
5477
5497
|
pageId: string;
|
|
@@ -5481,6 +5501,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
5481
5501
|
conceptId?: string | undefined;
|
|
5482
5502
|
metaDescription?: string | undefined;
|
|
5483
5503
|
pageTheme?: string | undefined;
|
|
5504
|
+
pageCategory?: string | undefined;
|
|
5484
5505
|
}, {
|
|
5485
5506
|
title: string;
|
|
5486
5507
|
pageId: string;
|
|
@@ -5490,6 +5511,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
5490
5511
|
conceptId?: string | undefined;
|
|
5491
5512
|
metaDescription?: string | undefined;
|
|
5492
5513
|
pageTheme?: string | undefined;
|
|
5514
|
+
pageCategory?: string | undefined;
|
|
5493
5515
|
}>;
|
|
5494
5516
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
5495
5517
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -6314,6 +6336,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6314
6336
|
conceptId?: string | undefined;
|
|
6315
6337
|
metaDescription?: string | undefined;
|
|
6316
6338
|
pageTheme?: string | undefined;
|
|
6339
|
+
pageCategory?: string | undefined;
|
|
6317
6340
|
};
|
|
6318
6341
|
children: ({
|
|
6319
6342
|
type: "Interactive";
|
|
@@ -6443,6 +6466,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6443
6466
|
conceptId?: string | undefined;
|
|
6444
6467
|
metaDescription?: string | undefined;
|
|
6445
6468
|
pageTheme?: string | undefined;
|
|
6469
|
+
pageCategory?: string | undefined;
|
|
6446
6470
|
};
|
|
6447
6471
|
children: ({
|
|
6448
6472
|
type: "Interactive";
|
|
@@ -6635,6 +6659,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
6635
6659
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
6636
6660
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
6637
6661
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
6662
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
6638
6663
|
}, "strip", z.ZodTypeAny, {
|
|
6639
6664
|
title: string;
|
|
6640
6665
|
pageId: string;
|
|
@@ -6644,6 +6669,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
6644
6669
|
conceptId?: string | undefined;
|
|
6645
6670
|
metaDescription?: string | undefined;
|
|
6646
6671
|
pageTheme?: string | undefined;
|
|
6672
|
+
pageCategory?: string | undefined;
|
|
6647
6673
|
}, {
|
|
6648
6674
|
title: string;
|
|
6649
6675
|
pageId: string;
|
|
@@ -6653,6 +6679,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
6653
6679
|
conceptId?: string | undefined;
|
|
6654
6680
|
metaDescription?: string | undefined;
|
|
6655
6681
|
pageTheme?: string | undefined;
|
|
6682
|
+
pageCategory?: string | undefined;
|
|
6656
6683
|
}>;
|
|
6657
6684
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
6658
6685
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -7476,6 +7503,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
7476
7503
|
conceptId?: string | undefined;
|
|
7477
7504
|
metaDescription?: string | undefined;
|
|
7478
7505
|
pageTheme?: string | undefined;
|
|
7506
|
+
pageCategory?: string | undefined;
|
|
7479
7507
|
};
|
|
7480
7508
|
children: ({
|
|
7481
7509
|
type: "Interactive";
|
|
@@ -7603,6 +7631,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
7603
7631
|
conceptId?: string | undefined;
|
|
7604
7632
|
metaDescription?: string | undefined;
|
|
7605
7633
|
pageTheme?: string | undefined;
|
|
7634
|
+
pageCategory?: string | undefined;
|
|
7606
7635
|
};
|
|
7607
7636
|
children: ({
|
|
7608
7637
|
type: "Interactive";
|
|
@@ -7745,6 +7774,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
7745
7774
|
conceptId?: string | undefined;
|
|
7746
7775
|
metaDescription?: string | undefined;
|
|
7747
7776
|
pageTheme?: string | undefined;
|
|
7777
|
+
pageCategory?: string | undefined;
|
|
7748
7778
|
};
|
|
7749
7779
|
children: ({
|
|
7750
7780
|
type: "Interactive";
|
|
@@ -7879,6 +7909,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
7879
7909
|
conceptId?: string | undefined;
|
|
7880
7910
|
metaDescription?: string | undefined;
|
|
7881
7911
|
pageTheme?: string | undefined;
|
|
7912
|
+
pageCategory?: string | undefined;
|
|
7882
7913
|
};
|
|
7883
7914
|
children: ({
|
|
7884
7915
|
type: "Interactive";
|
|
@@ -492,6 +492,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
492
492
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
493
493
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
494
494
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
495
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
495
496
|
}, "strip", z.ZodTypeAny, {
|
|
496
497
|
title: string;
|
|
497
498
|
pageId: string;
|
|
@@ -501,6 +502,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
501
502
|
conceptId?: string | undefined;
|
|
502
503
|
metaDescription?: string | undefined;
|
|
503
504
|
pageTheme?: string | undefined;
|
|
505
|
+
pageCategory?: string | undefined;
|
|
504
506
|
}, {
|
|
505
507
|
title: string;
|
|
506
508
|
pageId: string;
|
|
@@ -510,6 +512,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
510
512
|
conceptId?: string | undefined;
|
|
511
513
|
metaDescription?: string | undefined;
|
|
512
514
|
pageTheme?: string | undefined;
|
|
515
|
+
pageCategory?: string | undefined;
|
|
513
516
|
}>;
|
|
514
517
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
515
518
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -1334,6 +1337,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1334
1337
|
conceptId?: string | undefined;
|
|
1335
1338
|
metaDescription?: string | undefined;
|
|
1336
1339
|
pageTheme?: string | undefined;
|
|
1340
|
+
pageCategory?: string | undefined;
|
|
1337
1341
|
};
|
|
1338
1342
|
children: ({
|
|
1339
1343
|
type: "Interactive";
|
|
@@ -1463,6 +1467,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1463
1467
|
conceptId?: string | undefined;
|
|
1464
1468
|
metaDescription?: string | undefined;
|
|
1465
1469
|
pageTheme?: string | undefined;
|
|
1470
|
+
pageCategory?: string | undefined;
|
|
1466
1471
|
};
|
|
1467
1472
|
children: ({
|
|
1468
1473
|
type: "Interactive";
|
|
@@ -1604,6 +1609,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1604
1609
|
conceptId?: string | undefined;
|
|
1605
1610
|
metaDescription?: string | undefined;
|
|
1606
1611
|
pageTheme?: string | undefined;
|
|
1612
|
+
pageCategory?: string | undefined;
|
|
1607
1613
|
};
|
|
1608
1614
|
children: ({
|
|
1609
1615
|
type: "Interactive";
|
|
@@ -1745,6 +1751,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1745
1751
|
conceptId?: string | undefined;
|
|
1746
1752
|
metaDescription?: string | undefined;
|
|
1747
1753
|
pageTheme?: string | undefined;
|
|
1754
|
+
pageCategory?: string | undefined;
|
|
1748
1755
|
};
|
|
1749
1756
|
children: ({
|
|
1750
1757
|
type: "Interactive";
|
|
@@ -2967,6 +2974,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
2967
2974
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
2968
2975
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
2969
2976
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
2977
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
2970
2978
|
}, "strip", z.ZodTypeAny, {
|
|
2971
2979
|
title: string;
|
|
2972
2980
|
pageId: string;
|
|
@@ -2976,6 +2984,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
2976
2984
|
conceptId?: string | undefined;
|
|
2977
2985
|
metaDescription?: string | undefined;
|
|
2978
2986
|
pageTheme?: string | undefined;
|
|
2987
|
+
pageCategory?: string | undefined;
|
|
2979
2988
|
}, {
|
|
2980
2989
|
title: string;
|
|
2981
2990
|
pageId: string;
|
|
@@ -2985,6 +2994,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
2985
2994
|
conceptId?: string | undefined;
|
|
2986
2995
|
metaDescription?: string | undefined;
|
|
2987
2996
|
pageTheme?: string | undefined;
|
|
2997
|
+
pageCategory?: string | undefined;
|
|
2988
2998
|
}>;
|
|
2989
2999
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
2990
3000
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -3809,6 +3819,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
3809
3819
|
conceptId?: string | undefined;
|
|
3810
3820
|
metaDescription?: string | undefined;
|
|
3811
3821
|
pageTheme?: string | undefined;
|
|
3822
|
+
pageCategory?: string | undefined;
|
|
3812
3823
|
};
|
|
3813
3824
|
children: ({
|
|
3814
3825
|
type: "Interactive";
|
|
@@ -3938,6 +3949,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
3938
3949
|
conceptId?: string | undefined;
|
|
3939
3950
|
metaDescription?: string | undefined;
|
|
3940
3951
|
pageTheme?: string | undefined;
|
|
3952
|
+
pageCategory?: string | undefined;
|
|
3941
3953
|
};
|
|
3942
3954
|
children: ({
|
|
3943
3955
|
type: "Interactive";
|
|
@@ -4079,6 +4091,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4079
4091
|
conceptId?: string | undefined;
|
|
4080
4092
|
metaDescription?: string | undefined;
|
|
4081
4093
|
pageTheme?: string | undefined;
|
|
4094
|
+
pageCategory?: string | undefined;
|
|
4082
4095
|
};
|
|
4083
4096
|
children: ({
|
|
4084
4097
|
type: "Interactive";
|
|
@@ -4220,6 +4233,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4220
4233
|
conceptId?: string | undefined;
|
|
4221
4234
|
metaDescription?: string | undefined;
|
|
4222
4235
|
pageTheme?: string | undefined;
|
|
4236
|
+
pageCategory?: string | undefined;
|
|
4223
4237
|
};
|
|
4224
4238
|
children: ({
|
|
4225
4239
|
type: "Interactive";
|
|
@@ -4363,6 +4377,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
4363
4377
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
4364
4378
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
4365
4379
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
4380
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
4366
4381
|
}, "strip", z.ZodTypeAny, {
|
|
4367
4382
|
title: string;
|
|
4368
4383
|
pageId: string;
|
|
@@ -4372,6 +4387,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
4372
4387
|
conceptId?: string | undefined;
|
|
4373
4388
|
metaDescription?: string | undefined;
|
|
4374
4389
|
pageTheme?: string | undefined;
|
|
4390
|
+
pageCategory?: string | undefined;
|
|
4375
4391
|
}, {
|
|
4376
4392
|
title: string;
|
|
4377
4393
|
pageId: string;
|
|
@@ -4381,6 +4397,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
4381
4397
|
conceptId?: string | undefined;
|
|
4382
4398
|
metaDescription?: string | undefined;
|
|
4383
4399
|
pageTheme?: string | undefined;
|
|
4400
|
+
pageCategory?: string | undefined;
|
|
4384
4401
|
}>;
|
|
4385
4402
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
4386
4403
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -5204,6 +5221,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
5204
5221
|
conceptId?: string | undefined;
|
|
5205
5222
|
metaDescription?: string | undefined;
|
|
5206
5223
|
pageTheme?: string | undefined;
|
|
5224
|
+
pageCategory?: string | undefined;
|
|
5207
5225
|
};
|
|
5208
5226
|
children: ({
|
|
5209
5227
|
type: "Interactive";
|
|
@@ -5331,6 +5349,7 @@ declare const PageStructureInputSchema: z.ZodObject<{
|
|
|
5331
5349
|
conceptId?: string | undefined;
|
|
5332
5350
|
metaDescription?: string | undefined;
|
|
5333
5351
|
pageTheme?: string | undefined;
|
|
5352
|
+
pageCategory?: string | undefined;
|
|
5334
5353
|
};
|
|
5335
5354
|
children: ({
|
|
5336
5355
|
type: "Interactive";
|
|
@@ -5472,6 +5491,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
5472
5491
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
5473
5492
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
5474
5493
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
5494
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
5475
5495
|
}, "strip", z.ZodTypeAny, {
|
|
5476
5496
|
title: string;
|
|
5477
5497
|
pageId: string;
|
|
@@ -5481,6 +5501,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
5481
5501
|
conceptId?: string | undefined;
|
|
5482
5502
|
metaDescription?: string | undefined;
|
|
5483
5503
|
pageTheme?: string | undefined;
|
|
5504
|
+
pageCategory?: string | undefined;
|
|
5484
5505
|
}, {
|
|
5485
5506
|
title: string;
|
|
5486
5507
|
pageId: string;
|
|
@@ -5490,6 +5511,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
5490
5511
|
conceptId?: string | undefined;
|
|
5491
5512
|
metaDescription?: string | undefined;
|
|
5492
5513
|
pageTheme?: string | undefined;
|
|
5514
|
+
pageCategory?: string | undefined;
|
|
5493
5515
|
}>;
|
|
5494
5516
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
5495
5517
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -6314,6 +6336,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6314
6336
|
conceptId?: string | undefined;
|
|
6315
6337
|
metaDescription?: string | undefined;
|
|
6316
6338
|
pageTheme?: string | undefined;
|
|
6339
|
+
pageCategory?: string | undefined;
|
|
6317
6340
|
};
|
|
6318
6341
|
children: ({
|
|
6319
6342
|
type: "Interactive";
|
|
@@ -6443,6 +6466,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6443
6466
|
conceptId?: string | undefined;
|
|
6444
6467
|
metaDescription?: string | undefined;
|
|
6445
6468
|
pageTheme?: string | undefined;
|
|
6469
|
+
pageCategory?: string | undefined;
|
|
6446
6470
|
};
|
|
6447
6471
|
children: ({
|
|
6448
6472
|
type: "Interactive";
|
|
@@ -6635,6 +6659,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
6635
6659
|
pageTheme: z.ZodOptional<z.ZodString>;
|
|
6636
6660
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
6637
6661
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
6662
|
+
pageCategory: z.ZodOptional<z.ZodString>;
|
|
6638
6663
|
}, "strip", z.ZodTypeAny, {
|
|
6639
6664
|
title: string;
|
|
6640
6665
|
pageId: string;
|
|
@@ -6644,6 +6669,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
6644
6669
|
conceptId?: string | undefined;
|
|
6645
6670
|
metaDescription?: string | undefined;
|
|
6646
6671
|
pageTheme?: string | undefined;
|
|
6672
|
+
pageCategory?: string | undefined;
|
|
6647
6673
|
}, {
|
|
6648
6674
|
title: string;
|
|
6649
6675
|
pageId: string;
|
|
@@ -6653,6 +6679,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
6653
6679
|
conceptId?: string | undefined;
|
|
6654
6680
|
metaDescription?: string | undefined;
|
|
6655
6681
|
pageTheme?: string | undefined;
|
|
6682
|
+
pageCategory?: string | undefined;
|
|
6656
6683
|
}>;
|
|
6657
6684
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
6658
6685
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -7476,6 +7503,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
7476
7503
|
conceptId?: string | undefined;
|
|
7477
7504
|
metaDescription?: string | undefined;
|
|
7478
7505
|
pageTheme?: string | undefined;
|
|
7506
|
+
pageCategory?: string | undefined;
|
|
7479
7507
|
};
|
|
7480
7508
|
children: ({
|
|
7481
7509
|
type: "Interactive";
|
|
@@ -7603,6 +7631,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
7603
7631
|
conceptId?: string | undefined;
|
|
7604
7632
|
metaDescription?: string | undefined;
|
|
7605
7633
|
pageTheme?: string | undefined;
|
|
7634
|
+
pageCategory?: string | undefined;
|
|
7606
7635
|
};
|
|
7607
7636
|
children: ({
|
|
7608
7637
|
type: "Interactive";
|
|
@@ -7745,6 +7774,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
7745
7774
|
conceptId?: string | undefined;
|
|
7746
7775
|
metaDescription?: string | undefined;
|
|
7747
7776
|
pageTheme?: string | undefined;
|
|
7777
|
+
pageCategory?: string | undefined;
|
|
7748
7778
|
};
|
|
7749
7779
|
children: ({
|
|
7750
7780
|
type: "Interactive";
|
|
@@ -7879,6 +7909,7 @@ declare const PersistPageDraftInputSchema: z.ZodObject<{
|
|
|
7879
7909
|
conceptId?: string | undefined;
|
|
7880
7910
|
metaDescription?: string | undefined;
|
|
7881
7911
|
pageTheme?: string | undefined;
|
|
7912
|
+
pageCategory?: string | undefined;
|
|
7882
7913
|
};
|
|
7883
7914
|
children: ({
|
|
7884
7915
|
type: "Interactive";
|
package/dist/index.cjs
CHANGED
|
@@ -751,7 +751,8 @@ var BasePagePropertiesSchema = _zod.z.object({
|
|
|
751
751
|
metaDescription: _zod.z.string().optional(),
|
|
752
752
|
pageTheme: _zod.z.string().optional(),
|
|
753
753
|
sponsorText: _zod.z.string().optional(),
|
|
754
|
-
sponsorImage: _zod.z.string().url().optional()
|
|
754
|
+
sponsorImage: _zod.z.string().url().optional(),
|
|
755
|
+
pageCategory: _zod.z.string().optional()
|
|
755
756
|
});
|
|
756
757
|
var PageStructureInputSchema = _zod.z.object({
|
|
757
758
|
properties: BasePagePropertiesSchema,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/circleci/repo/packages/content-curation-client/dist/index.cjs","../src/errors.ts","../src/internal/error-factories.ts","../src/schemas/response.ts","../src/internal/response-handling.ts","../src/internal/request-lifecycle.ts","../src/base.ts","../src/schemas/ftpink/legacyHubPage/index.ts","../src/schemas/ftpink/page/index.ts","../src/schemas/prosemirror.ts","../src/schemas/ftpink/draft/index.ts","../src/page.ts","../src/client.ts"],"names":["z"],"mappings":"AAAA;AC4CO,IAAM,eAAA,EAAN,MAAA,QAA6B,MAAM;A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;AACb,QAAA;AACR,MAAA;AACM,MAAA;AACP,IAAA;AACD,EAAA;AAEgC,EAAA;AACH,IAAA;AAC7B,EAAA;AAIC,EAAA;AAEY,IAAA;AACO,MAAA;AAClB,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACD,EAAA;AACD;AXuwBkC;AACA;AY/yBH;AAC9B,EAAA;AAEqC,EAAA;AACxB,IAAA;AAGe,IAAA;AAC5B,EAAA;AACD;AZ8yBkC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/circleci/repo/packages/content-curation-client/dist/index.cjs","sourcesContent":[null,"import type { ApiErrorPayload } from \"./schemas/response\";\n\n/** Where the failing request broke down. */\nexport type ApiClientErrorOrigin = \"transport\" | \"gateway\" | \"service\";\n\n/** The transport failure mode when no HTTP response was received. */\nexport type ApiTransportKind = \"abort\" | \"timeout\" | \"network\";\n\n/** Machine-readable codes exposed by the client error model. */\nexport type ApiClientErrorCode =\n\t| ApiErrorPayload[\"code\"]\n\t| \"API_GATEWAY_ERROR\"\n\t| \"API_TRANSPORT_ERROR\";\n\n/**\n * Shared error payload shape used by all client-generated errors.\n *\n * Service-origin errors use the validated `ApiErrorPayload` returned by the API.\n * Gateway and transport errors synthesize the same top-level fields so callers\n * can handle them consistently.\n */\nexport type ApiClientErrorPayload = {\n\tcode: ApiClientErrorCode;\n\tmessage: string;\n\tdetails?: string;\n\tpath?: string;\n\ttimestamp?: string;\n};\n\ntype ApiClientErrorMetadata = {\n\torigin: ApiClientErrorOrigin;\n\turl?: string;\n\tcontentType?: string;\n\tbodyText?: string;\n\tcause?: unknown;\n};\n\ntype ApiTransportErrorMetadata = Omit<ApiClientErrorMetadata, \"origin\"> & {\n\ttransportKind: ApiTransportKind;\n};\n\n/**\n * Base error type for all failures surfaced by the client package.\n */\nexport class ApiClientError extends Error {\n\t/** The machine-readable error payload exposed by the client. */\n\tpublic payload: ApiClientErrorPayload;\n\t/** The machine-readable error code. */\n\tpublic code: ApiClientErrorPayload[\"code\"];\n\t/** Additional diagnostic detail captured by the client. */\n\tpublic details?: string;\n\t/** The API path associated with the failing request. */\n\tpublic path?: string;\n\t/** Optional timestamp supplied by the upstream service. */\n\tpublic timestamp?: string;\n\t/** Indicates whether the failure originated from transport, gateway, or service handling. */\n\tpublic origin: ApiClientErrorOrigin;\n\t/** The fully qualified request URL, when available. */\n\tpublic url?: string;\n\t/** The response content type, when a response was received. */\n\tpublic contentType?: string;\n\t/** A truncated copy of the raw response body, when captured. */\n\tpublic bodyText?: string;\n\t/** The upstream request identifier, when available. */\n\tpublic requestId?: string;\n\t/** The HTTP status code reported by the service or gateway. */\n\tpublic statusCode: number;\n\t/** The underlying thrown error, if there was one. */\n\tpublic override cause?: unknown;\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: ApiClientErrorMetadata = { origin: \"service\" },\n\t) {\n\t\tsuper(payload.message);\n\t\tthis.name = new.target.name;\n\t\tthis.payload = payload;\n\t\tthis.statusCode = statusCode;\n\t\tthis.requestId = requestId;\n\t\tthis.code = payload.code;\n\t\tthis.details = payload.details;\n\t\tthis.path = payload.path;\n\t\tthis.timestamp = payload.timestamp;\n\t\tthis.origin = metadata.origin;\n\t\tthis.url = metadata.url;\n\t\tthis.contentType = metadata.contentType;\n\t\tthis.bodyText = metadata.bodyText;\n\t\tthis.cause = metadata.cause;\n\t}\n}\n\n/**\n * Error raised when the request fails before any HTTP response is available.\n */\nexport class ApiTransportError extends ApiClientError {\n\tpublic override payload: ApiClientErrorPayload;\n\tpublic override origin: \"transport\";\n\t/** Whether the failure was caused by an abort, timeout, or generic network problem. */\n\tpublic transportKind: ApiTransportKind;\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId: string | undefined,\n\t\tmetadata: ApiTransportErrorMetadata,\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"transport\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"transport\";\n\t\tthis.transportKind = metadata.transportKind;\n\t}\n}\n\n/**\n * Error raised when the request reached API Gateway but did not produce a\n * valid service-level error envelope.\n */\nexport class ApiGatewayError extends ApiClientError {\n\tpublic override payload: ApiClientErrorPayload;\n\tpublic override origin: \"gateway\";\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: Omit<ApiClientErrorMetadata, \"origin\"> = {},\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"gateway\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"gateway\";\n\t}\n}\n\n/**\n * Error raised when the root service returns a valid JSON API error envelope,\n * or when a successful response cannot be interpreted as the expected API\n * success envelope.\n */\nexport class ApiServiceError extends ApiClientError {\n\tpublic override payload: ApiErrorPayload;\n\tpublic override origin: \"service\";\n\n\tconstructor(\n\t\tpayload: ApiErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: Omit<ApiClientErrorMetadata, \"origin\"> = {},\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"service\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"service\";\n\t}\n}\n","import {\n\tApiGatewayError,\n\tApiServiceError,\n\tApiTransportError,\n\ttype ApiTransportKind,\n} from \"../errors\";\n\ntype GatewayErrorOptions = {\n\tcontentType?: string;\n\tbodyText?: string;\n\tdetails: string;\n\trequestId?: string;\n\tcause?: unknown;\n};\n\ntype UnexpectedServiceResponseOptions = GatewayErrorOptions;\n\n/**\n * Wraps a fetch failure that happened before any response was available.\n */\nexport function createTransportError(path: string, url: string, error: unknown): ApiTransportError {\n\tconst transportKind = classifyTransportFailure(error);\n\tconst message = describeTransportFailure(transportKind);\n\tconst causeDetails = getErrorDiagnosticMessage(error);\n\tconst details = causeDetails ? `${message} Cause: ${causeDetails}` : message;\n\n\treturn new ApiTransportError(\n\t\t{\n\t\t\tcode: \"API_TRANSPORT_ERROR\",\n\t\t\tmessage,\n\t\t\tdetails,\n\t\t\tpath,\n\t\t},\n\t\t0,\n\t\tundefined,\n\t\t{\n\t\t\ttransportKind,\n\t\t\turl,\n\t\t\tcause: error,\n\t\t},\n\t);\n}\n\n/**\n * Builds a gateway-origin client error after the caller has already decided the response does not\n * represent a validated service error envelope.\n */\nexport function createGatewayError(\n\tpath: string,\n\turl: string,\n\tstatusCode: number,\n\toptions: GatewayErrorOptions,\n): ApiGatewayError {\n\treturn new ApiGatewayError(\n\t\t{\n\t\t\tcode: \"API_GATEWAY_ERROR\",\n\t\t\tmessage: `The API gateway responded with status ${statusCode}.`,\n\t\t\tdetails: options.details,\n\t\t\tpath,\n\t\t},\n\t\tstatusCode,\n\t\toptions.requestId,\n\t\t{\n\t\t\turl,\n\t\t\tcontentType: options.contentType,\n\t\t\tbodyText: options.bodyText,\n\t\t\tcause: options.cause,\n\t\t},\n\t);\n}\n\n/**\n * Builds the fallback service error used when a 2xx response cannot be interpreted as the\n * expected Content Curation API success envelope.\n */\nexport function createUnexpectedServiceResponseError(\n\tpath: string,\n\turl: string,\n\toptions: UnexpectedServiceResponseOptions,\n): ApiServiceError {\n\treturn new ApiServiceError(\n\t\t{\n\t\t\tcode: \"INTERNAL_SERVER_ERROR\",\n\t\t\tmessage: \"Unexpected API response format\",\n\t\t\tdetails: options.details,\n\t\t\tpath,\n\t\t},\n\t\t500,\n\t\toptions.requestId,\n\t\t{\n\t\t\turl,\n\t\t\tcontentType: options.contentType,\n\t\t\tbodyText: options.bodyText,\n\t\t\tcause: options.cause,\n\t\t},\n\t);\n}\n\nfunction classifyTransportFailure(error: unknown): ApiTransportKind {\n\tconst errorName = readStringProperty(error, \"name\");\n\n\tif (errorName === \"AbortError\") {\n\t\treturn \"abort\";\n\t}\n\n\tif (errorName === \"TimeoutError\") {\n\t\treturn \"timeout\";\n\t}\n\n\tif (errorName === \"FetchError\" && readStringProperty(error, \"type\") === \"request-timeout\") {\n\t\treturn \"timeout\";\n\t}\n\n\treturn \"network\";\n}\n\nfunction describeTransportFailure(transportKind: ApiTransportKind): string {\n\tif (transportKind === \"abort\") {\n\t\treturn \"The request was aborted before a response was received.\";\n\t}\n\n\tif (transportKind === \"timeout\") {\n\t\treturn \"The request timed out before a response was received.\";\n\t}\n\n\treturn \"The request failed before a response was received.\";\n}\n\nfunction getErrorDiagnosticMessage(error: unknown): string | undefined {\n\tconst diagnosticParts = [\n\t\treadCauseCode(error),\n\t\treadStringProperty(error, \"name\"),\n\t\treadStringProperty(error, \"message\"),\n\t].filter(\n\t\t(value, index, values): value is string => Boolean(value) && values.indexOf(value) === index,\n\t);\n\n\treturn diagnosticParts.length > 0 ? diagnosticParts.join(\": \") : undefined;\n}\n\nfunction readCauseCode(error: unknown): string | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst directCode = readStringProperty(error, \"code\");\n\tif (directCode) {\n\t\treturn directCode;\n\t}\n\n\tconst cause = (error as { cause?: unknown }).cause;\n\treturn readStringProperty(cause, \"code\");\n}\n\nfunction readStringProperty(error: unknown, property: string): string | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst value = (error as Record<string, unknown>)[property];\n\treturn typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n","import { z, type ZodTypeAny } from \"zod\";\n\n/**\n * Strongly‐typed enum for all possible API error codes.\n */\nexport const ApiErrorCode = z.enum([\n\t\"UNAUTHORIZED\",\n\t\"NOT_FOUND\",\n\t\"INTERNAL_SERVER_ERROR\",\n\t\"INVALID_INPUT_DATA\",\n]);\n\n/**\n * Fields shared by both success and error envelopes (but not the discriminant).\n */\nconst BaseEnvelopeFields = z.object({\n\tstatusCode: z.number(),\n\trequestId: z.string(),\n});\n\n/**\n * Specific details carried in an error payload.\n */\nexport const ApiErrorPayloadSchema = z\n\t.object({\n\t\tcode: ApiErrorCode,\n\t\tmessage: z.string(),\n\t\tdetails: z.string().optional(),\n\t\tpath: z.string().optional(),\n\t\ttimestamp: z.string().optional(),\n\t})\n\t.strict();\n\nexport type ApiErrorPayload = z.infer<typeof ApiErrorPayloadSchema>;\n\n/**\n * Full “envelope” when the API has failed.\n */\nexport const ApiErrorResponseSchema = BaseEnvelopeFields.extend({\n\tstatus: z.literal(\"error\"),\n\terror: ApiErrorPayloadSchema,\n}).strict();\n\nexport type ApiErrorResponse = z.infer<typeof ApiErrorResponseSchema>;\n\n/**\n * Schema for a successful API response, given some data schema T.\n */\nexport function ApiSuccessResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\treturn BaseEnvelopeFields.extend({\n\t\tstatus: z.literal(\"success\"),\n\t\tdata: dataSchema,\n\t}).strict();\n}\n\n/**\n * Union of success or error envelopes, discriminated on `status`.\n */\nexport function ApiResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\tconst successSchema = ApiSuccessResponseSchema(dataSchema);\n\tconst errorSchema = ApiErrorResponseSchema;\n\treturn z.discriminatedUnion(\"status\", [successSchema, errorSchema]);\n}\n","import type { ZodTypeAny } from \"zod\";\nimport { ApiErrorResponseSchema, ApiResponseSchema } from \"../schemas/response\";\n\nconst GATEWAY_STATUS_CODES = new Set([499, 502, 503]);\nconst MAX_DIAGNOSTIC_BODY_LENGTH = 2000;\n\n/**\n * Captured information from a response body after the client has consumed it exactly once.\n */\nexport type ResponseBodyDiagnostics = {\n\tcontentType?: string;\n\tbodyText?: string;\n\tjson?: unknown;\n\tjsonParseError?: Error;\n};\n\n/**\n * Returns `true` when a status code should always be treated as an API Gateway failure.\n */\nexport function isGatewayStatusCode(statusCode: number): boolean {\n\treturn GATEWAY_STATUS_CODES.has(statusCode);\n}\n\n/**\n * Extracts the response content type, if one was provided.\n */\nexport function getResponseContentType(response: Response): string | undefined {\n\treturn response.headers?.get(\"content-type\") ?? undefined;\n}\n\n/**\n * Extracts the upstream request identifier, if one was provided.\n */\nexport function getResponseRequestId(response: Response): string | undefined {\n\treturn response.headers?.get(\"x-request-id\") ?? response.headers?.get(\"request-id\") ?? undefined;\n}\n\n/**\n * Reads a response body exactly once, truncates diagnostic text, and only parses JSON when the\n * declared content type says that is appropriate.\n */\nexport async function readResponseBody(response: Response): Promise<ResponseBodyDiagnostics> {\n\tconst contentType = getResponseContentType(response);\n\tlet rawBody = \"\";\n\n\ttry {\n\t\trawBody = await response.text();\n\t} catch (error) {\n\t\tawait discardResponseBody(response);\n\t\tthrow error;\n\t}\n\n\tconst bodyText = truncateBody(rawBody);\n\n\tif (!isJsonContentType(contentType) || rawBody.length === 0) {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t};\n\t}\n\n\ttry {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t\tjson: JSON.parse(rawBody),\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t\tjsonParseError: toError(error),\n\t\t};\n\t}\n}\n\n/**\n * Attempts to validate a consumed response body as a success-or-error API envelope.\n */\nexport function parseApiResponse<ResponseDataSchema extends ZodTypeAny>(\n\tresponseDataSchema: ResponseDataSchema,\n\tresponseBody: ResponseBodyDiagnostics,\n) {\n\tif (responseBody.json === undefined) {\n\t\treturn null;\n\t}\n\n\tconst parsedResponse = ApiResponseSchema(responseDataSchema).safeParse(responseBody.json);\n\treturn parsedResponse.success ? parsedResponse.data : null;\n}\n\n/**\n * Attempts to validate a consumed response body as a service-level error envelope.\n */\nexport function parseApiErrorResponse(responseBody: ResponseBodyDiagnostics) {\n\tif (responseBody.json === undefined) {\n\t\treturn null;\n\t}\n\n\tconst parsedError = ApiErrorResponseSchema.safeParse(responseBody.json);\n\treturn parsedError.success ? parsedError.data : null;\n}\n\n/**\n * Builds the diagnostic detail string used when a 2xx response cannot be understood as the\n * expected Content Curation API success envelope.\n */\nexport function describeUnexpectedSuccessResponse(responseBody: ResponseBodyDiagnostics): string {\n\tif (responseBody.jsonParseError) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t\"The service reported a JSON response but the body could not be parsed as JSON.\",\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\tif (!responseBody.contentType || !isJsonContentType(responseBody.contentType)) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t\"The service returned a success status without a JSON response body.\",\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\treturn buildDiagnosticDetails(\n\t\t\"The service returned JSON, but it did not match the expected Content Curation API envelope.\",\n\t\tresponseBody,\n\t);\n}\n\n/**\n * Builds the diagnostic detail string used when a non-success response should be treated as a\n * gateway-origin failure rather than a validated service error.\n */\nexport function describeGatewayResponse(\n\tstatusCode: number,\n\tresponseBody: ResponseBodyDiagnostics,\n): string {\n\tif (responseBody.jsonParseError) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t`The non-success response with status ${statusCode} declared a JSON content type, but its body could not be parsed as JSON.`,\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\tif (!responseBody.contentType || !isJsonContentType(responseBody.contentType)) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t`The non-success response with status ${statusCode} was not a valid service JSON error envelope.`,\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\treturn buildDiagnosticDetails(\n\t\t`The non-success response with status ${statusCode} returned JSON, but it did not match the service error envelope.`,\n\t\tresponseBody,\n\t);\n}\n\n/**\n * Best-effort response cleanup for the rare case where reading the body throws before completion.\n */\nasync function discardResponseBody(response: Response): Promise<void> {\n\tconst body = response.body as unknown;\n\tif (!body) {\n\t\treturn;\n\t}\n\n\tif (typeof (body as { cancel?: () => Promise<void> }).cancel === \"function\") {\n\t\ttry {\n\t\t\tawait (body as { cancel: () => Promise<void> }).cancel();\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// Best effort only.\n\t\t}\n\t}\n\n\tif (\n\t\ttypeof (body as { resume?: () => void }).resume === \"function\" &&\n\t\ttypeof (body as { on?: (event: string, handler: () => void) => void }).on === \"function\"\n\t) {\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst stream = body as {\n\t\t\t\tresume: () => void;\n\t\t\t\ton: (event: string, handler: () => void) => void;\n\t\t\t};\n\t\t\tconst finish = () => resolve();\n\t\t\tstream.on(\"end\", finish);\n\t\t\tstream.on(\"error\", finish);\n\t\t\tstream.resume();\n\t\t});\n\t}\n}\n\nfunction buildDiagnosticDetails(message: string, responseBody: ResponseBodyDiagnostics): string {\n\tconst detailParts = [message];\n\n\tif (responseBody.contentType) {\n\t\tdetailParts.push(`Content-Type: ${responseBody.contentType}.`);\n\t}\n\n\tif (responseBody.jsonParseError) {\n\t\tdetailParts.push(`JSON parse error: ${responseBody.jsonParseError.message}.`);\n\t}\n\n\tif (responseBody.bodyText) {\n\t\tdetailParts.push(\"The raw response body is available in bodyText.\");\n\t}\n\n\treturn detailParts.join(\" \");\n}\n\nfunction isJsonContentType(contentType?: string): boolean {\n\tif (!contentType) {\n\t\treturn false;\n\t}\n\n\tconst mimeType = contentType.split(\";\")[0]?.trim().toLowerCase();\n\tif (!mimeType) {\n\t\treturn false;\n\t}\n\n\treturn mimeType === \"application/json\" || mimeType.endsWith(\"+json\");\n}\n\nfunction truncateBody(bodyText: string): string | undefined {\n\tif (bodyText.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (bodyText.length <= MAX_DIAGNOSTIC_BODY_LENGTH) {\n\t\treturn bodyText;\n\t}\n\n\treturn `${bodyText.slice(0, MAX_DIAGNOSTIC_BODY_LENGTH - 3)}...`;\n}\n\nfunction toError(error: unknown): Error {\n\tif (error instanceof Error) {\n\t\treturn error;\n\t}\n\n\tconst message = typeof error === \"string\" && error.length > 0 ? error : \"Unknown error\";\n\treturn new Error(message);\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport type { ApiGatewayError } from \"../errors\";\nimport { ApiServiceError } from \"../errors\";\nimport { createGatewayError, createUnexpectedServiceResponseError } from \"./error-factories\";\nimport {\n\tdescribeGatewayResponse,\n\tdescribeUnexpectedSuccessResponse,\n\tgetResponseContentType,\n\tgetResponseRequestId,\n\tisGatewayStatusCode,\n\tparseApiErrorResponse,\n\tparseApiResponse,\n\treadResponseBody,\n\ttype ResponseBodyDiagnostics,\n} from \"./response-handling\";\n\n/**\n * Validates an outbound request body when the caller supplied a schema.\n *\n * Requests without a body, or without a schema, pass through unchanged.\n */\nexport function parseRequestBody<ReqSchema extends ZodTypeAny | undefined>(\n\trequestSchema: ReqSchema | undefined,\n\tbody: (ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown) | undefined,\n): (ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown) | undefined {\n\tif (!requestSchema || body === undefined) {\n\t\treturn body;\n\t}\n\n\treturn requestSchema.parse(body);\n}\n\n/**\n * Consumes the HTTP response body and converts body-read failures into the same\n * client error model used for normal gateway and service failures.\n */\nexport async function readApiResponseBody(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n): Promise<ResponseBodyDiagnostics> {\n\ttry {\n\t\treturn await readResponseBody(response);\n\t} catch (error) {\n\t\tif (response.ok) {\n\t\t\tthrow createUnexpectedServiceResponseError(path, url, {\n\t\t\t\tcontentType: getResponseContentType(response),\n\t\t\t\tcause: error,\n\t\t\t\tdetails: \"Failed to read the response body before the API response could be validated.\",\n\t\t\t\trequestId: getResponseRequestId(response),\n\t\t\t});\n\t\t}\n\n\t\tthrow createGatewayError(path, url, response.status, {\n\t\t\tcontentType: getResponseContentType(response),\n\t\t\tcause: error,\n\t\t\tdetails:\n\t\t\t\t\"Failed to read the non-success response body, so the response could not be validated as a service error.\",\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n}\n\n/**\n * Interprets a successful HTTP response as either a valid Content Curation API\n * success envelope or a service-origin failure.\n */\nexport function parseSuccessfulResponse<ResponseDataSchema extends ZodTypeAny>(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n\tresponseBody: ResponseBodyDiagnostics,\n\tresponseDataSchema: ResponseDataSchema,\n): z.infer<ResponseDataSchema> {\n\tconst parsedResponse = parseApiResponse(responseDataSchema, responseBody);\n\n\tif (!parsedResponse) {\n\t\tthrow createUnexpectedServiceResponseError(path, url, {\n\t\t\tcontentType: responseBody.contentType,\n\t\t\tbodyText: responseBody.bodyText,\n\t\t\tdetails: describeUnexpectedSuccessResponse(responseBody),\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n\n\tif (\"error\" in parsedResponse) {\n\t\tthrow new ApiServiceError(\n\t\t\tparsedResponse.error,\n\t\t\tparsedResponse.statusCode,\n\t\t\tparsedResponse.requestId,\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\tcontentType: responseBody.contentType,\n\t\t\t\tbodyText: responseBody.bodyText,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn parsedResponse.data;\n}\n\n/**\n * Classifies a non-success HTTP response as either a validated service error or\n * a gateway-origin failure.\n */\nexport function createResponseError(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n\tresponseBody: ResponseBodyDiagnostics,\n): ApiGatewayError | ApiServiceError {\n\tif (isGatewayStatusCode(response.status)) {\n\t\treturn createGatewayError(path, url, response.status, {\n\t\t\tcontentType: responseBody.contentType,\n\t\t\tbodyText: responseBody.bodyText,\n\t\t\tdetails: describeGatewayResponse(response.status, responseBody),\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n\n\tconst parsedServiceError = parseApiErrorResponse(responseBody);\n\tif (parsedServiceError) {\n\t\treturn new ApiServiceError(\n\t\t\tparsedServiceError.error,\n\t\t\tparsedServiceError.statusCode,\n\t\t\tparsedServiceError.requestId,\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\tcontentType: responseBody.contentType,\n\t\t\t\tbodyText: responseBody.bodyText,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn createGatewayError(path, url, response.status, {\n\t\tcontentType: responseBody.contentType,\n\t\tbodyText: responseBody.bodyText,\n\t\tdetails: describeGatewayResponse(response.status, responseBody),\n\t\trequestId: getResponseRequestId(response),\n\t});\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport {\n\tcreateResponseError,\n\tcreateTransportError,\n\tparseRequestBody,\n\tparseSuccessfulResponse,\n\treadApiResponseBody,\n} from \"./internal\";\n\n/**\n * Configuration options for the API client.\n */\nexport type ApiClientConfig =\n\t| {\n\t\t\t// Standard configuration.\n\t\t\t// Intended for external clients using an API key issued via API Gateway.\n\t\t\tbaseUrl: string;\n\t\t\tapiKey: string;\n\t\t\tapiToken?: never;\n\t\t\tfetch?: typeof fetch;\n\t }\n\t| {\n\t\t\t// Alternative configuration.\n\t\t\t// Reserved for clients with access to a bearer token (for example, e2e tests).\n\t\t\tbaseUrl: string;\n\t\t\tapiKey?: never;\n\t\t\tapiToken: string;\n\t\t\tfetch?: typeof fetch;\n\t };\n\n/**\n * Shared HTTP client for Content Curation API requests.\n *\n * The public sub-clients delegate to this class so request validation, fetch\n * execution, response parsing, and error classification all happen in one place.\n */\nexport class BaseApiClient {\n\tprotected config: ApiClientConfig;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\tfetch: config.fetch || fetch,\n\t\t};\n\t\tthis.config.baseUrl = trimTrailingSlashes(this.config.baseUrl);\n\t}\n\n\t/**\n\t * Performs a request against the JSON API, validates the response envelope,\n\t * and returns the typed `data` payload on success.\n\t */\n\tprotected async request<\n\t\tReqSchema extends ZodTypeAny | undefined,\n\t\tResponseDataSchema extends ZodTypeAny,\n\t>(\n\t\tmethod: \"GET\" | \"PUT\" | \"POST\" | \"DELETE\",\n\t\tpath: string,\n\t\topts: {\n\t\t\trequestSchema?: ReqSchema;\n\t\t\tbody?: ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown;\n\t\t\tresponseDataSchema: ResponseDataSchema;\n\t\t},\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\tconst bodyPayload = parseRequestBody(opts.requestSchema, opts.body);\n\t\tconst urlString = new URL(this.config.baseUrl + path).toString();\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await this.config.fetch!(urlString, {\n\t\t\t\tmethod,\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t...(this.config.apiKey\n\t\t\t\t\t\t? { \"x-api-key\": this.config.apiKey }\n\t\t\t\t\t\t: { Authorization: `Bearer ${this.config.apiToken}` }),\n\t\t\t\t},\n\t\t\t\tbody: bodyPayload === undefined ? undefined : JSON.stringify(bodyPayload),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow createTransportError(path, urlString, error);\n\t\t}\n\n\t\tconst responseBody = await readApiResponseBody(path, urlString, response);\n\n\t\tif (response.ok) {\n\t\t\treturn parseSuccessfulResponse(\n\t\t\t\tpath,\n\t\t\t\turlString,\n\t\t\t\tresponse,\n\t\t\t\tresponseBody,\n\t\t\t\topts.responseDataSchema,\n\t\t\t);\n\t\t}\n\n\t\tthrow createResponseError(path, urlString, response, responseBody);\n\t}\n\n\t/**\n\t * GET convenience method inferring response type from schema.\n\t */\n\tprotected get<ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"GET\", path, { responseDataSchema });\n\t}\n\n\t/**\n\t * PUT convenience method inferring both request and response types.\n\t */\n\tprotected put<ReqSchema extends ZodTypeAny, ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tbody: z.infer<ReqSchema>,\n\t\trequestSchema: ReqSchema,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"PUT\", path, { body, requestSchema, responseDataSchema });\n\t}\n}\n\nfunction trimTrailingSlashes(value: string): string {\n\tlet end = value.length;\n\n\twhile (end > 0 && value.charCodeAt(end - 1) === 47) {\n\t\tend -= 1;\n\t}\n\n\treturn end === value.length ? value : value.slice(0, end);\n}\n","import { z } from \"zod\";\n\n/**\n * -----------------------------------------\n * Legacy API Schemas & Types\n *\n * These schemas map to expected types for Hub Pages rendered by dotcom-pages.\n * -----------------------------------------\n */\n\nconst LegacyFlourishChildSchema = z.object({\n\tsource: z.literal(\"flourish\"),\n\tproperties: z.object({\n\t\tid: z.string().min(1), // e.g. \"visualisation/21901162\"\n\t}),\n});\n\nconst LegacyListChildSchema = z.object({\n\tsource: z.literal(\"list\"),\n\tproperties: z.object({\n\t\tid: z.string().uuid(),\n\t\tmaxItems: z.number().optional(),\n\t}),\n});\n\nconst LegacyContentChildSchema = z.object({\n\tsource: z.literal(\"content\"),\n\tproperties: z.object({\n\t\tids: z.array(z.string()).nonempty(),\n\t}),\n});\n\nconst LegacyContainerChildSchema = z.discriminatedUnion(\"source\", [\n\tLegacyFlourishChildSchema,\n\tLegacyListChildSchema,\n\tLegacyContentChildSchema,\n]);\n\nconst LegacyTopperSchema = z.object({\n\ttype: z.literal(\"topper-basic\"),\n\tproperties: z.object({\n\t\ttitle: z.string(),\n\t\tsponsorText: z.string().optional(),\n\t\tsponsorImage: z.string().url().optional(),\n\t}),\n});\n\nconst LegacyInfoBoxSchema = z.object({\n\ttype: z.literal(\"info-box\"),\n\tproperties: z.object({\n\t\tbodyHTML: z.string(),\n\t\ttitle: z.string().optional(),\n\t}),\n});\n\nconst LegacyContainerSchema = z.object({\n\ttype: z.literal(\"container\"),\n\tchildren: z.array(LegacyContainerChildSchema).min(1),\n\tproperties: z.object({\n\t\ttitle: z.string().optional(),\n\t\tdesign: z.enum([\"chart\", \"four-story\", \"freeform\", \"hero-lead\"]).default(\"freeform\"),\n\t\tbackgroundColor: z.string().optional(),\n\t}),\n});\n\nconst LegacyExperimentSchema = z.object({\n\ttype: z.literal(\"experiment\"),\n\tchildren: z.tuple([]),\n\tproperties: z.object({\n\t\texperimentName: z.string(),\n\t\tid: z.string(),\n\t\ttitle: z.string().optional(),\n\t\tconfig: z\n\t\t\t.object({\n\t\t\t\tvalue: z.unknown().optional(),\n\t\t\t\t// Hub pages support experiments with HTML and Text.\n\t\t\t\t// For now we just support JSON. As we migrate pages, this may change.\n\t\t\t\tformat: z.enum([\"json\"]).default(\"json\"),\n\t\t\t})\n\t\t\t.partial()\n\t\t\t.optional(),\n\t}),\n});\n\nconst LegacyBlockSchema = z.discriminatedUnion(\"type\", [\n\tLegacyTopperSchema,\n\tLegacyInfoBoxSchema,\n\tLegacyContainerSchema,\n\tLegacyExperimentSchema,\n]);\n\nexport const LegacyPageStructureOutputSchema = z.object({\n\tuuid: z.string().uuid(),\n\ttitle: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tthemeName: z.string().optional(),\n\tmetaDescription: z.string().optional(),\n\tblocks: z.array(LegacyBlockSchema),\n});\n\nexport type LegacyPageStructureOutput = z.infer<typeof LegacyPageStructureOutputSchema>;\nexport type LegacyBlock = z.infer<typeof LegacyBlockSchema>;\n","import { z } from \"zod\";\nimport { ProseMirrorDocSchema } from \"../../prosemirror\";\n\n//\n// 1) REUSABLE SCHEMAS FOR COMMON STRUCTURES\n//\n\n/**\n * A generic schema representing a heading used across various slices.\n * - `text`: The display text of the heading.\n * - `href`: An optional URL that the heading links to.\n */\nconst HeadingSchema = z.object({\n\ttext: z.string(),\n\thref: z.string().url().optional(),\n});\n\n/**\n * Base “properties” common to most page slices.\n * - `heading`: An optional heading object for slices that can display a title.\n */\nconst BasePageItemProps = z.object({\n\theading: HeadingSchema.optional(),\n});\n\n/**\n * A schema to validate that a string is valid JSON.\n */\nconst ValidJSONStringSchema = z.string().refine(\n\t(val) => {\n\t\ttry {\n\t\t\tJSON.parse(val);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\t{ message: \"Invalid JSON string\" },\n);\n\n//\n// 2) GENERIC HELPER TO DEFINE “SLICE” INPUT/OUTPUT SCHEMAS\n//\n\n/**\n * A union type to represent either a Zod object schema or an optional Zod object schema.\n */\ntype OptionalOrRequiredZodObject = z.AnyZodObject | z.ZodOptional<z.AnyZodObject>;\n\n/**\n * Helper function that, given:\n * - `typeName`: A string literal identifying the slice type.\n * - `propsShape`: A Zod schema describing the slice’s `properties`.\n *\n * Returns an object containing two schemas:\n * - `InputSchema`: For client-side input; `sliceId` is optional.\n * - `OutputSchema`: For server-side/output; `sliceId` is required.\n *\n * This is useful because when defining slices we often want to allow -\n * clients to submit slices without an ID (e.g., when creating new slices),\n */\nfunction defineSliceSchema<T extends string, P extends OptionalOrRequiredZodObject>(options: {\n\ttypeName: T;\n\tpropsShape: P;\n}) {\n\tconst { typeName, propsShape } = options;\n\n\t// Base schema shared by both input and output:\n\t// - `type`: Literal string identifying which slice this is.\n\t// - `hidden`: Optional flag to mark the slice as hidden.\n\t// - `properties`: The detailed properties shape for the slice.\n\tconst BaseSchema = z.object({\n\t\ttype: z.literal(typeName),\n\t\thidden: z.boolean().optional(),\n\t\tproperties: propsShape,\n\t});\n\n\t/**\n\t * Input schema: For client submissions.\n\t * - `sliceId` is optional because the client might not specify it yet.\n\t */\n\tconst InputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid().optional(),\n\t});\n\n\t/**\n\t * Output schema: For persisted or server-returned data.\n\t * - `sliceId` is required (each saved slice must have an ID).\n\t */\n\tconst OutputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid(),\n\t});\n\n\treturn { InputSchema, OutputSchema };\n}\n\n//\n// 3) DEFINE INDIVIDUAL SLICE TYPES (INPUT & OUTPUT) USING THE HELPER\n//\n\n// 3.A “InteractiveSlice”\n// - A slice to embed or reference a Flourish graphic by its ID.\n// - Extends graphic base properties with `flourishId` and `flourishAltText`, with optional 'theme', 'flourishDescription' or 'storyUUID'.\nconst InteractiveSlice = defineSliceSchema({\n\ttypeName: \"Interactive\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tflourishDescription: z.string().optional(), // Optional description for the Flourish graphic\n\t\tflourishId: z.string().nonempty(),\n\t\tflourishAltText: z.string().nonempty(),\n\t\tstoryUUID: z.string().uuid().optional(),\n\t\ttheme: z.string().optional(),\n\t}),\n});\n\n// 3.B “ExperimentSlice”\n// - A slice for embedding experimental content.\n// - Requires an `experimentId`, `experimentName`, and a JSON string (`contentJson`).\nconst ExperimentSlice = defineSliceSchema({\n\ttypeName: \"Experiment\",\n\tpropsShape: BasePageItemProps.extend({\n\t\texperimentId: z.string().nonempty(), // Unique ID for the experiment\n\t\texperimentName: z.string().nonempty(), // Human-readable name of the experiment\n\t\tcontentJson: ValidJSONStringSchema, // The experiment’s JSON payload as a valid JSON string\n\t}),\n});\n\n// 3.C \"Strip\"\n// - A slice that displays a strip of content.\nconst StripSlice = defineSliceSchema({\n\ttypeName: \"Strip\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the strip to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the strip\n\t}),\n});\n\n// 3.D \"TopperSlice\"\n// - A slice that displays a topper section with description and optional strapline.\nconst TopperSlice = defineSliceSchema({\n\ttypeName: \"Topper\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tdescription: ProseMirrorDocSchema,\n\t\tstrapline: z.string().optional(),\n\t}),\n});\n\n// 3.E \"Hero\"\n// - A slice that represents a Hero on the page. It references a Spark List.\nconst HeroSlice = defineSliceSchema({\n\ttypeName: \"Hero\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the spark list to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the hero\n\t}),\n});\n\n// 3.G \"StoryGroup\"\n// - A slice that stores an ordered list of manually curated content ids.\nconst StoryGroupSlice = defineSliceSchema({\n\ttypeName: \"StoryGroup\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tstorySlots: z.array(z.string().uuid()).nonempty(),\n\t}),\n});\n\n//\n// 4) COMPOSE DISCRIMINATED UNIONS FOR “SLICE API” INPUT & OUTPUT\n//\n\n/**\n * All possible slice inputs for the Page API.\n * This discriminated union allows Zod to pick the correct schema based on the `type` field.\n */\nexport const SliceApiInputSchema = z.discriminatedUnion(\"type\", [\n\tInteractiveSlice.InputSchema,\n\tExperimentSlice.InputSchema,\n\tStripSlice.InputSchema,\n\tTopperSlice.InputSchema,\n\tHeroSlice.InputSchema,\n\tStoryGroupSlice.InputSchema,\n] as const);\n\n/**\n * All possible slice outputs for the Page API.\n * The same discriminated union but with each slice requiring `sliceId`.\n */\nexport const SliceApiOutputSchema = z.discriminatedUnion(\"type\", [\n\tInteractiveSlice.OutputSchema,\n\tExperimentSlice.OutputSchema,\n\tStripSlice.OutputSchema,\n\tTopperSlice.OutputSchema,\n\tHeroSlice.OutputSchema,\n\tStoryGroupSlice.OutputSchema,\n] as const);\n\n//\n// 5) WRAPPER SCHEMAS FOR THE ENTIRE PAGE STRUCTURE\n//\n\nconst BasePagePropertiesSchema = z.object({\n\ttitle: z.string(),\n\tpageId: z.string().uuid(),\n\tpublicationId: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tmetaDescription: z.string().optional(),\n\tpageTheme: z.string().optional(),\n\tsponsorText: z.string().optional(),\n\tsponsorImage: z.string().url().optional(),\n});\n\n/**\n * Page structure as submitted by clients.\n * - `properties`: Metadata about the page\n * - `children`: Array of slice inputs (each with an optional `sliceId`).\n */\nexport const PageStructureInputSchema = z.object({\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiInputSchema),\n});\n\n/**\n * Page structure as stored or returned by the server.\n */\nexport const PageStructureOutputSchema = z.object({\n\ttype: z.literal(\"Page\"),\n\tschemaVersion: z.number(),\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiOutputSchema),\n});\n\n//\n// 6) EXPORT TYPES FOR CONSUMPTION IN CODE\n//\n\n/** Client-side type for page structure input */\nexport type PageStructureInput = z.infer<typeof PageStructureInputSchema>;\n\n/** Server-side type for page structure output */\nexport type PageStructureOutput = z.infer<typeof PageStructureOutputSchema>;\n\n/** Union of all possible slice outputs for type-checking convenience */\nexport type Slice = z.infer<typeof SliceApiOutputSchema>;\n\n/** Individual slice output types */\nexport type InteractiveSliceType = z.infer<typeof InteractiveSlice.OutputSchema>;\nexport type ExperimentSliceType = z.infer<typeof ExperimentSlice.OutputSchema>;\nexport type StripSliceType = z.infer<typeof StripSlice.OutputSchema>;\nexport type TopperSliceType = z.infer<typeof TopperSlice.OutputSchema>;\nexport type HeroSliceType = z.infer<typeof HeroSlice.OutputSchema>;\nexport type StoryGroupSliceType = z.infer<typeof StoryGroupSlice.OutputSchema>;\n","import { z } from \"zod\";\n\n/** Accept http(s) and mailto: (matches your editor config) */\nconst HrefSchema = z.string().refine((v) => /^(https?:\\/\\/|mailto:).+/.test(v), {\n\tmessage: \"Expected http(s):// or mailto: URL\",\n});\n\n/** Link mark. */\nconst ProseMirrorLinkMark = z.object({\n\ttype: z.literal(\"link\"),\n\tattrs: z.object({\n\t\thref: HrefSchema,\n\t}),\n});\n\n/** Supported text marks */\nconst ProseMirrorMark = z.discriminatedUnion(\"type\", [\n\tProseMirrorLinkMark,\n\tz.object({ type: z.literal(\"bold\") }),\n\tz.object({ type: z.literal(\"italic\") }),\n\tz.object({ type: z.literal(\"underline\") }),\n\tz.object({ type: z.literal(\"strike\") }),\n]);\n\n/** Text node */\nconst ProseMirrorTextNode = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tmarks: z.array(ProseMirrorMark).optional(),\n});\n\n/** Paragraph node — content can be empty/omitted */\nconst ProseMirrorParagraphNode = z.object({\n\ttype: z.literal(\"paragraph\"),\n\tcontent: z.array(ProseMirrorTextNode),\n});\n\n/** ProseMirror Node Union. */\nconst ProseMirrorNode = z.union([ProseMirrorParagraphNode, ProseMirrorTextNode]);\n\n/** Root node of a ProseMirror document - enforcing at least 1 paragraph */\nexport const ProseMirrorDocSchema = z.object({\n\ttype: z.literal(\"doc\"),\n\tcontent: z\n\t\t.array(ProseMirrorNode)\n\t\t.min(1, { message: \"Document must contain at least one paragraph\" }),\n});\n\n/** Rich text editor TS type. */\nexport type RichTextEditorType = z.infer<typeof ProseMirrorDocSchema>;\n\nexport {};\n","import { z } from \"zod\";\nimport { PageStructureInputSchema, PageStructureOutputSchema } from \"../page\";\n\nexport const DraftContributorInputSchema = z.object({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\temail: z.string().email().optional(),\n});\n\nexport const DraftContributorSchema = DraftContributorInputSchema.extend({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\tfirstTouchedAt: z.string().datetime(),\n\tlastTouchedAt: z.string().datetime(),\n});\n\nconst DraftMetadataSchema = z.object({\n\tdraftId: z.string().uuid(),\n\tcreatedAt: z.string().datetime(),\n\tupdatedAt: z.string().datetime(),\n\tcontributors: z.array(DraftContributorSchema),\n});\n\nexport const PageDraftSchema = DraftMetadataSchema.extend({\n\tstructure: PageStructureOutputSchema,\n});\n\nexport const DraftSchema = PageDraftSchema;\n\nexport const PersistPageDraftInputSchema = z.object({\n\tstructure: PageStructureInputSchema,\n\tcontributor: DraftContributorInputSchema,\n});\n\nexport type DraftContributorInput = z.infer<typeof DraftContributorInputSchema>;\nexport type DraftContributor = z.infer<typeof DraftContributorSchema>;\nexport type PageDraft = z.infer<typeof PageDraftSchema>;\nexport type Draft = z.infer<typeof DraftSchema>;\nexport type PersistPageDraftInput = z.infer<typeof PersistPageDraftInputSchema>;\n","import { BaseApiClient } from \"./base\";\nimport { ApiServiceError } from \"./errors\";\nimport type { LegacyPageStructureOutput } from \"./schemas/ftpink/legacyHubPage\";\nimport { LegacyPageStructureOutputSchema } from \"./schemas/ftpink/legacyHubPage\";\nimport {\n\tPageStructureInputSchema,\n\tPageStructureOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\n/**\n * Client for Page structure endpoints\n */\nexport class PageClient extends BaseApiClient {\n\tasync getStructure(pageId: string): Promise<PageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/structure`, PageStructureOutputSchema);\n\t}\n\n\tasync getDraft(pageId: string): Promise<PageDraft | null> {\n\t\ttry {\n\t\t\treturn await this.get(`/v1/page/${pageId}/draft`, PageDraftSchema);\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiServiceError && error.code === \"NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync getLegacyHubPageStructure(pageId: string): Promise<LegacyPageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/legacyHubPageStructure`, LegacyPageStructureOutputSchema);\n\t}\n\n\tasync upsertStructure(\n\t\tpageId: string,\n\t\tdata: Omit<PageStructureInput, \"type\">,\n\t): Promise<PageStructureOutput> {\n\t\treturn this.put(\n\t\t\t`/v1/page/${pageId}/structure`,\n\t\t\tdata,\n\t\t\tPageStructureInputSchema,\n\t\t\tPageStructureOutputSchema,\n\t\t);\n\t}\n}\n","import type { ApiClientConfig } from \"./base\";\nimport { BaseApiClient } from \"./base\";\nimport { PageClient } from \"./page\";\n\n/**\n * Main API client that provides access to all API endpoints\n */\nexport class ApiClient extends BaseApiClient {\n\tpage: PageClient;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tsuper(config);\n\n\t\t// Initialize sub-client\n\t\tthis.page = new PageClient(config);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/circleci/repo/packages/content-curation-client/dist/index.cjs","../src/errors.ts","../src/internal/error-factories.ts","../src/schemas/response.ts","../src/internal/response-handling.ts","../src/internal/request-lifecycle.ts","../src/base.ts","../src/schemas/ftpink/legacyHubPage/index.ts","../src/schemas/ftpink/page/index.ts","../src/schemas/prosemirror.ts","../src/schemas/ftpink/draft/index.ts","../src/page.ts","../src/client.ts"],"names":["z"],"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7B,EAAA;AAE0D,EAAA;AACrD,IAAA;AACmB,MAAA;AACP,IAAA;AACM,MAAA;AACb,QAAA;AACR,MAAA;AACM,MAAA;AACP,IAAA;AACD,EAAA;AAEgC,EAAA;AACH,IAAA;AAC7B,EAAA;AAIC,EAAA;AAEY,IAAA;AACO,MAAA;AAClB,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACD,EAAA;AACD;AXwwBkC;AACA;AYhzBH;AAC9B,EAAA;AAEqC,EAAA;AACxB,IAAA;AAGe,IAAA;AAC5B,EAAA;AACD;AZ+yBkC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/circleci/repo/packages/content-curation-client/dist/index.cjs","sourcesContent":[null,"import type { ApiErrorPayload } from \"./schemas/response\";\n\n/** Where the failing request broke down. */\nexport type ApiClientErrorOrigin = \"transport\" | \"gateway\" | \"service\";\n\n/** The transport failure mode when no HTTP response was received. */\nexport type ApiTransportKind = \"abort\" | \"timeout\" | \"network\";\n\n/** Machine-readable codes exposed by the client error model. */\nexport type ApiClientErrorCode =\n\t| ApiErrorPayload[\"code\"]\n\t| \"API_GATEWAY_ERROR\"\n\t| \"API_TRANSPORT_ERROR\";\n\n/**\n * Shared error payload shape used by all client-generated errors.\n *\n * Service-origin errors use the validated `ApiErrorPayload` returned by the API.\n * Gateway and transport errors synthesize the same top-level fields so callers\n * can handle them consistently.\n */\nexport type ApiClientErrorPayload = {\n\tcode: ApiClientErrorCode;\n\tmessage: string;\n\tdetails?: string;\n\tpath?: string;\n\ttimestamp?: string;\n};\n\ntype ApiClientErrorMetadata = {\n\torigin: ApiClientErrorOrigin;\n\turl?: string;\n\tcontentType?: string;\n\tbodyText?: string;\n\tcause?: unknown;\n};\n\ntype ApiTransportErrorMetadata = Omit<ApiClientErrorMetadata, \"origin\"> & {\n\ttransportKind: ApiTransportKind;\n};\n\n/**\n * Base error type for all failures surfaced by the client package.\n */\nexport class ApiClientError extends Error {\n\t/** The machine-readable error payload exposed by the client. */\n\tpublic payload: ApiClientErrorPayload;\n\t/** The machine-readable error code. */\n\tpublic code: ApiClientErrorPayload[\"code\"];\n\t/** Additional diagnostic detail captured by the client. */\n\tpublic details?: string;\n\t/** The API path associated with the failing request. */\n\tpublic path?: string;\n\t/** Optional timestamp supplied by the upstream service. */\n\tpublic timestamp?: string;\n\t/** Indicates whether the failure originated from transport, gateway, or service handling. */\n\tpublic origin: ApiClientErrorOrigin;\n\t/** The fully qualified request URL, when available. */\n\tpublic url?: string;\n\t/** The response content type, when a response was received. */\n\tpublic contentType?: string;\n\t/** A truncated copy of the raw response body, when captured. */\n\tpublic bodyText?: string;\n\t/** The upstream request identifier, when available. */\n\tpublic requestId?: string;\n\t/** The HTTP status code reported by the service or gateway. */\n\tpublic statusCode: number;\n\t/** The underlying thrown error, if there was one. */\n\tpublic override cause?: unknown;\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: ApiClientErrorMetadata = { origin: \"service\" },\n\t) {\n\t\tsuper(payload.message);\n\t\tthis.name = new.target.name;\n\t\tthis.payload = payload;\n\t\tthis.statusCode = statusCode;\n\t\tthis.requestId = requestId;\n\t\tthis.code = payload.code;\n\t\tthis.details = payload.details;\n\t\tthis.path = payload.path;\n\t\tthis.timestamp = payload.timestamp;\n\t\tthis.origin = metadata.origin;\n\t\tthis.url = metadata.url;\n\t\tthis.contentType = metadata.contentType;\n\t\tthis.bodyText = metadata.bodyText;\n\t\tthis.cause = metadata.cause;\n\t}\n}\n\n/**\n * Error raised when the request fails before any HTTP response is available.\n */\nexport class ApiTransportError extends ApiClientError {\n\tpublic override payload: ApiClientErrorPayload;\n\tpublic override origin: \"transport\";\n\t/** Whether the failure was caused by an abort, timeout, or generic network problem. */\n\tpublic transportKind: ApiTransportKind;\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId: string | undefined,\n\t\tmetadata: ApiTransportErrorMetadata,\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"transport\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"transport\";\n\t\tthis.transportKind = metadata.transportKind;\n\t}\n}\n\n/**\n * Error raised when the request reached API Gateway but did not produce a\n * valid service-level error envelope.\n */\nexport class ApiGatewayError extends ApiClientError {\n\tpublic override payload: ApiClientErrorPayload;\n\tpublic override origin: \"gateway\";\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: Omit<ApiClientErrorMetadata, \"origin\"> = {},\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"gateway\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"gateway\";\n\t}\n}\n\n/**\n * Error raised when the root service returns a valid JSON API error envelope,\n * or when a successful response cannot be interpreted as the expected API\n * success envelope.\n */\nexport class ApiServiceError extends ApiClientError {\n\tpublic override payload: ApiErrorPayload;\n\tpublic override origin: \"service\";\n\n\tconstructor(\n\t\tpayload: ApiErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: Omit<ApiClientErrorMetadata, \"origin\"> = {},\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"service\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"service\";\n\t}\n}\n","import {\n\tApiGatewayError,\n\tApiServiceError,\n\tApiTransportError,\n\ttype ApiTransportKind,\n} from \"../errors\";\n\ntype GatewayErrorOptions = {\n\tcontentType?: string;\n\tbodyText?: string;\n\tdetails: string;\n\trequestId?: string;\n\tcause?: unknown;\n};\n\ntype UnexpectedServiceResponseOptions = GatewayErrorOptions;\n\n/**\n * Wraps a fetch failure that happened before any response was available.\n */\nexport function createTransportError(path: string, url: string, error: unknown): ApiTransportError {\n\tconst transportKind = classifyTransportFailure(error);\n\tconst message = describeTransportFailure(transportKind);\n\tconst causeDetails = getErrorDiagnosticMessage(error);\n\tconst details = causeDetails ? `${message} Cause: ${causeDetails}` : message;\n\n\treturn new ApiTransportError(\n\t\t{\n\t\t\tcode: \"API_TRANSPORT_ERROR\",\n\t\t\tmessage,\n\t\t\tdetails,\n\t\t\tpath,\n\t\t},\n\t\t0,\n\t\tundefined,\n\t\t{\n\t\t\ttransportKind,\n\t\t\turl,\n\t\t\tcause: error,\n\t\t},\n\t);\n}\n\n/**\n * Builds a gateway-origin client error after the caller has already decided the response does not\n * represent a validated service error envelope.\n */\nexport function createGatewayError(\n\tpath: string,\n\turl: string,\n\tstatusCode: number,\n\toptions: GatewayErrorOptions,\n): ApiGatewayError {\n\treturn new ApiGatewayError(\n\t\t{\n\t\t\tcode: \"API_GATEWAY_ERROR\",\n\t\t\tmessage: `The API gateway responded with status ${statusCode}.`,\n\t\t\tdetails: options.details,\n\t\t\tpath,\n\t\t},\n\t\tstatusCode,\n\t\toptions.requestId,\n\t\t{\n\t\t\turl,\n\t\t\tcontentType: options.contentType,\n\t\t\tbodyText: options.bodyText,\n\t\t\tcause: options.cause,\n\t\t},\n\t);\n}\n\n/**\n * Builds the fallback service error used when a 2xx response cannot be interpreted as the\n * expected Content Curation API success envelope.\n */\nexport function createUnexpectedServiceResponseError(\n\tpath: string,\n\turl: string,\n\toptions: UnexpectedServiceResponseOptions,\n): ApiServiceError {\n\treturn new ApiServiceError(\n\t\t{\n\t\t\tcode: \"INTERNAL_SERVER_ERROR\",\n\t\t\tmessage: \"Unexpected API response format\",\n\t\t\tdetails: options.details,\n\t\t\tpath,\n\t\t},\n\t\t500,\n\t\toptions.requestId,\n\t\t{\n\t\t\turl,\n\t\t\tcontentType: options.contentType,\n\t\t\tbodyText: options.bodyText,\n\t\t\tcause: options.cause,\n\t\t},\n\t);\n}\n\nfunction classifyTransportFailure(error: unknown): ApiTransportKind {\n\tconst errorName = readStringProperty(error, \"name\");\n\n\tif (errorName === \"AbortError\") {\n\t\treturn \"abort\";\n\t}\n\n\tif (errorName === \"TimeoutError\") {\n\t\treturn \"timeout\";\n\t}\n\n\tif (errorName === \"FetchError\" && readStringProperty(error, \"type\") === \"request-timeout\") {\n\t\treturn \"timeout\";\n\t}\n\n\treturn \"network\";\n}\n\nfunction describeTransportFailure(transportKind: ApiTransportKind): string {\n\tif (transportKind === \"abort\") {\n\t\treturn \"The request was aborted before a response was received.\";\n\t}\n\n\tif (transportKind === \"timeout\") {\n\t\treturn \"The request timed out before a response was received.\";\n\t}\n\n\treturn \"The request failed before a response was received.\";\n}\n\nfunction getErrorDiagnosticMessage(error: unknown): string | undefined {\n\tconst diagnosticParts = [\n\t\treadCauseCode(error),\n\t\treadStringProperty(error, \"name\"),\n\t\treadStringProperty(error, \"message\"),\n\t].filter(\n\t\t(value, index, values): value is string => Boolean(value) && values.indexOf(value) === index,\n\t);\n\n\treturn diagnosticParts.length > 0 ? diagnosticParts.join(\": \") : undefined;\n}\n\nfunction readCauseCode(error: unknown): string | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst directCode = readStringProperty(error, \"code\");\n\tif (directCode) {\n\t\treturn directCode;\n\t}\n\n\tconst cause = (error as { cause?: unknown }).cause;\n\treturn readStringProperty(cause, \"code\");\n}\n\nfunction readStringProperty(error: unknown, property: string): string | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst value = (error as Record<string, unknown>)[property];\n\treturn typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n","import { z, type ZodTypeAny } from \"zod\";\n\n/**\n * Strongly‐typed enum for all possible API error codes.\n */\nexport const ApiErrorCode = z.enum([\n\t\"UNAUTHORIZED\",\n\t\"NOT_FOUND\",\n\t\"INTERNAL_SERVER_ERROR\",\n\t\"INVALID_INPUT_DATA\",\n]);\n\n/**\n * Fields shared by both success and error envelopes (but not the discriminant).\n */\nconst BaseEnvelopeFields = z.object({\n\tstatusCode: z.number(),\n\trequestId: z.string(),\n});\n\n/**\n * Specific details carried in an error payload.\n */\nexport const ApiErrorPayloadSchema = z\n\t.object({\n\t\tcode: ApiErrorCode,\n\t\tmessage: z.string(),\n\t\tdetails: z.string().optional(),\n\t\tpath: z.string().optional(),\n\t\ttimestamp: z.string().optional(),\n\t})\n\t.strict();\n\nexport type ApiErrorPayload = z.infer<typeof ApiErrorPayloadSchema>;\n\n/**\n * Full “envelope” when the API has failed.\n */\nexport const ApiErrorResponseSchema = BaseEnvelopeFields.extend({\n\tstatus: z.literal(\"error\"),\n\terror: ApiErrorPayloadSchema,\n}).strict();\n\nexport type ApiErrorResponse = z.infer<typeof ApiErrorResponseSchema>;\n\n/**\n * Schema for a successful API response, given some data schema T.\n */\nexport function ApiSuccessResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\treturn BaseEnvelopeFields.extend({\n\t\tstatus: z.literal(\"success\"),\n\t\tdata: dataSchema,\n\t}).strict();\n}\n\n/**\n * Union of success or error envelopes, discriminated on `status`.\n */\nexport function ApiResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\tconst successSchema = ApiSuccessResponseSchema(dataSchema);\n\tconst errorSchema = ApiErrorResponseSchema;\n\treturn z.discriminatedUnion(\"status\", [successSchema, errorSchema]);\n}\n","import type { ZodTypeAny } from \"zod\";\nimport { ApiErrorResponseSchema, ApiResponseSchema } from \"../schemas/response\";\n\nconst GATEWAY_STATUS_CODES = new Set([499, 502, 503]);\nconst MAX_DIAGNOSTIC_BODY_LENGTH = 2000;\n\n/**\n * Captured information from a response body after the client has consumed it exactly once.\n */\nexport type ResponseBodyDiagnostics = {\n\tcontentType?: string;\n\tbodyText?: string;\n\tjson?: unknown;\n\tjsonParseError?: Error;\n};\n\n/**\n * Returns `true` when a status code should always be treated as an API Gateway failure.\n */\nexport function isGatewayStatusCode(statusCode: number): boolean {\n\treturn GATEWAY_STATUS_CODES.has(statusCode);\n}\n\n/**\n * Extracts the response content type, if one was provided.\n */\nexport function getResponseContentType(response: Response): string | undefined {\n\treturn response.headers?.get(\"content-type\") ?? undefined;\n}\n\n/**\n * Extracts the upstream request identifier, if one was provided.\n */\nexport function getResponseRequestId(response: Response): string | undefined {\n\treturn response.headers?.get(\"x-request-id\") ?? response.headers?.get(\"request-id\") ?? undefined;\n}\n\n/**\n * Reads a response body exactly once, truncates diagnostic text, and only parses JSON when the\n * declared content type says that is appropriate.\n */\nexport async function readResponseBody(response: Response): Promise<ResponseBodyDiagnostics> {\n\tconst contentType = getResponseContentType(response);\n\tlet rawBody = \"\";\n\n\ttry {\n\t\trawBody = await response.text();\n\t} catch (error) {\n\t\tawait discardResponseBody(response);\n\t\tthrow error;\n\t}\n\n\tconst bodyText = truncateBody(rawBody);\n\n\tif (!isJsonContentType(contentType) || rawBody.length === 0) {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t};\n\t}\n\n\ttry {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t\tjson: JSON.parse(rawBody),\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t\tjsonParseError: toError(error),\n\t\t};\n\t}\n}\n\n/**\n * Attempts to validate a consumed response body as a success-or-error API envelope.\n */\nexport function parseApiResponse<ResponseDataSchema extends ZodTypeAny>(\n\tresponseDataSchema: ResponseDataSchema,\n\tresponseBody: ResponseBodyDiagnostics,\n) {\n\tif (responseBody.json === undefined) {\n\t\treturn null;\n\t}\n\n\tconst parsedResponse = ApiResponseSchema(responseDataSchema).safeParse(responseBody.json);\n\treturn parsedResponse.success ? parsedResponse.data : null;\n}\n\n/**\n * Attempts to validate a consumed response body as a service-level error envelope.\n */\nexport function parseApiErrorResponse(responseBody: ResponseBodyDiagnostics) {\n\tif (responseBody.json === undefined) {\n\t\treturn null;\n\t}\n\n\tconst parsedError = ApiErrorResponseSchema.safeParse(responseBody.json);\n\treturn parsedError.success ? parsedError.data : null;\n}\n\n/**\n * Builds the diagnostic detail string used when a 2xx response cannot be understood as the\n * expected Content Curation API success envelope.\n */\nexport function describeUnexpectedSuccessResponse(responseBody: ResponseBodyDiagnostics): string {\n\tif (responseBody.jsonParseError) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t\"The service reported a JSON response but the body could not be parsed as JSON.\",\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\tif (!responseBody.contentType || !isJsonContentType(responseBody.contentType)) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t\"The service returned a success status without a JSON response body.\",\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\treturn buildDiagnosticDetails(\n\t\t\"The service returned JSON, but it did not match the expected Content Curation API envelope.\",\n\t\tresponseBody,\n\t);\n}\n\n/**\n * Builds the diagnostic detail string used when a non-success response should be treated as a\n * gateway-origin failure rather than a validated service error.\n */\nexport function describeGatewayResponse(\n\tstatusCode: number,\n\tresponseBody: ResponseBodyDiagnostics,\n): string {\n\tif (responseBody.jsonParseError) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t`The non-success response with status ${statusCode} declared a JSON content type, but its body could not be parsed as JSON.`,\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\tif (!responseBody.contentType || !isJsonContentType(responseBody.contentType)) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t`The non-success response with status ${statusCode} was not a valid service JSON error envelope.`,\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\treturn buildDiagnosticDetails(\n\t\t`The non-success response with status ${statusCode} returned JSON, but it did not match the service error envelope.`,\n\t\tresponseBody,\n\t);\n}\n\n/**\n * Best-effort response cleanup for the rare case where reading the body throws before completion.\n */\nasync function discardResponseBody(response: Response): Promise<void> {\n\tconst body = response.body as unknown;\n\tif (!body) {\n\t\treturn;\n\t}\n\n\tif (typeof (body as { cancel?: () => Promise<void> }).cancel === \"function\") {\n\t\ttry {\n\t\t\tawait (body as { cancel: () => Promise<void> }).cancel();\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// Best effort only.\n\t\t}\n\t}\n\n\tif (\n\t\ttypeof (body as { resume?: () => void }).resume === \"function\" &&\n\t\ttypeof (body as { on?: (event: string, handler: () => void) => void }).on === \"function\"\n\t) {\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst stream = body as {\n\t\t\t\tresume: () => void;\n\t\t\t\ton: (event: string, handler: () => void) => void;\n\t\t\t};\n\t\t\tconst finish = () => resolve();\n\t\t\tstream.on(\"end\", finish);\n\t\t\tstream.on(\"error\", finish);\n\t\t\tstream.resume();\n\t\t});\n\t}\n}\n\nfunction buildDiagnosticDetails(message: string, responseBody: ResponseBodyDiagnostics): string {\n\tconst detailParts = [message];\n\n\tif (responseBody.contentType) {\n\t\tdetailParts.push(`Content-Type: ${responseBody.contentType}.`);\n\t}\n\n\tif (responseBody.jsonParseError) {\n\t\tdetailParts.push(`JSON parse error: ${responseBody.jsonParseError.message}.`);\n\t}\n\n\tif (responseBody.bodyText) {\n\t\tdetailParts.push(\"The raw response body is available in bodyText.\");\n\t}\n\n\treturn detailParts.join(\" \");\n}\n\nfunction isJsonContentType(contentType?: string): boolean {\n\tif (!contentType) {\n\t\treturn false;\n\t}\n\n\tconst mimeType = contentType.split(\";\")[0]?.trim().toLowerCase();\n\tif (!mimeType) {\n\t\treturn false;\n\t}\n\n\treturn mimeType === \"application/json\" || mimeType.endsWith(\"+json\");\n}\n\nfunction truncateBody(bodyText: string): string | undefined {\n\tif (bodyText.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (bodyText.length <= MAX_DIAGNOSTIC_BODY_LENGTH) {\n\t\treturn bodyText;\n\t}\n\n\treturn `${bodyText.slice(0, MAX_DIAGNOSTIC_BODY_LENGTH - 3)}...`;\n}\n\nfunction toError(error: unknown): Error {\n\tif (error instanceof Error) {\n\t\treturn error;\n\t}\n\n\tconst message = typeof error === \"string\" && error.length > 0 ? error : \"Unknown error\";\n\treturn new Error(message);\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport type { ApiGatewayError } from \"../errors\";\nimport { ApiServiceError } from \"../errors\";\nimport { createGatewayError, createUnexpectedServiceResponseError } from \"./error-factories\";\nimport {\n\tdescribeGatewayResponse,\n\tdescribeUnexpectedSuccessResponse,\n\tgetResponseContentType,\n\tgetResponseRequestId,\n\tisGatewayStatusCode,\n\tparseApiErrorResponse,\n\tparseApiResponse,\n\treadResponseBody,\n\ttype ResponseBodyDiagnostics,\n} from \"./response-handling\";\n\n/**\n * Validates an outbound request body when the caller supplied a schema.\n *\n * Requests without a body, or without a schema, pass through unchanged.\n */\nexport function parseRequestBody<ReqSchema extends ZodTypeAny | undefined>(\n\trequestSchema: ReqSchema | undefined,\n\tbody: (ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown) | undefined,\n): (ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown) | undefined {\n\tif (!requestSchema || body === undefined) {\n\t\treturn body;\n\t}\n\n\treturn requestSchema.parse(body);\n}\n\n/**\n * Consumes the HTTP response body and converts body-read failures into the same\n * client error model used for normal gateway and service failures.\n */\nexport async function readApiResponseBody(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n): Promise<ResponseBodyDiagnostics> {\n\ttry {\n\t\treturn await readResponseBody(response);\n\t} catch (error) {\n\t\tif (response.ok) {\n\t\t\tthrow createUnexpectedServiceResponseError(path, url, {\n\t\t\t\tcontentType: getResponseContentType(response),\n\t\t\t\tcause: error,\n\t\t\t\tdetails: \"Failed to read the response body before the API response could be validated.\",\n\t\t\t\trequestId: getResponseRequestId(response),\n\t\t\t});\n\t\t}\n\n\t\tthrow createGatewayError(path, url, response.status, {\n\t\t\tcontentType: getResponseContentType(response),\n\t\t\tcause: error,\n\t\t\tdetails:\n\t\t\t\t\"Failed to read the non-success response body, so the response could not be validated as a service error.\",\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n}\n\n/**\n * Interprets a successful HTTP response as either a valid Content Curation API\n * success envelope or a service-origin failure.\n */\nexport function parseSuccessfulResponse<ResponseDataSchema extends ZodTypeAny>(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n\tresponseBody: ResponseBodyDiagnostics,\n\tresponseDataSchema: ResponseDataSchema,\n): z.infer<ResponseDataSchema> {\n\tconst parsedResponse = parseApiResponse(responseDataSchema, responseBody);\n\n\tif (!parsedResponse) {\n\t\tthrow createUnexpectedServiceResponseError(path, url, {\n\t\t\tcontentType: responseBody.contentType,\n\t\t\tbodyText: responseBody.bodyText,\n\t\t\tdetails: describeUnexpectedSuccessResponse(responseBody),\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n\n\tif (\"error\" in parsedResponse) {\n\t\tthrow new ApiServiceError(\n\t\t\tparsedResponse.error,\n\t\t\tparsedResponse.statusCode,\n\t\t\tparsedResponse.requestId,\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\tcontentType: responseBody.contentType,\n\t\t\t\tbodyText: responseBody.bodyText,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn parsedResponse.data;\n}\n\n/**\n * Classifies a non-success HTTP response as either a validated service error or\n * a gateway-origin failure.\n */\nexport function createResponseError(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n\tresponseBody: ResponseBodyDiagnostics,\n): ApiGatewayError | ApiServiceError {\n\tif (isGatewayStatusCode(response.status)) {\n\t\treturn createGatewayError(path, url, response.status, {\n\t\t\tcontentType: responseBody.contentType,\n\t\t\tbodyText: responseBody.bodyText,\n\t\t\tdetails: describeGatewayResponse(response.status, responseBody),\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n\n\tconst parsedServiceError = parseApiErrorResponse(responseBody);\n\tif (parsedServiceError) {\n\t\treturn new ApiServiceError(\n\t\t\tparsedServiceError.error,\n\t\t\tparsedServiceError.statusCode,\n\t\t\tparsedServiceError.requestId,\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\tcontentType: responseBody.contentType,\n\t\t\t\tbodyText: responseBody.bodyText,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn createGatewayError(path, url, response.status, {\n\t\tcontentType: responseBody.contentType,\n\t\tbodyText: responseBody.bodyText,\n\t\tdetails: describeGatewayResponse(response.status, responseBody),\n\t\trequestId: getResponseRequestId(response),\n\t});\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport {\n\tcreateResponseError,\n\tcreateTransportError,\n\tparseRequestBody,\n\tparseSuccessfulResponse,\n\treadApiResponseBody,\n} from \"./internal\";\n\n/**\n * Configuration options for the API client.\n */\nexport type ApiClientConfig =\n\t| {\n\t\t\t// Standard configuration.\n\t\t\t// Intended for external clients using an API key issued via API Gateway.\n\t\t\tbaseUrl: string;\n\t\t\tapiKey: string;\n\t\t\tapiToken?: never;\n\t\t\tfetch?: typeof fetch;\n\t }\n\t| {\n\t\t\t// Alternative configuration.\n\t\t\t// Reserved for clients with access to a bearer token (for example, e2e tests).\n\t\t\tbaseUrl: string;\n\t\t\tapiKey?: never;\n\t\t\tapiToken: string;\n\t\t\tfetch?: typeof fetch;\n\t };\n\n/**\n * Shared HTTP client for Content Curation API requests.\n *\n * The public sub-clients delegate to this class so request validation, fetch\n * execution, response parsing, and error classification all happen in one place.\n */\nexport class BaseApiClient {\n\tprotected config: ApiClientConfig;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\tfetch: config.fetch || fetch,\n\t\t};\n\t\tthis.config.baseUrl = trimTrailingSlashes(this.config.baseUrl);\n\t}\n\n\t/**\n\t * Performs a request against the JSON API, validates the response envelope,\n\t * and returns the typed `data` payload on success.\n\t */\n\tprotected async request<\n\t\tReqSchema extends ZodTypeAny | undefined,\n\t\tResponseDataSchema extends ZodTypeAny,\n\t>(\n\t\tmethod: \"GET\" | \"PUT\" | \"POST\" | \"DELETE\",\n\t\tpath: string,\n\t\topts: {\n\t\t\trequestSchema?: ReqSchema;\n\t\t\tbody?: ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown;\n\t\t\tresponseDataSchema: ResponseDataSchema;\n\t\t},\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\tconst bodyPayload = parseRequestBody(opts.requestSchema, opts.body);\n\t\tconst urlString = new URL(this.config.baseUrl + path).toString();\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await this.config.fetch!(urlString, {\n\t\t\t\tmethod,\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t...(this.config.apiKey\n\t\t\t\t\t\t? { \"x-api-key\": this.config.apiKey }\n\t\t\t\t\t\t: { Authorization: `Bearer ${this.config.apiToken}` }),\n\t\t\t\t},\n\t\t\t\tbody: bodyPayload === undefined ? undefined : JSON.stringify(bodyPayload),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow createTransportError(path, urlString, error);\n\t\t}\n\n\t\tconst responseBody = await readApiResponseBody(path, urlString, response);\n\n\t\tif (response.ok) {\n\t\t\treturn parseSuccessfulResponse(\n\t\t\t\tpath,\n\t\t\t\turlString,\n\t\t\t\tresponse,\n\t\t\t\tresponseBody,\n\t\t\t\topts.responseDataSchema,\n\t\t\t);\n\t\t}\n\n\t\tthrow createResponseError(path, urlString, response, responseBody);\n\t}\n\n\t/**\n\t * GET convenience method inferring response type from schema.\n\t */\n\tprotected get<ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"GET\", path, { responseDataSchema });\n\t}\n\n\t/**\n\t * PUT convenience method inferring both request and response types.\n\t */\n\tprotected put<ReqSchema extends ZodTypeAny, ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tbody: z.infer<ReqSchema>,\n\t\trequestSchema: ReqSchema,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"PUT\", path, { body, requestSchema, responseDataSchema });\n\t}\n}\n\nfunction trimTrailingSlashes(value: string): string {\n\tlet end = value.length;\n\n\twhile (end > 0 && value.charCodeAt(end - 1) === 47) {\n\t\tend -= 1;\n\t}\n\n\treturn end === value.length ? value : value.slice(0, end);\n}\n","import { z } from \"zod\";\n\n/**\n * -----------------------------------------\n * Legacy API Schemas & Types\n *\n * These schemas map to expected types for Hub Pages rendered by dotcom-pages.\n * -----------------------------------------\n */\n\nconst LegacyFlourishChildSchema = z.object({\n\tsource: z.literal(\"flourish\"),\n\tproperties: z.object({\n\t\tid: z.string().min(1), // e.g. \"visualisation/21901162\"\n\t}),\n});\n\nconst LegacyListChildSchema = z.object({\n\tsource: z.literal(\"list\"),\n\tproperties: z.object({\n\t\tid: z.string().uuid(),\n\t\tmaxItems: z.number().optional(),\n\t}),\n});\n\nconst LegacyContentChildSchema = z.object({\n\tsource: z.literal(\"content\"),\n\tproperties: z.object({\n\t\tids: z.array(z.string()).nonempty(),\n\t}),\n});\n\nconst LegacyContainerChildSchema = z.discriminatedUnion(\"source\", [\n\tLegacyFlourishChildSchema,\n\tLegacyListChildSchema,\n\tLegacyContentChildSchema,\n]);\n\nconst LegacyTopperSchema = z.object({\n\ttype: z.literal(\"topper-basic\"),\n\tproperties: z.object({\n\t\ttitle: z.string(),\n\t\tsponsorText: z.string().optional(),\n\t\tsponsorImage: z.string().url().optional(),\n\t}),\n});\n\nconst LegacyInfoBoxSchema = z.object({\n\ttype: z.literal(\"info-box\"),\n\tproperties: z.object({\n\t\tbodyHTML: z.string(),\n\t\ttitle: z.string().optional(),\n\t}),\n});\n\nconst LegacyContainerSchema = z.object({\n\ttype: z.literal(\"container\"),\n\tchildren: z.array(LegacyContainerChildSchema).min(1),\n\tproperties: z.object({\n\t\ttitle: z.string().optional(),\n\t\tdesign: z.enum([\"chart\", \"four-story\", \"freeform\", \"hero-lead\"]).default(\"freeform\"),\n\t\tbackgroundColor: z.string().optional(),\n\t}),\n});\n\nconst LegacyExperimentSchema = z.object({\n\ttype: z.literal(\"experiment\"),\n\tchildren: z.tuple([]),\n\tproperties: z.object({\n\t\texperimentName: z.string(),\n\t\tid: z.string(),\n\t\ttitle: z.string().optional(),\n\t\tconfig: z\n\t\t\t.object({\n\t\t\t\tvalue: z.unknown().optional(),\n\t\t\t\t// Hub pages support experiments with HTML and Text.\n\t\t\t\t// For now we just support JSON. As we migrate pages, this may change.\n\t\t\t\tformat: z.enum([\"json\"]).default(\"json\"),\n\t\t\t})\n\t\t\t.partial()\n\t\t\t.optional(),\n\t}),\n});\n\nconst LegacyBlockSchema = z.discriminatedUnion(\"type\", [\n\tLegacyTopperSchema,\n\tLegacyInfoBoxSchema,\n\tLegacyContainerSchema,\n\tLegacyExperimentSchema,\n]);\n\nexport const LegacyPageStructureOutputSchema = z.object({\n\tuuid: z.string().uuid(),\n\ttitle: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tthemeName: z.string().optional(),\n\tmetaDescription: z.string().optional(),\n\tblocks: z.array(LegacyBlockSchema),\n});\n\nexport type LegacyPageStructureOutput = z.infer<typeof LegacyPageStructureOutputSchema>;\nexport type LegacyBlock = z.infer<typeof LegacyBlockSchema>;\n","import { z } from \"zod\";\nimport { ProseMirrorDocSchema } from \"../../prosemirror\";\n\n//\n// 1) REUSABLE SCHEMAS FOR COMMON STRUCTURES\n//\n\n/**\n * A generic schema representing a heading used across various slices.\n * - `text`: The display text of the heading.\n * - `href`: An optional URL that the heading links to.\n */\nconst HeadingSchema = z.object({\n\ttext: z.string(),\n\thref: z.string().url().optional(),\n});\n\n/**\n * Base “properties” common to most page slices.\n * - `heading`: An optional heading object for slices that can display a title.\n */\nconst BasePageItemProps = z.object({\n\theading: HeadingSchema.optional(),\n});\n\n/**\n * A schema to validate that a string is valid JSON.\n */\nconst ValidJSONStringSchema = z.string().refine(\n\t(val) => {\n\t\ttry {\n\t\t\tJSON.parse(val);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\t{ message: \"Invalid JSON string\" },\n);\n\n//\n// 2) GENERIC HELPER TO DEFINE “SLICE” INPUT/OUTPUT SCHEMAS\n//\n\n/**\n * A union type to represent either a Zod object schema or an optional Zod object schema.\n */\ntype OptionalOrRequiredZodObject = z.AnyZodObject | z.ZodOptional<z.AnyZodObject>;\n\n/**\n * Helper function that, given:\n * - `typeName`: A string literal identifying the slice type.\n * - `propsShape`: A Zod schema describing the slice’s `properties`.\n *\n * Returns an object containing two schemas:\n * - `InputSchema`: For client-side input; `sliceId` is optional.\n * - `OutputSchema`: For server-side/output; `sliceId` is required.\n *\n * This is useful because when defining slices we often want to allow -\n * clients to submit slices without an ID (e.g., when creating new slices),\n */\nfunction defineSliceSchema<T extends string, P extends OptionalOrRequiredZodObject>(options: {\n\ttypeName: T;\n\tpropsShape: P;\n}) {\n\tconst { typeName, propsShape } = options;\n\n\t// Base schema shared by both input and output:\n\t// - `type`: Literal string identifying which slice this is.\n\t// - `hidden`: Optional flag to mark the slice as hidden.\n\t// - `properties`: The detailed properties shape for the slice.\n\tconst BaseSchema = z.object({\n\t\ttype: z.literal(typeName),\n\t\thidden: z.boolean().optional(),\n\t\tproperties: propsShape,\n\t});\n\n\t/**\n\t * Input schema: For client submissions.\n\t * - `sliceId` is optional because the client might not specify it yet.\n\t */\n\tconst InputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid().optional(),\n\t});\n\n\t/**\n\t * Output schema: For persisted or server-returned data.\n\t * - `sliceId` is required (each saved slice must have an ID).\n\t */\n\tconst OutputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid(),\n\t});\n\n\treturn { InputSchema, OutputSchema };\n}\n\n//\n// 3) DEFINE INDIVIDUAL SLICE TYPES (INPUT & OUTPUT) USING THE HELPER\n//\n\n// 3.A “InteractiveSlice”\n// - A slice to embed or reference a Flourish graphic by its ID.\n// - Extends graphic base properties with `flourishId` and `flourishAltText`, with optional 'theme', 'flourishDescription' or 'storyUUID'.\nconst InteractiveSlice = defineSliceSchema({\n\ttypeName: \"Interactive\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tflourishDescription: z.string().optional(), // Optional description for the Flourish graphic\n\t\tflourishId: z.string().nonempty(),\n\t\tflourishAltText: z.string().nonempty(),\n\t\tstoryUUID: z.string().uuid().optional(),\n\t\ttheme: z.string().optional(),\n\t}),\n});\n\n// 3.B “ExperimentSlice”\n// - A slice for embedding experimental content.\n// - Requires an `experimentId`, `experimentName`, and a JSON string (`contentJson`).\nconst ExperimentSlice = defineSliceSchema({\n\ttypeName: \"Experiment\",\n\tpropsShape: BasePageItemProps.extend({\n\t\texperimentId: z.string().nonempty(), // Unique ID for the experiment\n\t\texperimentName: z.string().nonempty(), // Human-readable name of the experiment\n\t\tcontentJson: ValidJSONStringSchema, // The experiment’s JSON payload as a valid JSON string\n\t}),\n});\n\n// 3.C \"Strip\"\n// - A slice that displays a strip of content.\nconst StripSlice = defineSliceSchema({\n\ttypeName: \"Strip\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the strip to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the strip\n\t}),\n});\n\n// 3.D \"TopperSlice\"\n// - A slice that displays a topper section with description and optional strapline.\nconst TopperSlice = defineSliceSchema({\n\ttypeName: \"Topper\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tdescription: ProseMirrorDocSchema,\n\t\tstrapline: z.string().optional(),\n\t}),\n});\n\n// 3.E \"Hero\"\n// - A slice that represents a Hero on the page. It references a Spark List.\nconst HeroSlice = defineSliceSchema({\n\ttypeName: \"Hero\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the spark list to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the hero\n\t}),\n});\n\n// 3.G \"StoryGroup\"\n// - A slice that stores an ordered list of manually curated content ids.\nconst StoryGroupSlice = defineSliceSchema({\n\ttypeName: \"StoryGroup\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tstorySlots: z.array(z.string().uuid()).nonempty(),\n\t}),\n});\n\n//\n// 4) COMPOSE DISCRIMINATED UNIONS FOR “SLICE API” INPUT & OUTPUT\n//\n\n/**\n * All possible slice inputs for the Page API.\n * This discriminated union allows Zod to pick the correct schema based on the `type` field.\n */\nexport const SliceApiInputSchema = z.discriminatedUnion(\"type\", [\n\tInteractiveSlice.InputSchema,\n\tExperimentSlice.InputSchema,\n\tStripSlice.InputSchema,\n\tTopperSlice.InputSchema,\n\tHeroSlice.InputSchema,\n\tStoryGroupSlice.InputSchema,\n] as const);\n\n/**\n * All possible slice outputs for the Page API.\n * The same discriminated union but with each slice requiring `sliceId`.\n */\nexport const SliceApiOutputSchema = z.discriminatedUnion(\"type\", [\n\tInteractiveSlice.OutputSchema,\n\tExperimentSlice.OutputSchema,\n\tStripSlice.OutputSchema,\n\tTopperSlice.OutputSchema,\n\tHeroSlice.OutputSchema,\n\tStoryGroupSlice.OutputSchema,\n] as const);\n\n//\n// 5) WRAPPER SCHEMAS FOR THE ENTIRE PAGE STRUCTURE\n//\n\nconst BasePagePropertiesSchema = z.object({\n\ttitle: z.string(),\n\tpageId: z.string().uuid(),\n\tpublicationId: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tmetaDescription: z.string().optional(),\n\tpageTheme: z.string().optional(),\n\tsponsorText: z.string().optional(),\n\tsponsorImage: z.string().url().optional(),\n\tpageCategory: z.string().optional(),\n});\n\n/**\n * Page structure as submitted by clients.\n * - `properties`: Metadata about the page\n * - `children`: Array of slice inputs (each with an optional `sliceId`).\n */\nexport const PageStructureInputSchema = z.object({\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiInputSchema),\n});\n\n/**\n * Page structure as stored or returned by the server.\n */\nexport const PageStructureOutputSchema = z.object({\n\ttype: z.literal(\"Page\"),\n\tschemaVersion: z.number(),\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiOutputSchema),\n});\n\n//\n// 6) EXPORT TYPES FOR CONSUMPTION IN CODE\n//\n\n/** Client-side type for page structure input */\nexport type PageStructureInput = z.infer<typeof PageStructureInputSchema>;\n\n/** Server-side type for page structure output */\nexport type PageStructureOutput = z.infer<typeof PageStructureOutputSchema>;\n\n/** Union of all possible slice outputs for type-checking convenience */\nexport type Slice = z.infer<typeof SliceApiOutputSchema>;\n\n/** Individual slice output types */\nexport type InteractiveSliceType = z.infer<typeof InteractiveSlice.OutputSchema>;\nexport type ExperimentSliceType = z.infer<typeof ExperimentSlice.OutputSchema>;\nexport type StripSliceType = z.infer<typeof StripSlice.OutputSchema>;\nexport type TopperSliceType = z.infer<typeof TopperSlice.OutputSchema>;\nexport type HeroSliceType = z.infer<typeof HeroSlice.OutputSchema>;\nexport type StoryGroupSliceType = z.infer<typeof StoryGroupSlice.OutputSchema>;\n","import { z } from \"zod\";\n\n/** Accept http(s) and mailto: (matches your editor config) */\nconst HrefSchema = z.string().refine((v) => /^(https?:\\/\\/|mailto:).+/.test(v), {\n\tmessage: \"Expected http(s):// or mailto: URL\",\n});\n\n/** Link mark. */\nconst ProseMirrorLinkMark = z.object({\n\ttype: z.literal(\"link\"),\n\tattrs: z.object({\n\t\thref: HrefSchema,\n\t}),\n});\n\n/** Supported text marks */\nconst ProseMirrorMark = z.discriminatedUnion(\"type\", [\n\tProseMirrorLinkMark,\n\tz.object({ type: z.literal(\"bold\") }),\n\tz.object({ type: z.literal(\"italic\") }),\n\tz.object({ type: z.literal(\"underline\") }),\n\tz.object({ type: z.literal(\"strike\") }),\n]);\n\n/** Text node */\nconst ProseMirrorTextNode = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tmarks: z.array(ProseMirrorMark).optional(),\n});\n\n/** Paragraph node — content can be empty/omitted */\nconst ProseMirrorParagraphNode = z.object({\n\ttype: z.literal(\"paragraph\"),\n\tcontent: z.array(ProseMirrorTextNode),\n});\n\n/** ProseMirror Node Union. */\nconst ProseMirrorNode = z.union([ProseMirrorParagraphNode, ProseMirrorTextNode]);\n\n/** Root node of a ProseMirror document - enforcing at least 1 paragraph */\nexport const ProseMirrorDocSchema = z.object({\n\ttype: z.literal(\"doc\"),\n\tcontent: z\n\t\t.array(ProseMirrorNode)\n\t\t.min(1, { message: \"Document must contain at least one paragraph\" }),\n});\n\n/** Rich text editor TS type. */\nexport type RichTextEditorType = z.infer<typeof ProseMirrorDocSchema>;\n\nexport {};\n","import { z } from \"zod\";\nimport { PageStructureInputSchema, PageStructureOutputSchema } from \"../page\";\n\nexport const DraftContributorInputSchema = z.object({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\temail: z.string().email().optional(),\n});\n\nexport const DraftContributorSchema = DraftContributorInputSchema.extend({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\tfirstTouchedAt: z.string().datetime(),\n\tlastTouchedAt: z.string().datetime(),\n});\n\nconst DraftMetadataSchema = z.object({\n\tdraftId: z.string().uuid(),\n\tcreatedAt: z.string().datetime(),\n\tupdatedAt: z.string().datetime(),\n\tcontributors: z.array(DraftContributorSchema),\n});\n\nexport const PageDraftSchema = DraftMetadataSchema.extend({\n\tstructure: PageStructureOutputSchema,\n});\n\nexport const DraftSchema = PageDraftSchema;\n\nexport const PersistPageDraftInputSchema = z.object({\n\tstructure: PageStructureInputSchema,\n\tcontributor: DraftContributorInputSchema,\n});\n\nexport type DraftContributorInput = z.infer<typeof DraftContributorInputSchema>;\nexport type DraftContributor = z.infer<typeof DraftContributorSchema>;\nexport type PageDraft = z.infer<typeof PageDraftSchema>;\nexport type Draft = z.infer<typeof DraftSchema>;\nexport type PersistPageDraftInput = z.infer<typeof PersistPageDraftInputSchema>;\n","import { BaseApiClient } from \"./base\";\nimport { ApiServiceError } from \"./errors\";\nimport type { LegacyPageStructureOutput } from \"./schemas/ftpink/legacyHubPage\";\nimport { LegacyPageStructureOutputSchema } from \"./schemas/ftpink/legacyHubPage\";\nimport {\n\tPageStructureInputSchema,\n\tPageStructureOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\n/**\n * Client for Page structure endpoints\n */\nexport class PageClient extends BaseApiClient {\n\tasync getStructure(pageId: string): Promise<PageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/structure`, PageStructureOutputSchema);\n\t}\n\n\tasync getDraft(pageId: string): Promise<PageDraft | null> {\n\t\ttry {\n\t\t\treturn await this.get(`/v1/page/${pageId}/draft`, PageDraftSchema);\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiServiceError && error.code === \"NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync getLegacyHubPageStructure(pageId: string): Promise<LegacyPageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/legacyHubPageStructure`, LegacyPageStructureOutputSchema);\n\t}\n\n\tasync upsertStructure(\n\t\tpageId: string,\n\t\tdata: Omit<PageStructureInput, \"type\">,\n\t): Promise<PageStructureOutput> {\n\t\treturn this.put(\n\t\t\t`/v1/page/${pageId}/structure`,\n\t\t\tdata,\n\t\t\tPageStructureInputSchema,\n\t\t\tPageStructureOutputSchema,\n\t\t);\n\t}\n}\n","import type { ApiClientConfig } from \"./base\";\nimport { BaseApiClient } from \"./base\";\nimport { PageClient } from \"./page\";\n\n/**\n * Main API client that provides access to all API endpoints\n */\nexport class ApiClient extends BaseApiClient {\n\tpage: PageClient;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tsuper(config);\n\n\t\t// Initialize sub-client\n\t\tthis.page = new PageClient(config);\n\t}\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -751,7 +751,8 @@ var BasePagePropertiesSchema = z4.object({
|
|
|
751
751
|
metaDescription: z4.string().optional(),
|
|
752
752
|
pageTheme: z4.string().optional(),
|
|
753
753
|
sponsorText: z4.string().optional(),
|
|
754
|
-
sponsorImage: z4.string().url().optional()
|
|
754
|
+
sponsorImage: z4.string().url().optional(),
|
|
755
|
+
pageCategory: z4.string().optional()
|
|
755
756
|
});
|
|
756
757
|
var PageStructureInputSchema = z4.object({
|
|
757
758
|
properties: BasePagePropertiesSchema,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/internal/error-factories.ts","../src/schemas/response.ts","../src/internal/response-handling.ts","../src/internal/request-lifecycle.ts","../src/base.ts","../src/schemas/ftpink/legacyHubPage/index.ts","../src/schemas/ftpink/page/index.ts","../src/schemas/prosemirror.ts","../src/schemas/ftpink/draft/index.ts","../src/page.ts","../src/client.ts"],"sourcesContent":["import type { ApiErrorPayload } from \"./schemas/response\";\n\n/** Where the failing request broke down. */\nexport type ApiClientErrorOrigin = \"transport\" | \"gateway\" | \"service\";\n\n/** The transport failure mode when no HTTP response was received. */\nexport type ApiTransportKind = \"abort\" | \"timeout\" | \"network\";\n\n/** Machine-readable codes exposed by the client error model. */\nexport type ApiClientErrorCode =\n\t| ApiErrorPayload[\"code\"]\n\t| \"API_GATEWAY_ERROR\"\n\t| \"API_TRANSPORT_ERROR\";\n\n/**\n * Shared error payload shape used by all client-generated errors.\n *\n * Service-origin errors use the validated `ApiErrorPayload` returned by the API.\n * Gateway and transport errors synthesize the same top-level fields so callers\n * can handle them consistently.\n */\nexport type ApiClientErrorPayload = {\n\tcode: ApiClientErrorCode;\n\tmessage: string;\n\tdetails?: string;\n\tpath?: string;\n\ttimestamp?: string;\n};\n\ntype ApiClientErrorMetadata = {\n\torigin: ApiClientErrorOrigin;\n\turl?: string;\n\tcontentType?: string;\n\tbodyText?: string;\n\tcause?: unknown;\n};\n\ntype ApiTransportErrorMetadata = Omit<ApiClientErrorMetadata, \"origin\"> & {\n\ttransportKind: ApiTransportKind;\n};\n\n/**\n * Base error type for all failures surfaced by the client package.\n */\nexport class ApiClientError extends Error {\n\t/** The machine-readable error payload exposed by the client. */\n\tpublic payload: ApiClientErrorPayload;\n\t/** The machine-readable error code. */\n\tpublic code: ApiClientErrorPayload[\"code\"];\n\t/** Additional diagnostic detail captured by the client. */\n\tpublic details?: string;\n\t/** The API path associated with the failing request. */\n\tpublic path?: string;\n\t/** Optional timestamp supplied by the upstream service. */\n\tpublic timestamp?: string;\n\t/** Indicates whether the failure originated from transport, gateway, or service handling. */\n\tpublic origin: ApiClientErrorOrigin;\n\t/** The fully qualified request URL, when available. */\n\tpublic url?: string;\n\t/** The response content type, when a response was received. */\n\tpublic contentType?: string;\n\t/** A truncated copy of the raw response body, when captured. */\n\tpublic bodyText?: string;\n\t/** The upstream request identifier, when available. */\n\tpublic requestId?: string;\n\t/** The HTTP status code reported by the service or gateway. */\n\tpublic statusCode: number;\n\t/** The underlying thrown error, if there was one. */\n\tpublic override cause?: unknown;\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: ApiClientErrorMetadata = { origin: \"service\" },\n\t) {\n\t\tsuper(payload.message);\n\t\tthis.name = new.target.name;\n\t\tthis.payload = payload;\n\t\tthis.statusCode = statusCode;\n\t\tthis.requestId = requestId;\n\t\tthis.code = payload.code;\n\t\tthis.details = payload.details;\n\t\tthis.path = payload.path;\n\t\tthis.timestamp = payload.timestamp;\n\t\tthis.origin = metadata.origin;\n\t\tthis.url = metadata.url;\n\t\tthis.contentType = metadata.contentType;\n\t\tthis.bodyText = metadata.bodyText;\n\t\tthis.cause = metadata.cause;\n\t}\n}\n\n/**\n * Error raised when the request fails before any HTTP response is available.\n */\nexport class ApiTransportError extends ApiClientError {\n\tpublic override payload: ApiClientErrorPayload;\n\tpublic override origin: \"transport\";\n\t/** Whether the failure was caused by an abort, timeout, or generic network problem. */\n\tpublic transportKind: ApiTransportKind;\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId: string | undefined,\n\t\tmetadata: ApiTransportErrorMetadata,\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"transport\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"transport\";\n\t\tthis.transportKind = metadata.transportKind;\n\t}\n}\n\n/**\n * Error raised when the request reached API Gateway but did not produce a\n * valid service-level error envelope.\n */\nexport class ApiGatewayError extends ApiClientError {\n\tpublic override payload: ApiClientErrorPayload;\n\tpublic override origin: \"gateway\";\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: Omit<ApiClientErrorMetadata, \"origin\"> = {},\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"gateway\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"gateway\";\n\t}\n}\n\n/**\n * Error raised when the root service returns a valid JSON API error envelope,\n * or when a successful response cannot be interpreted as the expected API\n * success envelope.\n */\nexport class ApiServiceError extends ApiClientError {\n\tpublic override payload: ApiErrorPayload;\n\tpublic override origin: \"service\";\n\n\tconstructor(\n\t\tpayload: ApiErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: Omit<ApiClientErrorMetadata, \"origin\"> = {},\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"service\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"service\";\n\t}\n}\n","import {\n\tApiGatewayError,\n\tApiServiceError,\n\tApiTransportError,\n\ttype ApiTransportKind,\n} from \"../errors\";\n\ntype GatewayErrorOptions = {\n\tcontentType?: string;\n\tbodyText?: string;\n\tdetails: string;\n\trequestId?: string;\n\tcause?: unknown;\n};\n\ntype UnexpectedServiceResponseOptions = GatewayErrorOptions;\n\n/**\n * Wraps a fetch failure that happened before any response was available.\n */\nexport function createTransportError(path: string, url: string, error: unknown): ApiTransportError {\n\tconst transportKind = classifyTransportFailure(error);\n\tconst message = describeTransportFailure(transportKind);\n\tconst causeDetails = getErrorDiagnosticMessage(error);\n\tconst details = causeDetails ? `${message} Cause: ${causeDetails}` : message;\n\n\treturn new ApiTransportError(\n\t\t{\n\t\t\tcode: \"API_TRANSPORT_ERROR\",\n\t\t\tmessage,\n\t\t\tdetails,\n\t\t\tpath,\n\t\t},\n\t\t0,\n\t\tundefined,\n\t\t{\n\t\t\ttransportKind,\n\t\t\turl,\n\t\t\tcause: error,\n\t\t},\n\t);\n}\n\n/**\n * Builds a gateway-origin client error after the caller has already decided the response does not\n * represent a validated service error envelope.\n */\nexport function createGatewayError(\n\tpath: string,\n\turl: string,\n\tstatusCode: number,\n\toptions: GatewayErrorOptions,\n): ApiGatewayError {\n\treturn new ApiGatewayError(\n\t\t{\n\t\t\tcode: \"API_GATEWAY_ERROR\",\n\t\t\tmessage: `The API gateway responded with status ${statusCode}.`,\n\t\t\tdetails: options.details,\n\t\t\tpath,\n\t\t},\n\t\tstatusCode,\n\t\toptions.requestId,\n\t\t{\n\t\t\turl,\n\t\t\tcontentType: options.contentType,\n\t\t\tbodyText: options.bodyText,\n\t\t\tcause: options.cause,\n\t\t},\n\t);\n}\n\n/**\n * Builds the fallback service error used when a 2xx response cannot be interpreted as the\n * expected Content Curation API success envelope.\n */\nexport function createUnexpectedServiceResponseError(\n\tpath: string,\n\turl: string,\n\toptions: UnexpectedServiceResponseOptions,\n): ApiServiceError {\n\treturn new ApiServiceError(\n\t\t{\n\t\t\tcode: \"INTERNAL_SERVER_ERROR\",\n\t\t\tmessage: \"Unexpected API response format\",\n\t\t\tdetails: options.details,\n\t\t\tpath,\n\t\t},\n\t\t500,\n\t\toptions.requestId,\n\t\t{\n\t\t\turl,\n\t\t\tcontentType: options.contentType,\n\t\t\tbodyText: options.bodyText,\n\t\t\tcause: options.cause,\n\t\t},\n\t);\n}\n\nfunction classifyTransportFailure(error: unknown): ApiTransportKind {\n\tconst errorName = readStringProperty(error, \"name\");\n\n\tif (errorName === \"AbortError\") {\n\t\treturn \"abort\";\n\t}\n\n\tif (errorName === \"TimeoutError\") {\n\t\treturn \"timeout\";\n\t}\n\n\tif (errorName === \"FetchError\" && readStringProperty(error, \"type\") === \"request-timeout\") {\n\t\treturn \"timeout\";\n\t}\n\n\treturn \"network\";\n}\n\nfunction describeTransportFailure(transportKind: ApiTransportKind): string {\n\tif (transportKind === \"abort\") {\n\t\treturn \"The request was aborted before a response was received.\";\n\t}\n\n\tif (transportKind === \"timeout\") {\n\t\treturn \"The request timed out before a response was received.\";\n\t}\n\n\treturn \"The request failed before a response was received.\";\n}\n\nfunction getErrorDiagnosticMessage(error: unknown): string | undefined {\n\tconst diagnosticParts = [\n\t\treadCauseCode(error),\n\t\treadStringProperty(error, \"name\"),\n\t\treadStringProperty(error, \"message\"),\n\t].filter(\n\t\t(value, index, values): value is string => Boolean(value) && values.indexOf(value) === index,\n\t);\n\n\treturn diagnosticParts.length > 0 ? diagnosticParts.join(\": \") : undefined;\n}\n\nfunction readCauseCode(error: unknown): string | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst directCode = readStringProperty(error, \"code\");\n\tif (directCode) {\n\t\treturn directCode;\n\t}\n\n\tconst cause = (error as { cause?: unknown }).cause;\n\treturn readStringProperty(cause, \"code\");\n}\n\nfunction readStringProperty(error: unknown, property: string): string | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst value = (error as Record<string, unknown>)[property];\n\treturn typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n","import { z, type ZodTypeAny } from \"zod\";\n\n/**\n * Strongly‐typed enum for all possible API error codes.\n */\nexport const ApiErrorCode = z.enum([\n\t\"UNAUTHORIZED\",\n\t\"NOT_FOUND\",\n\t\"INTERNAL_SERVER_ERROR\",\n\t\"INVALID_INPUT_DATA\",\n]);\n\n/**\n * Fields shared by both success and error envelopes (but not the discriminant).\n */\nconst BaseEnvelopeFields = z.object({\n\tstatusCode: z.number(),\n\trequestId: z.string(),\n});\n\n/**\n * Specific details carried in an error payload.\n */\nexport const ApiErrorPayloadSchema = z\n\t.object({\n\t\tcode: ApiErrorCode,\n\t\tmessage: z.string(),\n\t\tdetails: z.string().optional(),\n\t\tpath: z.string().optional(),\n\t\ttimestamp: z.string().optional(),\n\t})\n\t.strict();\n\nexport type ApiErrorPayload = z.infer<typeof ApiErrorPayloadSchema>;\n\n/**\n * Full “envelope” when the API has failed.\n */\nexport const ApiErrorResponseSchema = BaseEnvelopeFields.extend({\n\tstatus: z.literal(\"error\"),\n\terror: ApiErrorPayloadSchema,\n}).strict();\n\nexport type ApiErrorResponse = z.infer<typeof ApiErrorResponseSchema>;\n\n/**\n * Schema for a successful API response, given some data schema T.\n */\nexport function ApiSuccessResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\treturn BaseEnvelopeFields.extend({\n\t\tstatus: z.literal(\"success\"),\n\t\tdata: dataSchema,\n\t}).strict();\n}\n\n/**\n * Union of success or error envelopes, discriminated on `status`.\n */\nexport function ApiResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\tconst successSchema = ApiSuccessResponseSchema(dataSchema);\n\tconst errorSchema = ApiErrorResponseSchema;\n\treturn z.discriminatedUnion(\"status\", [successSchema, errorSchema]);\n}\n","import type { ZodTypeAny } from \"zod\";\nimport { ApiErrorResponseSchema, ApiResponseSchema } from \"../schemas/response\";\n\nconst GATEWAY_STATUS_CODES = new Set([499, 502, 503]);\nconst MAX_DIAGNOSTIC_BODY_LENGTH = 2000;\n\n/**\n * Captured information from a response body after the client has consumed it exactly once.\n */\nexport type ResponseBodyDiagnostics = {\n\tcontentType?: string;\n\tbodyText?: string;\n\tjson?: unknown;\n\tjsonParseError?: Error;\n};\n\n/**\n * Returns `true` when a status code should always be treated as an API Gateway failure.\n */\nexport function isGatewayStatusCode(statusCode: number): boolean {\n\treturn GATEWAY_STATUS_CODES.has(statusCode);\n}\n\n/**\n * Extracts the response content type, if one was provided.\n */\nexport function getResponseContentType(response: Response): string | undefined {\n\treturn response.headers?.get(\"content-type\") ?? undefined;\n}\n\n/**\n * Extracts the upstream request identifier, if one was provided.\n */\nexport function getResponseRequestId(response: Response): string | undefined {\n\treturn response.headers?.get(\"x-request-id\") ?? response.headers?.get(\"request-id\") ?? undefined;\n}\n\n/**\n * Reads a response body exactly once, truncates diagnostic text, and only parses JSON when the\n * declared content type says that is appropriate.\n */\nexport async function readResponseBody(response: Response): Promise<ResponseBodyDiagnostics> {\n\tconst contentType = getResponseContentType(response);\n\tlet rawBody = \"\";\n\n\ttry {\n\t\trawBody = await response.text();\n\t} catch (error) {\n\t\tawait discardResponseBody(response);\n\t\tthrow error;\n\t}\n\n\tconst bodyText = truncateBody(rawBody);\n\n\tif (!isJsonContentType(contentType) || rawBody.length === 0) {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t};\n\t}\n\n\ttry {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t\tjson: JSON.parse(rawBody),\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t\tjsonParseError: toError(error),\n\t\t};\n\t}\n}\n\n/**\n * Attempts to validate a consumed response body as a success-or-error API envelope.\n */\nexport function parseApiResponse<ResponseDataSchema extends ZodTypeAny>(\n\tresponseDataSchema: ResponseDataSchema,\n\tresponseBody: ResponseBodyDiagnostics,\n) {\n\tif (responseBody.json === undefined) {\n\t\treturn null;\n\t}\n\n\tconst parsedResponse = ApiResponseSchema(responseDataSchema).safeParse(responseBody.json);\n\treturn parsedResponse.success ? parsedResponse.data : null;\n}\n\n/**\n * Attempts to validate a consumed response body as a service-level error envelope.\n */\nexport function parseApiErrorResponse(responseBody: ResponseBodyDiagnostics) {\n\tif (responseBody.json === undefined) {\n\t\treturn null;\n\t}\n\n\tconst parsedError = ApiErrorResponseSchema.safeParse(responseBody.json);\n\treturn parsedError.success ? parsedError.data : null;\n}\n\n/**\n * Builds the diagnostic detail string used when a 2xx response cannot be understood as the\n * expected Content Curation API success envelope.\n */\nexport function describeUnexpectedSuccessResponse(responseBody: ResponseBodyDiagnostics): string {\n\tif (responseBody.jsonParseError) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t\"The service reported a JSON response but the body could not be parsed as JSON.\",\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\tif (!responseBody.contentType || !isJsonContentType(responseBody.contentType)) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t\"The service returned a success status without a JSON response body.\",\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\treturn buildDiagnosticDetails(\n\t\t\"The service returned JSON, but it did not match the expected Content Curation API envelope.\",\n\t\tresponseBody,\n\t);\n}\n\n/**\n * Builds the diagnostic detail string used when a non-success response should be treated as a\n * gateway-origin failure rather than a validated service error.\n */\nexport function describeGatewayResponse(\n\tstatusCode: number,\n\tresponseBody: ResponseBodyDiagnostics,\n): string {\n\tif (responseBody.jsonParseError) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t`The non-success response with status ${statusCode} declared a JSON content type, but its body could not be parsed as JSON.`,\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\tif (!responseBody.contentType || !isJsonContentType(responseBody.contentType)) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t`The non-success response with status ${statusCode} was not a valid service JSON error envelope.`,\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\treturn buildDiagnosticDetails(\n\t\t`The non-success response with status ${statusCode} returned JSON, but it did not match the service error envelope.`,\n\t\tresponseBody,\n\t);\n}\n\n/**\n * Best-effort response cleanup for the rare case where reading the body throws before completion.\n */\nasync function discardResponseBody(response: Response): Promise<void> {\n\tconst body = response.body as unknown;\n\tif (!body) {\n\t\treturn;\n\t}\n\n\tif (typeof (body as { cancel?: () => Promise<void> }).cancel === \"function\") {\n\t\ttry {\n\t\t\tawait (body as { cancel: () => Promise<void> }).cancel();\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// Best effort only.\n\t\t}\n\t}\n\n\tif (\n\t\ttypeof (body as { resume?: () => void }).resume === \"function\" &&\n\t\ttypeof (body as { on?: (event: string, handler: () => void) => void }).on === \"function\"\n\t) {\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst stream = body as {\n\t\t\t\tresume: () => void;\n\t\t\t\ton: (event: string, handler: () => void) => void;\n\t\t\t};\n\t\t\tconst finish = () => resolve();\n\t\t\tstream.on(\"end\", finish);\n\t\t\tstream.on(\"error\", finish);\n\t\t\tstream.resume();\n\t\t});\n\t}\n}\n\nfunction buildDiagnosticDetails(message: string, responseBody: ResponseBodyDiagnostics): string {\n\tconst detailParts = [message];\n\n\tif (responseBody.contentType) {\n\t\tdetailParts.push(`Content-Type: ${responseBody.contentType}.`);\n\t}\n\n\tif (responseBody.jsonParseError) {\n\t\tdetailParts.push(`JSON parse error: ${responseBody.jsonParseError.message}.`);\n\t}\n\n\tif (responseBody.bodyText) {\n\t\tdetailParts.push(\"The raw response body is available in bodyText.\");\n\t}\n\n\treturn detailParts.join(\" \");\n}\n\nfunction isJsonContentType(contentType?: string): boolean {\n\tif (!contentType) {\n\t\treturn false;\n\t}\n\n\tconst mimeType = contentType.split(\";\")[0]?.trim().toLowerCase();\n\tif (!mimeType) {\n\t\treturn false;\n\t}\n\n\treturn mimeType === \"application/json\" || mimeType.endsWith(\"+json\");\n}\n\nfunction truncateBody(bodyText: string): string | undefined {\n\tif (bodyText.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (bodyText.length <= MAX_DIAGNOSTIC_BODY_LENGTH) {\n\t\treturn bodyText;\n\t}\n\n\treturn `${bodyText.slice(0, MAX_DIAGNOSTIC_BODY_LENGTH - 3)}...`;\n}\n\nfunction toError(error: unknown): Error {\n\tif (error instanceof Error) {\n\t\treturn error;\n\t}\n\n\tconst message = typeof error === \"string\" && error.length > 0 ? error : \"Unknown error\";\n\treturn new Error(message);\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport type { ApiGatewayError } from \"../errors\";\nimport { ApiServiceError } from \"../errors\";\nimport { createGatewayError, createUnexpectedServiceResponseError } from \"./error-factories\";\nimport {\n\tdescribeGatewayResponse,\n\tdescribeUnexpectedSuccessResponse,\n\tgetResponseContentType,\n\tgetResponseRequestId,\n\tisGatewayStatusCode,\n\tparseApiErrorResponse,\n\tparseApiResponse,\n\treadResponseBody,\n\ttype ResponseBodyDiagnostics,\n} from \"./response-handling\";\n\n/**\n * Validates an outbound request body when the caller supplied a schema.\n *\n * Requests without a body, or without a schema, pass through unchanged.\n */\nexport function parseRequestBody<ReqSchema extends ZodTypeAny | undefined>(\n\trequestSchema: ReqSchema | undefined,\n\tbody: (ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown) | undefined,\n): (ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown) | undefined {\n\tif (!requestSchema || body === undefined) {\n\t\treturn body;\n\t}\n\n\treturn requestSchema.parse(body);\n}\n\n/**\n * Consumes the HTTP response body and converts body-read failures into the same\n * client error model used for normal gateway and service failures.\n */\nexport async function readApiResponseBody(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n): Promise<ResponseBodyDiagnostics> {\n\ttry {\n\t\treturn await readResponseBody(response);\n\t} catch (error) {\n\t\tif (response.ok) {\n\t\t\tthrow createUnexpectedServiceResponseError(path, url, {\n\t\t\t\tcontentType: getResponseContentType(response),\n\t\t\t\tcause: error,\n\t\t\t\tdetails: \"Failed to read the response body before the API response could be validated.\",\n\t\t\t\trequestId: getResponseRequestId(response),\n\t\t\t});\n\t\t}\n\n\t\tthrow createGatewayError(path, url, response.status, {\n\t\t\tcontentType: getResponseContentType(response),\n\t\t\tcause: error,\n\t\t\tdetails:\n\t\t\t\t\"Failed to read the non-success response body, so the response could not be validated as a service error.\",\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n}\n\n/**\n * Interprets a successful HTTP response as either a valid Content Curation API\n * success envelope or a service-origin failure.\n */\nexport function parseSuccessfulResponse<ResponseDataSchema extends ZodTypeAny>(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n\tresponseBody: ResponseBodyDiagnostics,\n\tresponseDataSchema: ResponseDataSchema,\n): z.infer<ResponseDataSchema> {\n\tconst parsedResponse = parseApiResponse(responseDataSchema, responseBody);\n\n\tif (!parsedResponse) {\n\t\tthrow createUnexpectedServiceResponseError(path, url, {\n\t\t\tcontentType: responseBody.contentType,\n\t\t\tbodyText: responseBody.bodyText,\n\t\t\tdetails: describeUnexpectedSuccessResponse(responseBody),\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n\n\tif (\"error\" in parsedResponse) {\n\t\tthrow new ApiServiceError(\n\t\t\tparsedResponse.error,\n\t\t\tparsedResponse.statusCode,\n\t\t\tparsedResponse.requestId,\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\tcontentType: responseBody.contentType,\n\t\t\t\tbodyText: responseBody.bodyText,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn parsedResponse.data;\n}\n\n/**\n * Classifies a non-success HTTP response as either a validated service error or\n * a gateway-origin failure.\n */\nexport function createResponseError(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n\tresponseBody: ResponseBodyDiagnostics,\n): ApiGatewayError | ApiServiceError {\n\tif (isGatewayStatusCode(response.status)) {\n\t\treturn createGatewayError(path, url, response.status, {\n\t\t\tcontentType: responseBody.contentType,\n\t\t\tbodyText: responseBody.bodyText,\n\t\t\tdetails: describeGatewayResponse(response.status, responseBody),\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n\n\tconst parsedServiceError = parseApiErrorResponse(responseBody);\n\tif (parsedServiceError) {\n\t\treturn new ApiServiceError(\n\t\t\tparsedServiceError.error,\n\t\t\tparsedServiceError.statusCode,\n\t\t\tparsedServiceError.requestId,\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\tcontentType: responseBody.contentType,\n\t\t\t\tbodyText: responseBody.bodyText,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn createGatewayError(path, url, response.status, {\n\t\tcontentType: responseBody.contentType,\n\t\tbodyText: responseBody.bodyText,\n\t\tdetails: describeGatewayResponse(response.status, responseBody),\n\t\trequestId: getResponseRequestId(response),\n\t});\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport {\n\tcreateResponseError,\n\tcreateTransportError,\n\tparseRequestBody,\n\tparseSuccessfulResponse,\n\treadApiResponseBody,\n} from \"./internal\";\n\n/**\n * Configuration options for the API client.\n */\nexport type ApiClientConfig =\n\t| {\n\t\t\t// Standard configuration.\n\t\t\t// Intended for external clients using an API key issued via API Gateway.\n\t\t\tbaseUrl: string;\n\t\t\tapiKey: string;\n\t\t\tapiToken?: never;\n\t\t\tfetch?: typeof fetch;\n\t }\n\t| {\n\t\t\t// Alternative configuration.\n\t\t\t// Reserved for clients with access to a bearer token (for example, e2e tests).\n\t\t\tbaseUrl: string;\n\t\t\tapiKey?: never;\n\t\t\tapiToken: string;\n\t\t\tfetch?: typeof fetch;\n\t };\n\n/**\n * Shared HTTP client for Content Curation API requests.\n *\n * The public sub-clients delegate to this class so request validation, fetch\n * execution, response parsing, and error classification all happen in one place.\n */\nexport class BaseApiClient {\n\tprotected config: ApiClientConfig;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\tfetch: config.fetch || fetch,\n\t\t};\n\t\tthis.config.baseUrl = trimTrailingSlashes(this.config.baseUrl);\n\t}\n\n\t/**\n\t * Performs a request against the JSON API, validates the response envelope,\n\t * and returns the typed `data` payload on success.\n\t */\n\tprotected async request<\n\t\tReqSchema extends ZodTypeAny | undefined,\n\t\tResponseDataSchema extends ZodTypeAny,\n\t>(\n\t\tmethod: \"GET\" | \"PUT\" | \"POST\" | \"DELETE\",\n\t\tpath: string,\n\t\topts: {\n\t\t\trequestSchema?: ReqSchema;\n\t\t\tbody?: ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown;\n\t\t\tresponseDataSchema: ResponseDataSchema;\n\t\t},\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\tconst bodyPayload = parseRequestBody(opts.requestSchema, opts.body);\n\t\tconst urlString = new URL(this.config.baseUrl + path).toString();\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await this.config.fetch!(urlString, {\n\t\t\t\tmethod,\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t...(this.config.apiKey\n\t\t\t\t\t\t? { \"x-api-key\": this.config.apiKey }\n\t\t\t\t\t\t: { Authorization: `Bearer ${this.config.apiToken}` }),\n\t\t\t\t},\n\t\t\t\tbody: bodyPayload === undefined ? undefined : JSON.stringify(bodyPayload),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow createTransportError(path, urlString, error);\n\t\t}\n\n\t\tconst responseBody = await readApiResponseBody(path, urlString, response);\n\n\t\tif (response.ok) {\n\t\t\treturn parseSuccessfulResponse(\n\t\t\t\tpath,\n\t\t\t\turlString,\n\t\t\t\tresponse,\n\t\t\t\tresponseBody,\n\t\t\t\topts.responseDataSchema,\n\t\t\t);\n\t\t}\n\n\t\tthrow createResponseError(path, urlString, response, responseBody);\n\t}\n\n\t/**\n\t * GET convenience method inferring response type from schema.\n\t */\n\tprotected get<ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"GET\", path, { responseDataSchema });\n\t}\n\n\t/**\n\t * PUT convenience method inferring both request and response types.\n\t */\n\tprotected put<ReqSchema extends ZodTypeAny, ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tbody: z.infer<ReqSchema>,\n\t\trequestSchema: ReqSchema,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"PUT\", path, { body, requestSchema, responseDataSchema });\n\t}\n}\n\nfunction trimTrailingSlashes(value: string): string {\n\tlet end = value.length;\n\n\twhile (end > 0 && value.charCodeAt(end - 1) === 47) {\n\t\tend -= 1;\n\t}\n\n\treturn end === value.length ? value : value.slice(0, end);\n}\n","import { z } from \"zod\";\n\n/**\n * -----------------------------------------\n * Legacy API Schemas & Types\n *\n * These schemas map to expected types for Hub Pages rendered by dotcom-pages.\n * -----------------------------------------\n */\n\nconst LegacyFlourishChildSchema = z.object({\n\tsource: z.literal(\"flourish\"),\n\tproperties: z.object({\n\t\tid: z.string().min(1), // e.g. \"visualisation/21901162\"\n\t}),\n});\n\nconst LegacyListChildSchema = z.object({\n\tsource: z.literal(\"list\"),\n\tproperties: z.object({\n\t\tid: z.string().uuid(),\n\t\tmaxItems: z.number().optional(),\n\t}),\n});\n\nconst LegacyContentChildSchema = z.object({\n\tsource: z.literal(\"content\"),\n\tproperties: z.object({\n\t\tids: z.array(z.string()).nonempty(),\n\t}),\n});\n\nconst LegacyContainerChildSchema = z.discriminatedUnion(\"source\", [\n\tLegacyFlourishChildSchema,\n\tLegacyListChildSchema,\n\tLegacyContentChildSchema,\n]);\n\nconst LegacyTopperSchema = z.object({\n\ttype: z.literal(\"topper-basic\"),\n\tproperties: z.object({\n\t\ttitle: z.string(),\n\t\tsponsorText: z.string().optional(),\n\t\tsponsorImage: z.string().url().optional(),\n\t}),\n});\n\nconst LegacyInfoBoxSchema = z.object({\n\ttype: z.literal(\"info-box\"),\n\tproperties: z.object({\n\t\tbodyHTML: z.string(),\n\t\ttitle: z.string().optional(),\n\t}),\n});\n\nconst LegacyContainerSchema = z.object({\n\ttype: z.literal(\"container\"),\n\tchildren: z.array(LegacyContainerChildSchema).min(1),\n\tproperties: z.object({\n\t\ttitle: z.string().optional(),\n\t\tdesign: z.enum([\"chart\", \"four-story\", \"freeform\", \"hero-lead\"]).default(\"freeform\"),\n\t\tbackgroundColor: z.string().optional(),\n\t}),\n});\n\nconst LegacyExperimentSchema = z.object({\n\ttype: z.literal(\"experiment\"),\n\tchildren: z.tuple([]),\n\tproperties: z.object({\n\t\texperimentName: z.string(),\n\t\tid: z.string(),\n\t\ttitle: z.string().optional(),\n\t\tconfig: z\n\t\t\t.object({\n\t\t\t\tvalue: z.unknown().optional(),\n\t\t\t\t// Hub pages support experiments with HTML and Text.\n\t\t\t\t// For now we just support JSON. As we migrate pages, this may change.\n\t\t\t\tformat: z.enum([\"json\"]).default(\"json\"),\n\t\t\t})\n\t\t\t.partial()\n\t\t\t.optional(),\n\t}),\n});\n\nconst LegacyBlockSchema = z.discriminatedUnion(\"type\", [\n\tLegacyTopperSchema,\n\tLegacyInfoBoxSchema,\n\tLegacyContainerSchema,\n\tLegacyExperimentSchema,\n]);\n\nexport const LegacyPageStructureOutputSchema = z.object({\n\tuuid: z.string().uuid(),\n\ttitle: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tthemeName: z.string().optional(),\n\tmetaDescription: z.string().optional(),\n\tblocks: z.array(LegacyBlockSchema),\n});\n\nexport type LegacyPageStructureOutput = z.infer<typeof LegacyPageStructureOutputSchema>;\nexport type LegacyBlock = z.infer<typeof LegacyBlockSchema>;\n","import { z } from \"zod\";\nimport { ProseMirrorDocSchema } from \"../../prosemirror\";\n\n//\n// 1) REUSABLE SCHEMAS FOR COMMON STRUCTURES\n//\n\n/**\n * A generic schema representing a heading used across various slices.\n * - `text`: The display text of the heading.\n * - `href`: An optional URL that the heading links to.\n */\nconst HeadingSchema = z.object({\n\ttext: z.string(),\n\thref: z.string().url().optional(),\n});\n\n/**\n * Base “properties” common to most page slices.\n * - `heading`: An optional heading object for slices that can display a title.\n */\nconst BasePageItemProps = z.object({\n\theading: HeadingSchema.optional(),\n});\n\n/**\n * A schema to validate that a string is valid JSON.\n */\nconst ValidJSONStringSchema = z.string().refine(\n\t(val) => {\n\t\ttry {\n\t\t\tJSON.parse(val);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\t{ message: \"Invalid JSON string\" },\n);\n\n//\n// 2) GENERIC HELPER TO DEFINE “SLICE” INPUT/OUTPUT SCHEMAS\n//\n\n/**\n * A union type to represent either a Zod object schema or an optional Zod object schema.\n */\ntype OptionalOrRequiredZodObject = z.AnyZodObject | z.ZodOptional<z.AnyZodObject>;\n\n/**\n * Helper function that, given:\n * - `typeName`: A string literal identifying the slice type.\n * - `propsShape`: A Zod schema describing the slice’s `properties`.\n *\n * Returns an object containing two schemas:\n * - `InputSchema`: For client-side input; `sliceId` is optional.\n * - `OutputSchema`: For server-side/output; `sliceId` is required.\n *\n * This is useful because when defining slices we often want to allow -\n * clients to submit slices without an ID (e.g., when creating new slices),\n */\nfunction defineSliceSchema<T extends string, P extends OptionalOrRequiredZodObject>(options: {\n\ttypeName: T;\n\tpropsShape: P;\n}) {\n\tconst { typeName, propsShape } = options;\n\n\t// Base schema shared by both input and output:\n\t// - `type`: Literal string identifying which slice this is.\n\t// - `hidden`: Optional flag to mark the slice as hidden.\n\t// - `properties`: The detailed properties shape for the slice.\n\tconst BaseSchema = z.object({\n\t\ttype: z.literal(typeName),\n\t\thidden: z.boolean().optional(),\n\t\tproperties: propsShape,\n\t});\n\n\t/**\n\t * Input schema: For client submissions.\n\t * - `sliceId` is optional because the client might not specify it yet.\n\t */\n\tconst InputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid().optional(),\n\t});\n\n\t/**\n\t * Output schema: For persisted or server-returned data.\n\t * - `sliceId` is required (each saved slice must have an ID).\n\t */\n\tconst OutputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid(),\n\t});\n\n\treturn { InputSchema, OutputSchema };\n}\n\n//\n// 3) DEFINE INDIVIDUAL SLICE TYPES (INPUT & OUTPUT) USING THE HELPER\n//\n\n// 3.A “InteractiveSlice”\n// - A slice to embed or reference a Flourish graphic by its ID.\n// - Extends graphic base properties with `flourishId` and `flourishAltText`, with optional 'theme', 'flourishDescription' or 'storyUUID'.\nconst InteractiveSlice = defineSliceSchema({\n\ttypeName: \"Interactive\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tflourishDescription: z.string().optional(), // Optional description for the Flourish graphic\n\t\tflourishId: z.string().nonempty(),\n\t\tflourishAltText: z.string().nonempty(),\n\t\tstoryUUID: z.string().uuid().optional(),\n\t\ttheme: z.string().optional(),\n\t}),\n});\n\n// 3.B “ExperimentSlice”\n// - A slice for embedding experimental content.\n// - Requires an `experimentId`, `experimentName`, and a JSON string (`contentJson`).\nconst ExperimentSlice = defineSliceSchema({\n\ttypeName: \"Experiment\",\n\tpropsShape: BasePageItemProps.extend({\n\t\texperimentId: z.string().nonempty(), // Unique ID for the experiment\n\t\texperimentName: z.string().nonempty(), // Human-readable name of the experiment\n\t\tcontentJson: ValidJSONStringSchema, // The experiment’s JSON payload as a valid JSON string\n\t}),\n});\n\n// 3.C \"Strip\"\n// - A slice that displays a strip of content.\nconst StripSlice = defineSliceSchema({\n\ttypeName: \"Strip\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the strip to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the strip\n\t}),\n});\n\n// 3.D \"TopperSlice\"\n// - A slice that displays a topper section with description and optional strapline.\nconst TopperSlice = defineSliceSchema({\n\ttypeName: \"Topper\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tdescription: ProseMirrorDocSchema,\n\t\tstrapline: z.string().optional(),\n\t}),\n});\n\n// 3.E \"Hero\"\n// - A slice that represents a Hero on the page. It references a Spark List.\nconst HeroSlice = defineSliceSchema({\n\ttypeName: \"Hero\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the spark list to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the hero\n\t}),\n});\n\n// 3.G \"StoryGroup\"\n// - A slice that stores an ordered list of manually curated content ids.\nconst StoryGroupSlice = defineSliceSchema({\n\ttypeName: \"StoryGroup\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tstorySlots: z.array(z.string().uuid()).nonempty(),\n\t}),\n});\n\n//\n// 4) COMPOSE DISCRIMINATED UNIONS FOR “SLICE API” INPUT & OUTPUT\n//\n\n/**\n * All possible slice inputs for the Page API.\n * This discriminated union allows Zod to pick the correct schema based on the `type` field.\n */\nexport const SliceApiInputSchema = z.discriminatedUnion(\"type\", [\n\tInteractiveSlice.InputSchema,\n\tExperimentSlice.InputSchema,\n\tStripSlice.InputSchema,\n\tTopperSlice.InputSchema,\n\tHeroSlice.InputSchema,\n\tStoryGroupSlice.InputSchema,\n] as const);\n\n/**\n * All possible slice outputs for the Page API.\n * The same discriminated union but with each slice requiring `sliceId`.\n */\nexport const SliceApiOutputSchema = z.discriminatedUnion(\"type\", [\n\tInteractiveSlice.OutputSchema,\n\tExperimentSlice.OutputSchema,\n\tStripSlice.OutputSchema,\n\tTopperSlice.OutputSchema,\n\tHeroSlice.OutputSchema,\n\tStoryGroupSlice.OutputSchema,\n] as const);\n\n//\n// 5) WRAPPER SCHEMAS FOR THE ENTIRE PAGE STRUCTURE\n//\n\nconst BasePagePropertiesSchema = z.object({\n\ttitle: z.string(),\n\tpageId: z.string().uuid(),\n\tpublicationId: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tmetaDescription: z.string().optional(),\n\tpageTheme: z.string().optional(),\n\tsponsorText: z.string().optional(),\n\tsponsorImage: z.string().url().optional(),\n});\n\n/**\n * Page structure as submitted by clients.\n * - `properties`: Metadata about the page\n * - `children`: Array of slice inputs (each with an optional `sliceId`).\n */\nexport const PageStructureInputSchema = z.object({\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiInputSchema),\n});\n\n/**\n * Page structure as stored or returned by the server.\n */\nexport const PageStructureOutputSchema = z.object({\n\ttype: z.literal(\"Page\"),\n\tschemaVersion: z.number(),\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiOutputSchema),\n});\n\n//\n// 6) EXPORT TYPES FOR CONSUMPTION IN CODE\n//\n\n/** Client-side type for page structure input */\nexport type PageStructureInput = z.infer<typeof PageStructureInputSchema>;\n\n/** Server-side type for page structure output */\nexport type PageStructureOutput = z.infer<typeof PageStructureOutputSchema>;\n\n/** Union of all possible slice outputs for type-checking convenience */\nexport type Slice = z.infer<typeof SliceApiOutputSchema>;\n\n/** Individual slice output types */\nexport type InteractiveSliceType = z.infer<typeof InteractiveSlice.OutputSchema>;\nexport type ExperimentSliceType = z.infer<typeof ExperimentSlice.OutputSchema>;\nexport type StripSliceType = z.infer<typeof StripSlice.OutputSchema>;\nexport type TopperSliceType = z.infer<typeof TopperSlice.OutputSchema>;\nexport type HeroSliceType = z.infer<typeof HeroSlice.OutputSchema>;\nexport type StoryGroupSliceType = z.infer<typeof StoryGroupSlice.OutputSchema>;\n","import { z } from \"zod\";\n\n/** Accept http(s) and mailto: (matches your editor config) */\nconst HrefSchema = z.string().refine((v) => /^(https?:\\/\\/|mailto:).+/.test(v), {\n\tmessage: \"Expected http(s):// or mailto: URL\",\n});\n\n/** Link mark. */\nconst ProseMirrorLinkMark = z.object({\n\ttype: z.literal(\"link\"),\n\tattrs: z.object({\n\t\thref: HrefSchema,\n\t}),\n});\n\n/** Supported text marks */\nconst ProseMirrorMark = z.discriminatedUnion(\"type\", [\n\tProseMirrorLinkMark,\n\tz.object({ type: z.literal(\"bold\") }),\n\tz.object({ type: z.literal(\"italic\") }),\n\tz.object({ type: z.literal(\"underline\") }),\n\tz.object({ type: z.literal(\"strike\") }),\n]);\n\n/** Text node */\nconst ProseMirrorTextNode = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tmarks: z.array(ProseMirrorMark).optional(),\n});\n\n/** Paragraph node — content can be empty/omitted */\nconst ProseMirrorParagraphNode = z.object({\n\ttype: z.literal(\"paragraph\"),\n\tcontent: z.array(ProseMirrorTextNode),\n});\n\n/** ProseMirror Node Union. */\nconst ProseMirrorNode = z.union([ProseMirrorParagraphNode, ProseMirrorTextNode]);\n\n/** Root node of a ProseMirror document - enforcing at least 1 paragraph */\nexport const ProseMirrorDocSchema = z.object({\n\ttype: z.literal(\"doc\"),\n\tcontent: z\n\t\t.array(ProseMirrorNode)\n\t\t.min(1, { message: \"Document must contain at least one paragraph\" }),\n});\n\n/** Rich text editor TS type. */\nexport type RichTextEditorType = z.infer<typeof ProseMirrorDocSchema>;\n\nexport {};\n","import { z } from \"zod\";\nimport { PageStructureInputSchema, PageStructureOutputSchema } from \"../page\";\n\nexport const DraftContributorInputSchema = z.object({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\temail: z.string().email().optional(),\n});\n\nexport const DraftContributorSchema = DraftContributorInputSchema.extend({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\tfirstTouchedAt: z.string().datetime(),\n\tlastTouchedAt: z.string().datetime(),\n});\n\nconst DraftMetadataSchema = z.object({\n\tdraftId: z.string().uuid(),\n\tcreatedAt: z.string().datetime(),\n\tupdatedAt: z.string().datetime(),\n\tcontributors: z.array(DraftContributorSchema),\n});\n\nexport const PageDraftSchema = DraftMetadataSchema.extend({\n\tstructure: PageStructureOutputSchema,\n});\n\nexport const DraftSchema = PageDraftSchema;\n\nexport const PersistPageDraftInputSchema = z.object({\n\tstructure: PageStructureInputSchema,\n\tcontributor: DraftContributorInputSchema,\n});\n\nexport type DraftContributorInput = z.infer<typeof DraftContributorInputSchema>;\nexport type DraftContributor = z.infer<typeof DraftContributorSchema>;\nexport type PageDraft = z.infer<typeof PageDraftSchema>;\nexport type Draft = z.infer<typeof DraftSchema>;\nexport type PersistPageDraftInput = z.infer<typeof PersistPageDraftInputSchema>;\n","import { BaseApiClient } from \"./base\";\nimport { ApiServiceError } from \"./errors\";\nimport type { LegacyPageStructureOutput } from \"./schemas/ftpink/legacyHubPage\";\nimport { LegacyPageStructureOutputSchema } from \"./schemas/ftpink/legacyHubPage\";\nimport {\n\tPageStructureInputSchema,\n\tPageStructureOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\n/**\n * Client for Page structure endpoints\n */\nexport class PageClient extends BaseApiClient {\n\tasync getStructure(pageId: string): Promise<PageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/structure`, PageStructureOutputSchema);\n\t}\n\n\tasync getDraft(pageId: string): Promise<PageDraft | null> {\n\t\ttry {\n\t\t\treturn await this.get(`/v1/page/${pageId}/draft`, PageDraftSchema);\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiServiceError && error.code === \"NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync getLegacyHubPageStructure(pageId: string): Promise<LegacyPageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/legacyHubPageStructure`, LegacyPageStructureOutputSchema);\n\t}\n\n\tasync upsertStructure(\n\t\tpageId: string,\n\t\tdata: Omit<PageStructureInput, \"type\">,\n\t): Promise<PageStructureOutput> {\n\t\treturn this.put(\n\t\t\t`/v1/page/${pageId}/structure`,\n\t\t\tdata,\n\t\t\tPageStructureInputSchema,\n\t\t\tPageStructureOutputSchema,\n\t\t);\n\t}\n}\n","import type { ApiClientConfig } from \"./base\";\nimport { BaseApiClient } from \"./base\";\nimport { PageClient } from \"./page\";\n\n/**\n * Main API client that provides access to all API endpoints\n */\nexport class ApiClient extends BaseApiClient {\n\tpage: PageClient;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tsuper(config);\n\n\t\t// Initialize sub-client\n\t\tthis.page = new PageClient(config);\n\t}\n}\n"],"mappings":";AA4CO,IAAM,iBAAN,cAA6B,MAAM;AAAA;AAAA,EAElC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAES;AAAA,EAEhB,YACC,SACA,YACA,WACA,WA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EAC7C,MAAM,aAAa,QAA8C;AAChE,WAAO,KAAK,IAAI,YAAY,MAAM,cAAc,yBAAyB;AAAA,EAC1E;AAAA,EAEA,MAAM,SAAS,QAA2C;AACzD,QAAI;AACH,aAAO,MAAM,KAAK,IAAI,YAAY,MAAM,UAAU,eAAe;AAAA,IAClE,SAAS,OAAO;AACf,UAAI,iBAAiB,mBAAmB,MAAM,SAAS,aAAa;AACnE,eAAO;AAAA,MACR;AACA,YAAM;AAAA,IACP;AAAA,EACD;AAAA,EAEA,MAAM,0BAA0B,QAAoD;AACnF,WAAO,KAAK,IAAI,YAAY,MAAM,2BAA2B,+BAA+B;AAAA,EAC7F;AAAA,EAEA,MAAM,gBACL,QACA,MAC+B;AAC/B,WAAO,KAAK;AAAA,MACX,YAAY,MAAM;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;;;ACvCO,IAAM,YAAN,cAAwB,cAAc;AAAA,EAC5C;AAAA,EAEA,YAAY,QAAyB;AACpC,UAAM,MAAM;AAGZ,SAAK,OAAO,IAAI,WAAW,MAAM;AAAA,EAClC;AACD;","names":["z","z","z","z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/internal/error-factories.ts","../src/schemas/response.ts","../src/internal/response-handling.ts","../src/internal/request-lifecycle.ts","../src/base.ts","../src/schemas/ftpink/legacyHubPage/index.ts","../src/schemas/ftpink/page/index.ts","../src/schemas/prosemirror.ts","../src/schemas/ftpink/draft/index.ts","../src/page.ts","../src/client.ts"],"sourcesContent":["import type { ApiErrorPayload } from \"./schemas/response\";\n\n/** Where the failing request broke down. */\nexport type ApiClientErrorOrigin = \"transport\" | \"gateway\" | \"service\";\n\n/** The transport failure mode when no HTTP response was received. */\nexport type ApiTransportKind = \"abort\" | \"timeout\" | \"network\";\n\n/** Machine-readable codes exposed by the client error model. */\nexport type ApiClientErrorCode =\n\t| ApiErrorPayload[\"code\"]\n\t| \"API_GATEWAY_ERROR\"\n\t| \"API_TRANSPORT_ERROR\";\n\n/**\n * Shared error payload shape used by all client-generated errors.\n *\n * Service-origin errors use the validated `ApiErrorPayload` returned by the API.\n * Gateway and transport errors synthesize the same top-level fields so callers\n * can handle them consistently.\n */\nexport type ApiClientErrorPayload = {\n\tcode: ApiClientErrorCode;\n\tmessage: string;\n\tdetails?: string;\n\tpath?: string;\n\ttimestamp?: string;\n};\n\ntype ApiClientErrorMetadata = {\n\torigin: ApiClientErrorOrigin;\n\turl?: string;\n\tcontentType?: string;\n\tbodyText?: string;\n\tcause?: unknown;\n};\n\ntype ApiTransportErrorMetadata = Omit<ApiClientErrorMetadata, \"origin\"> & {\n\ttransportKind: ApiTransportKind;\n};\n\n/**\n * Base error type for all failures surfaced by the client package.\n */\nexport class ApiClientError extends Error {\n\t/** The machine-readable error payload exposed by the client. */\n\tpublic payload: ApiClientErrorPayload;\n\t/** The machine-readable error code. */\n\tpublic code: ApiClientErrorPayload[\"code\"];\n\t/** Additional diagnostic detail captured by the client. */\n\tpublic details?: string;\n\t/** The API path associated with the failing request. */\n\tpublic path?: string;\n\t/** Optional timestamp supplied by the upstream service. */\n\tpublic timestamp?: string;\n\t/** Indicates whether the failure originated from transport, gateway, or service handling. */\n\tpublic origin: ApiClientErrorOrigin;\n\t/** The fully qualified request URL, when available. */\n\tpublic url?: string;\n\t/** The response content type, when a response was received. */\n\tpublic contentType?: string;\n\t/** A truncated copy of the raw response body, when captured. */\n\tpublic bodyText?: string;\n\t/** The upstream request identifier, when available. */\n\tpublic requestId?: string;\n\t/** The HTTP status code reported by the service or gateway. */\n\tpublic statusCode: number;\n\t/** The underlying thrown error, if there was one. */\n\tpublic override cause?: unknown;\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: ApiClientErrorMetadata = { origin: \"service\" },\n\t) {\n\t\tsuper(payload.message);\n\t\tthis.name = new.target.name;\n\t\tthis.payload = payload;\n\t\tthis.statusCode = statusCode;\n\t\tthis.requestId = requestId;\n\t\tthis.code = payload.code;\n\t\tthis.details = payload.details;\n\t\tthis.path = payload.path;\n\t\tthis.timestamp = payload.timestamp;\n\t\tthis.origin = metadata.origin;\n\t\tthis.url = metadata.url;\n\t\tthis.contentType = metadata.contentType;\n\t\tthis.bodyText = metadata.bodyText;\n\t\tthis.cause = metadata.cause;\n\t}\n}\n\n/**\n * Error raised when the request fails before any HTTP response is available.\n */\nexport class ApiTransportError extends ApiClientError {\n\tpublic override payload: ApiClientErrorPayload;\n\tpublic override origin: \"transport\";\n\t/** Whether the failure was caused by an abort, timeout, or generic network problem. */\n\tpublic transportKind: ApiTransportKind;\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId: string | undefined,\n\t\tmetadata: ApiTransportErrorMetadata,\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"transport\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"transport\";\n\t\tthis.transportKind = metadata.transportKind;\n\t}\n}\n\n/**\n * Error raised when the request reached API Gateway but did not produce a\n * valid service-level error envelope.\n */\nexport class ApiGatewayError extends ApiClientError {\n\tpublic override payload: ApiClientErrorPayload;\n\tpublic override origin: \"gateway\";\n\n\tconstructor(\n\t\tpayload: ApiClientErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: Omit<ApiClientErrorMetadata, \"origin\"> = {},\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"gateway\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"gateway\";\n\t}\n}\n\n/**\n * Error raised when the root service returns a valid JSON API error envelope,\n * or when a successful response cannot be interpreted as the expected API\n * success envelope.\n */\nexport class ApiServiceError extends ApiClientError {\n\tpublic override payload: ApiErrorPayload;\n\tpublic override origin: \"service\";\n\n\tconstructor(\n\t\tpayload: ApiErrorPayload,\n\t\tstatusCode: number,\n\t\trequestId?: string,\n\t\tmetadata: Omit<ApiClientErrorMetadata, \"origin\"> = {},\n\t) {\n\t\tsuper(payload, statusCode, requestId, {\n\t\t\t...metadata,\n\t\t\torigin: \"service\",\n\t\t});\n\t\tthis.payload = payload;\n\t\tthis.origin = \"service\";\n\t}\n}\n","import {\n\tApiGatewayError,\n\tApiServiceError,\n\tApiTransportError,\n\ttype ApiTransportKind,\n} from \"../errors\";\n\ntype GatewayErrorOptions = {\n\tcontentType?: string;\n\tbodyText?: string;\n\tdetails: string;\n\trequestId?: string;\n\tcause?: unknown;\n};\n\ntype UnexpectedServiceResponseOptions = GatewayErrorOptions;\n\n/**\n * Wraps a fetch failure that happened before any response was available.\n */\nexport function createTransportError(path: string, url: string, error: unknown): ApiTransportError {\n\tconst transportKind = classifyTransportFailure(error);\n\tconst message = describeTransportFailure(transportKind);\n\tconst causeDetails = getErrorDiagnosticMessage(error);\n\tconst details = causeDetails ? `${message} Cause: ${causeDetails}` : message;\n\n\treturn new ApiTransportError(\n\t\t{\n\t\t\tcode: \"API_TRANSPORT_ERROR\",\n\t\t\tmessage,\n\t\t\tdetails,\n\t\t\tpath,\n\t\t},\n\t\t0,\n\t\tundefined,\n\t\t{\n\t\t\ttransportKind,\n\t\t\turl,\n\t\t\tcause: error,\n\t\t},\n\t);\n}\n\n/**\n * Builds a gateway-origin client error after the caller has already decided the response does not\n * represent a validated service error envelope.\n */\nexport function createGatewayError(\n\tpath: string,\n\turl: string,\n\tstatusCode: number,\n\toptions: GatewayErrorOptions,\n): ApiGatewayError {\n\treturn new ApiGatewayError(\n\t\t{\n\t\t\tcode: \"API_GATEWAY_ERROR\",\n\t\t\tmessage: `The API gateway responded with status ${statusCode}.`,\n\t\t\tdetails: options.details,\n\t\t\tpath,\n\t\t},\n\t\tstatusCode,\n\t\toptions.requestId,\n\t\t{\n\t\t\turl,\n\t\t\tcontentType: options.contentType,\n\t\t\tbodyText: options.bodyText,\n\t\t\tcause: options.cause,\n\t\t},\n\t);\n}\n\n/**\n * Builds the fallback service error used when a 2xx response cannot be interpreted as the\n * expected Content Curation API success envelope.\n */\nexport function createUnexpectedServiceResponseError(\n\tpath: string,\n\turl: string,\n\toptions: UnexpectedServiceResponseOptions,\n): ApiServiceError {\n\treturn new ApiServiceError(\n\t\t{\n\t\t\tcode: \"INTERNAL_SERVER_ERROR\",\n\t\t\tmessage: \"Unexpected API response format\",\n\t\t\tdetails: options.details,\n\t\t\tpath,\n\t\t},\n\t\t500,\n\t\toptions.requestId,\n\t\t{\n\t\t\turl,\n\t\t\tcontentType: options.contentType,\n\t\t\tbodyText: options.bodyText,\n\t\t\tcause: options.cause,\n\t\t},\n\t);\n}\n\nfunction classifyTransportFailure(error: unknown): ApiTransportKind {\n\tconst errorName = readStringProperty(error, \"name\");\n\n\tif (errorName === \"AbortError\") {\n\t\treturn \"abort\";\n\t}\n\n\tif (errorName === \"TimeoutError\") {\n\t\treturn \"timeout\";\n\t}\n\n\tif (errorName === \"FetchError\" && readStringProperty(error, \"type\") === \"request-timeout\") {\n\t\treturn \"timeout\";\n\t}\n\n\treturn \"network\";\n}\n\nfunction describeTransportFailure(transportKind: ApiTransportKind): string {\n\tif (transportKind === \"abort\") {\n\t\treturn \"The request was aborted before a response was received.\";\n\t}\n\n\tif (transportKind === \"timeout\") {\n\t\treturn \"The request timed out before a response was received.\";\n\t}\n\n\treturn \"The request failed before a response was received.\";\n}\n\nfunction getErrorDiagnosticMessage(error: unknown): string | undefined {\n\tconst diagnosticParts = [\n\t\treadCauseCode(error),\n\t\treadStringProperty(error, \"name\"),\n\t\treadStringProperty(error, \"message\"),\n\t].filter(\n\t\t(value, index, values): value is string => Boolean(value) && values.indexOf(value) === index,\n\t);\n\n\treturn diagnosticParts.length > 0 ? diagnosticParts.join(\": \") : undefined;\n}\n\nfunction readCauseCode(error: unknown): string | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst directCode = readStringProperty(error, \"code\");\n\tif (directCode) {\n\t\treturn directCode;\n\t}\n\n\tconst cause = (error as { cause?: unknown }).cause;\n\treturn readStringProperty(cause, \"code\");\n}\n\nfunction readStringProperty(error: unknown, property: string): string | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst value = (error as Record<string, unknown>)[property];\n\treturn typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n","import { z, type ZodTypeAny } from \"zod\";\n\n/**\n * Strongly‐typed enum for all possible API error codes.\n */\nexport const ApiErrorCode = z.enum([\n\t\"UNAUTHORIZED\",\n\t\"NOT_FOUND\",\n\t\"INTERNAL_SERVER_ERROR\",\n\t\"INVALID_INPUT_DATA\",\n]);\n\n/**\n * Fields shared by both success and error envelopes (but not the discriminant).\n */\nconst BaseEnvelopeFields = z.object({\n\tstatusCode: z.number(),\n\trequestId: z.string(),\n});\n\n/**\n * Specific details carried in an error payload.\n */\nexport const ApiErrorPayloadSchema = z\n\t.object({\n\t\tcode: ApiErrorCode,\n\t\tmessage: z.string(),\n\t\tdetails: z.string().optional(),\n\t\tpath: z.string().optional(),\n\t\ttimestamp: z.string().optional(),\n\t})\n\t.strict();\n\nexport type ApiErrorPayload = z.infer<typeof ApiErrorPayloadSchema>;\n\n/**\n * Full “envelope” when the API has failed.\n */\nexport const ApiErrorResponseSchema = BaseEnvelopeFields.extend({\n\tstatus: z.literal(\"error\"),\n\terror: ApiErrorPayloadSchema,\n}).strict();\n\nexport type ApiErrorResponse = z.infer<typeof ApiErrorResponseSchema>;\n\n/**\n * Schema for a successful API response, given some data schema T.\n */\nexport function ApiSuccessResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\treturn BaseEnvelopeFields.extend({\n\t\tstatus: z.literal(\"success\"),\n\t\tdata: dataSchema,\n\t}).strict();\n}\n\n/**\n * Union of success or error envelopes, discriminated on `status`.\n */\nexport function ApiResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\tconst successSchema = ApiSuccessResponseSchema(dataSchema);\n\tconst errorSchema = ApiErrorResponseSchema;\n\treturn z.discriminatedUnion(\"status\", [successSchema, errorSchema]);\n}\n","import type { ZodTypeAny } from \"zod\";\nimport { ApiErrorResponseSchema, ApiResponseSchema } from \"../schemas/response\";\n\nconst GATEWAY_STATUS_CODES = new Set([499, 502, 503]);\nconst MAX_DIAGNOSTIC_BODY_LENGTH = 2000;\n\n/**\n * Captured information from a response body after the client has consumed it exactly once.\n */\nexport type ResponseBodyDiagnostics = {\n\tcontentType?: string;\n\tbodyText?: string;\n\tjson?: unknown;\n\tjsonParseError?: Error;\n};\n\n/**\n * Returns `true` when a status code should always be treated as an API Gateway failure.\n */\nexport function isGatewayStatusCode(statusCode: number): boolean {\n\treturn GATEWAY_STATUS_CODES.has(statusCode);\n}\n\n/**\n * Extracts the response content type, if one was provided.\n */\nexport function getResponseContentType(response: Response): string | undefined {\n\treturn response.headers?.get(\"content-type\") ?? undefined;\n}\n\n/**\n * Extracts the upstream request identifier, if one was provided.\n */\nexport function getResponseRequestId(response: Response): string | undefined {\n\treturn response.headers?.get(\"x-request-id\") ?? response.headers?.get(\"request-id\") ?? undefined;\n}\n\n/**\n * Reads a response body exactly once, truncates diagnostic text, and only parses JSON when the\n * declared content type says that is appropriate.\n */\nexport async function readResponseBody(response: Response): Promise<ResponseBodyDiagnostics> {\n\tconst contentType = getResponseContentType(response);\n\tlet rawBody = \"\";\n\n\ttry {\n\t\trawBody = await response.text();\n\t} catch (error) {\n\t\tawait discardResponseBody(response);\n\t\tthrow error;\n\t}\n\n\tconst bodyText = truncateBody(rawBody);\n\n\tif (!isJsonContentType(contentType) || rawBody.length === 0) {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t};\n\t}\n\n\ttry {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t\tjson: JSON.parse(rawBody),\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tcontentType,\n\t\t\tbodyText,\n\t\t\tjsonParseError: toError(error),\n\t\t};\n\t}\n}\n\n/**\n * Attempts to validate a consumed response body as a success-or-error API envelope.\n */\nexport function parseApiResponse<ResponseDataSchema extends ZodTypeAny>(\n\tresponseDataSchema: ResponseDataSchema,\n\tresponseBody: ResponseBodyDiagnostics,\n) {\n\tif (responseBody.json === undefined) {\n\t\treturn null;\n\t}\n\n\tconst parsedResponse = ApiResponseSchema(responseDataSchema).safeParse(responseBody.json);\n\treturn parsedResponse.success ? parsedResponse.data : null;\n}\n\n/**\n * Attempts to validate a consumed response body as a service-level error envelope.\n */\nexport function parseApiErrorResponse(responseBody: ResponseBodyDiagnostics) {\n\tif (responseBody.json === undefined) {\n\t\treturn null;\n\t}\n\n\tconst parsedError = ApiErrorResponseSchema.safeParse(responseBody.json);\n\treturn parsedError.success ? parsedError.data : null;\n}\n\n/**\n * Builds the diagnostic detail string used when a 2xx response cannot be understood as the\n * expected Content Curation API success envelope.\n */\nexport function describeUnexpectedSuccessResponse(responseBody: ResponseBodyDiagnostics): string {\n\tif (responseBody.jsonParseError) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t\"The service reported a JSON response but the body could not be parsed as JSON.\",\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\tif (!responseBody.contentType || !isJsonContentType(responseBody.contentType)) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t\"The service returned a success status without a JSON response body.\",\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\treturn buildDiagnosticDetails(\n\t\t\"The service returned JSON, but it did not match the expected Content Curation API envelope.\",\n\t\tresponseBody,\n\t);\n}\n\n/**\n * Builds the diagnostic detail string used when a non-success response should be treated as a\n * gateway-origin failure rather than a validated service error.\n */\nexport function describeGatewayResponse(\n\tstatusCode: number,\n\tresponseBody: ResponseBodyDiagnostics,\n): string {\n\tif (responseBody.jsonParseError) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t`The non-success response with status ${statusCode} declared a JSON content type, but its body could not be parsed as JSON.`,\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\tif (!responseBody.contentType || !isJsonContentType(responseBody.contentType)) {\n\t\treturn buildDiagnosticDetails(\n\t\t\t`The non-success response with status ${statusCode} was not a valid service JSON error envelope.`,\n\t\t\tresponseBody,\n\t\t);\n\t}\n\n\treturn buildDiagnosticDetails(\n\t\t`The non-success response with status ${statusCode} returned JSON, but it did not match the service error envelope.`,\n\t\tresponseBody,\n\t);\n}\n\n/**\n * Best-effort response cleanup for the rare case where reading the body throws before completion.\n */\nasync function discardResponseBody(response: Response): Promise<void> {\n\tconst body = response.body as unknown;\n\tif (!body) {\n\t\treturn;\n\t}\n\n\tif (typeof (body as { cancel?: () => Promise<void> }).cancel === \"function\") {\n\t\ttry {\n\t\t\tawait (body as { cancel: () => Promise<void> }).cancel();\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// Best effort only.\n\t\t}\n\t}\n\n\tif (\n\t\ttypeof (body as { resume?: () => void }).resume === \"function\" &&\n\t\ttypeof (body as { on?: (event: string, handler: () => void) => void }).on === \"function\"\n\t) {\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst stream = body as {\n\t\t\t\tresume: () => void;\n\t\t\t\ton: (event: string, handler: () => void) => void;\n\t\t\t};\n\t\t\tconst finish = () => resolve();\n\t\t\tstream.on(\"end\", finish);\n\t\t\tstream.on(\"error\", finish);\n\t\t\tstream.resume();\n\t\t});\n\t}\n}\n\nfunction buildDiagnosticDetails(message: string, responseBody: ResponseBodyDiagnostics): string {\n\tconst detailParts = [message];\n\n\tif (responseBody.contentType) {\n\t\tdetailParts.push(`Content-Type: ${responseBody.contentType}.`);\n\t}\n\n\tif (responseBody.jsonParseError) {\n\t\tdetailParts.push(`JSON parse error: ${responseBody.jsonParseError.message}.`);\n\t}\n\n\tif (responseBody.bodyText) {\n\t\tdetailParts.push(\"The raw response body is available in bodyText.\");\n\t}\n\n\treturn detailParts.join(\" \");\n}\n\nfunction isJsonContentType(contentType?: string): boolean {\n\tif (!contentType) {\n\t\treturn false;\n\t}\n\n\tconst mimeType = contentType.split(\";\")[0]?.trim().toLowerCase();\n\tif (!mimeType) {\n\t\treturn false;\n\t}\n\n\treturn mimeType === \"application/json\" || mimeType.endsWith(\"+json\");\n}\n\nfunction truncateBody(bodyText: string): string | undefined {\n\tif (bodyText.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tif (bodyText.length <= MAX_DIAGNOSTIC_BODY_LENGTH) {\n\t\treturn bodyText;\n\t}\n\n\treturn `${bodyText.slice(0, MAX_DIAGNOSTIC_BODY_LENGTH - 3)}...`;\n}\n\nfunction toError(error: unknown): Error {\n\tif (error instanceof Error) {\n\t\treturn error;\n\t}\n\n\tconst message = typeof error === \"string\" && error.length > 0 ? error : \"Unknown error\";\n\treturn new Error(message);\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport type { ApiGatewayError } from \"../errors\";\nimport { ApiServiceError } from \"../errors\";\nimport { createGatewayError, createUnexpectedServiceResponseError } from \"./error-factories\";\nimport {\n\tdescribeGatewayResponse,\n\tdescribeUnexpectedSuccessResponse,\n\tgetResponseContentType,\n\tgetResponseRequestId,\n\tisGatewayStatusCode,\n\tparseApiErrorResponse,\n\tparseApiResponse,\n\treadResponseBody,\n\ttype ResponseBodyDiagnostics,\n} from \"./response-handling\";\n\n/**\n * Validates an outbound request body when the caller supplied a schema.\n *\n * Requests without a body, or without a schema, pass through unchanged.\n */\nexport function parseRequestBody<ReqSchema extends ZodTypeAny | undefined>(\n\trequestSchema: ReqSchema | undefined,\n\tbody: (ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown) | undefined,\n): (ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown) | undefined {\n\tif (!requestSchema || body === undefined) {\n\t\treturn body;\n\t}\n\n\treturn requestSchema.parse(body);\n}\n\n/**\n * Consumes the HTTP response body and converts body-read failures into the same\n * client error model used for normal gateway and service failures.\n */\nexport async function readApiResponseBody(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n): Promise<ResponseBodyDiagnostics> {\n\ttry {\n\t\treturn await readResponseBody(response);\n\t} catch (error) {\n\t\tif (response.ok) {\n\t\t\tthrow createUnexpectedServiceResponseError(path, url, {\n\t\t\t\tcontentType: getResponseContentType(response),\n\t\t\t\tcause: error,\n\t\t\t\tdetails: \"Failed to read the response body before the API response could be validated.\",\n\t\t\t\trequestId: getResponseRequestId(response),\n\t\t\t});\n\t\t}\n\n\t\tthrow createGatewayError(path, url, response.status, {\n\t\t\tcontentType: getResponseContentType(response),\n\t\t\tcause: error,\n\t\t\tdetails:\n\t\t\t\t\"Failed to read the non-success response body, so the response could not be validated as a service error.\",\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n}\n\n/**\n * Interprets a successful HTTP response as either a valid Content Curation API\n * success envelope or a service-origin failure.\n */\nexport function parseSuccessfulResponse<ResponseDataSchema extends ZodTypeAny>(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n\tresponseBody: ResponseBodyDiagnostics,\n\tresponseDataSchema: ResponseDataSchema,\n): z.infer<ResponseDataSchema> {\n\tconst parsedResponse = parseApiResponse(responseDataSchema, responseBody);\n\n\tif (!parsedResponse) {\n\t\tthrow createUnexpectedServiceResponseError(path, url, {\n\t\t\tcontentType: responseBody.contentType,\n\t\t\tbodyText: responseBody.bodyText,\n\t\t\tdetails: describeUnexpectedSuccessResponse(responseBody),\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n\n\tif (\"error\" in parsedResponse) {\n\t\tthrow new ApiServiceError(\n\t\t\tparsedResponse.error,\n\t\t\tparsedResponse.statusCode,\n\t\t\tparsedResponse.requestId,\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\tcontentType: responseBody.contentType,\n\t\t\t\tbodyText: responseBody.bodyText,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn parsedResponse.data;\n}\n\n/**\n * Classifies a non-success HTTP response as either a validated service error or\n * a gateway-origin failure.\n */\nexport function createResponseError(\n\tpath: string,\n\turl: string,\n\tresponse: Response,\n\tresponseBody: ResponseBodyDiagnostics,\n): ApiGatewayError | ApiServiceError {\n\tif (isGatewayStatusCode(response.status)) {\n\t\treturn createGatewayError(path, url, response.status, {\n\t\t\tcontentType: responseBody.contentType,\n\t\t\tbodyText: responseBody.bodyText,\n\t\t\tdetails: describeGatewayResponse(response.status, responseBody),\n\t\t\trequestId: getResponseRequestId(response),\n\t\t});\n\t}\n\n\tconst parsedServiceError = parseApiErrorResponse(responseBody);\n\tif (parsedServiceError) {\n\t\treturn new ApiServiceError(\n\t\t\tparsedServiceError.error,\n\t\t\tparsedServiceError.statusCode,\n\t\t\tparsedServiceError.requestId,\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\tcontentType: responseBody.contentType,\n\t\t\t\tbodyText: responseBody.bodyText,\n\t\t\t},\n\t\t);\n\t}\n\n\treturn createGatewayError(path, url, response.status, {\n\t\tcontentType: responseBody.contentType,\n\t\tbodyText: responseBody.bodyText,\n\t\tdetails: describeGatewayResponse(response.status, responseBody),\n\t\trequestId: getResponseRequestId(response),\n\t});\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport {\n\tcreateResponseError,\n\tcreateTransportError,\n\tparseRequestBody,\n\tparseSuccessfulResponse,\n\treadApiResponseBody,\n} from \"./internal\";\n\n/**\n * Configuration options for the API client.\n */\nexport type ApiClientConfig =\n\t| {\n\t\t\t// Standard configuration.\n\t\t\t// Intended for external clients using an API key issued via API Gateway.\n\t\t\tbaseUrl: string;\n\t\t\tapiKey: string;\n\t\t\tapiToken?: never;\n\t\t\tfetch?: typeof fetch;\n\t }\n\t| {\n\t\t\t// Alternative configuration.\n\t\t\t// Reserved for clients with access to a bearer token (for example, e2e tests).\n\t\t\tbaseUrl: string;\n\t\t\tapiKey?: never;\n\t\t\tapiToken: string;\n\t\t\tfetch?: typeof fetch;\n\t };\n\n/**\n * Shared HTTP client for Content Curation API requests.\n *\n * The public sub-clients delegate to this class so request validation, fetch\n * execution, response parsing, and error classification all happen in one place.\n */\nexport class BaseApiClient {\n\tprotected config: ApiClientConfig;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\tfetch: config.fetch || fetch,\n\t\t};\n\t\tthis.config.baseUrl = trimTrailingSlashes(this.config.baseUrl);\n\t}\n\n\t/**\n\t * Performs a request against the JSON API, validates the response envelope,\n\t * and returns the typed `data` payload on success.\n\t */\n\tprotected async request<\n\t\tReqSchema extends ZodTypeAny | undefined,\n\t\tResponseDataSchema extends ZodTypeAny,\n\t>(\n\t\tmethod: \"GET\" | \"PUT\" | \"POST\" | \"DELETE\",\n\t\tpath: string,\n\t\topts: {\n\t\t\trequestSchema?: ReqSchema;\n\t\t\tbody?: ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown;\n\t\t\tresponseDataSchema: ResponseDataSchema;\n\t\t},\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\tconst bodyPayload = parseRequestBody(opts.requestSchema, opts.body);\n\t\tconst urlString = new URL(this.config.baseUrl + path).toString();\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await this.config.fetch!(urlString, {\n\t\t\t\tmethod,\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t...(this.config.apiKey\n\t\t\t\t\t\t? { \"x-api-key\": this.config.apiKey }\n\t\t\t\t\t\t: { Authorization: `Bearer ${this.config.apiToken}` }),\n\t\t\t\t},\n\t\t\t\tbody: bodyPayload === undefined ? undefined : JSON.stringify(bodyPayload),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow createTransportError(path, urlString, error);\n\t\t}\n\n\t\tconst responseBody = await readApiResponseBody(path, urlString, response);\n\n\t\tif (response.ok) {\n\t\t\treturn parseSuccessfulResponse(\n\t\t\t\tpath,\n\t\t\t\turlString,\n\t\t\t\tresponse,\n\t\t\t\tresponseBody,\n\t\t\t\topts.responseDataSchema,\n\t\t\t);\n\t\t}\n\n\t\tthrow createResponseError(path, urlString, response, responseBody);\n\t}\n\n\t/**\n\t * GET convenience method inferring response type from schema.\n\t */\n\tprotected get<ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"GET\", path, { responseDataSchema });\n\t}\n\n\t/**\n\t * PUT convenience method inferring both request and response types.\n\t */\n\tprotected put<ReqSchema extends ZodTypeAny, ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tbody: z.infer<ReqSchema>,\n\t\trequestSchema: ReqSchema,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"PUT\", path, { body, requestSchema, responseDataSchema });\n\t}\n}\n\nfunction trimTrailingSlashes(value: string): string {\n\tlet end = value.length;\n\n\twhile (end > 0 && value.charCodeAt(end - 1) === 47) {\n\t\tend -= 1;\n\t}\n\n\treturn end === value.length ? value : value.slice(0, end);\n}\n","import { z } from \"zod\";\n\n/**\n * -----------------------------------------\n * Legacy API Schemas & Types\n *\n * These schemas map to expected types for Hub Pages rendered by dotcom-pages.\n * -----------------------------------------\n */\n\nconst LegacyFlourishChildSchema = z.object({\n\tsource: z.literal(\"flourish\"),\n\tproperties: z.object({\n\t\tid: z.string().min(1), // e.g. \"visualisation/21901162\"\n\t}),\n});\n\nconst LegacyListChildSchema = z.object({\n\tsource: z.literal(\"list\"),\n\tproperties: z.object({\n\t\tid: z.string().uuid(),\n\t\tmaxItems: z.number().optional(),\n\t}),\n});\n\nconst LegacyContentChildSchema = z.object({\n\tsource: z.literal(\"content\"),\n\tproperties: z.object({\n\t\tids: z.array(z.string()).nonempty(),\n\t}),\n});\n\nconst LegacyContainerChildSchema = z.discriminatedUnion(\"source\", [\n\tLegacyFlourishChildSchema,\n\tLegacyListChildSchema,\n\tLegacyContentChildSchema,\n]);\n\nconst LegacyTopperSchema = z.object({\n\ttype: z.literal(\"topper-basic\"),\n\tproperties: z.object({\n\t\ttitle: z.string(),\n\t\tsponsorText: z.string().optional(),\n\t\tsponsorImage: z.string().url().optional(),\n\t}),\n});\n\nconst LegacyInfoBoxSchema = z.object({\n\ttype: z.literal(\"info-box\"),\n\tproperties: z.object({\n\t\tbodyHTML: z.string(),\n\t\ttitle: z.string().optional(),\n\t}),\n});\n\nconst LegacyContainerSchema = z.object({\n\ttype: z.literal(\"container\"),\n\tchildren: z.array(LegacyContainerChildSchema).min(1),\n\tproperties: z.object({\n\t\ttitle: z.string().optional(),\n\t\tdesign: z.enum([\"chart\", \"four-story\", \"freeform\", \"hero-lead\"]).default(\"freeform\"),\n\t\tbackgroundColor: z.string().optional(),\n\t}),\n});\n\nconst LegacyExperimentSchema = z.object({\n\ttype: z.literal(\"experiment\"),\n\tchildren: z.tuple([]),\n\tproperties: z.object({\n\t\texperimentName: z.string(),\n\t\tid: z.string(),\n\t\ttitle: z.string().optional(),\n\t\tconfig: z\n\t\t\t.object({\n\t\t\t\tvalue: z.unknown().optional(),\n\t\t\t\t// Hub pages support experiments with HTML and Text.\n\t\t\t\t// For now we just support JSON. As we migrate pages, this may change.\n\t\t\t\tformat: z.enum([\"json\"]).default(\"json\"),\n\t\t\t})\n\t\t\t.partial()\n\t\t\t.optional(),\n\t}),\n});\n\nconst LegacyBlockSchema = z.discriminatedUnion(\"type\", [\n\tLegacyTopperSchema,\n\tLegacyInfoBoxSchema,\n\tLegacyContainerSchema,\n\tLegacyExperimentSchema,\n]);\n\nexport const LegacyPageStructureOutputSchema = z.object({\n\tuuid: z.string().uuid(),\n\ttitle: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tthemeName: z.string().optional(),\n\tmetaDescription: z.string().optional(),\n\tblocks: z.array(LegacyBlockSchema),\n});\n\nexport type LegacyPageStructureOutput = z.infer<typeof LegacyPageStructureOutputSchema>;\nexport type LegacyBlock = z.infer<typeof LegacyBlockSchema>;\n","import { z } from \"zod\";\nimport { ProseMirrorDocSchema } from \"../../prosemirror\";\n\n//\n// 1) REUSABLE SCHEMAS FOR COMMON STRUCTURES\n//\n\n/**\n * A generic schema representing a heading used across various slices.\n * - `text`: The display text of the heading.\n * - `href`: An optional URL that the heading links to.\n */\nconst HeadingSchema = z.object({\n\ttext: z.string(),\n\thref: z.string().url().optional(),\n});\n\n/**\n * Base “properties” common to most page slices.\n * - `heading`: An optional heading object for slices that can display a title.\n */\nconst BasePageItemProps = z.object({\n\theading: HeadingSchema.optional(),\n});\n\n/**\n * A schema to validate that a string is valid JSON.\n */\nconst ValidJSONStringSchema = z.string().refine(\n\t(val) => {\n\t\ttry {\n\t\t\tJSON.parse(val);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\t{ message: \"Invalid JSON string\" },\n);\n\n//\n// 2) GENERIC HELPER TO DEFINE “SLICE” INPUT/OUTPUT SCHEMAS\n//\n\n/**\n * A union type to represent either a Zod object schema or an optional Zod object schema.\n */\ntype OptionalOrRequiredZodObject = z.AnyZodObject | z.ZodOptional<z.AnyZodObject>;\n\n/**\n * Helper function that, given:\n * - `typeName`: A string literal identifying the slice type.\n * - `propsShape`: A Zod schema describing the slice’s `properties`.\n *\n * Returns an object containing two schemas:\n * - `InputSchema`: For client-side input; `sliceId` is optional.\n * - `OutputSchema`: For server-side/output; `sliceId` is required.\n *\n * This is useful because when defining slices we often want to allow -\n * clients to submit slices without an ID (e.g., when creating new slices),\n */\nfunction defineSliceSchema<T extends string, P extends OptionalOrRequiredZodObject>(options: {\n\ttypeName: T;\n\tpropsShape: P;\n}) {\n\tconst { typeName, propsShape } = options;\n\n\t// Base schema shared by both input and output:\n\t// - `type`: Literal string identifying which slice this is.\n\t// - `hidden`: Optional flag to mark the slice as hidden.\n\t// - `properties`: The detailed properties shape for the slice.\n\tconst BaseSchema = z.object({\n\t\ttype: z.literal(typeName),\n\t\thidden: z.boolean().optional(),\n\t\tproperties: propsShape,\n\t});\n\n\t/**\n\t * Input schema: For client submissions.\n\t * - `sliceId` is optional because the client might not specify it yet.\n\t */\n\tconst InputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid().optional(),\n\t});\n\n\t/**\n\t * Output schema: For persisted or server-returned data.\n\t * - `sliceId` is required (each saved slice must have an ID).\n\t */\n\tconst OutputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid(),\n\t});\n\n\treturn { InputSchema, OutputSchema };\n}\n\n//\n// 3) DEFINE INDIVIDUAL SLICE TYPES (INPUT & OUTPUT) USING THE HELPER\n//\n\n// 3.A “InteractiveSlice”\n// - A slice to embed or reference a Flourish graphic by its ID.\n// - Extends graphic base properties with `flourishId` and `flourishAltText`, with optional 'theme', 'flourishDescription' or 'storyUUID'.\nconst InteractiveSlice = defineSliceSchema({\n\ttypeName: \"Interactive\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tflourishDescription: z.string().optional(), // Optional description for the Flourish graphic\n\t\tflourishId: z.string().nonempty(),\n\t\tflourishAltText: z.string().nonempty(),\n\t\tstoryUUID: z.string().uuid().optional(),\n\t\ttheme: z.string().optional(),\n\t}),\n});\n\n// 3.B “ExperimentSlice”\n// - A slice for embedding experimental content.\n// - Requires an `experimentId`, `experimentName`, and a JSON string (`contentJson`).\nconst ExperimentSlice = defineSliceSchema({\n\ttypeName: \"Experiment\",\n\tpropsShape: BasePageItemProps.extend({\n\t\texperimentId: z.string().nonempty(), // Unique ID for the experiment\n\t\texperimentName: z.string().nonempty(), // Human-readable name of the experiment\n\t\tcontentJson: ValidJSONStringSchema, // The experiment’s JSON payload as a valid JSON string\n\t}),\n});\n\n// 3.C \"Strip\"\n// - A slice that displays a strip of content.\nconst StripSlice = defineSliceSchema({\n\ttypeName: \"Strip\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the strip to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the strip\n\t}),\n});\n\n// 3.D \"TopperSlice\"\n// - A slice that displays a topper section with description and optional strapline.\nconst TopperSlice = defineSliceSchema({\n\ttypeName: \"Topper\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tdescription: ProseMirrorDocSchema,\n\t\tstrapline: z.string().optional(),\n\t}),\n});\n\n// 3.E \"Hero\"\n// - A slice that represents a Hero on the page. It references a Spark List.\nconst HeroSlice = defineSliceSchema({\n\ttypeName: \"Hero\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the spark list to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the hero\n\t}),\n});\n\n// 3.G \"StoryGroup\"\n// - A slice that stores an ordered list of manually curated content ids.\nconst StoryGroupSlice = defineSliceSchema({\n\ttypeName: \"StoryGroup\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tstorySlots: z.array(z.string().uuid()).nonempty(),\n\t}),\n});\n\n//\n// 4) COMPOSE DISCRIMINATED UNIONS FOR “SLICE API” INPUT & OUTPUT\n//\n\n/**\n * All possible slice inputs for the Page API.\n * This discriminated union allows Zod to pick the correct schema based on the `type` field.\n */\nexport const SliceApiInputSchema = z.discriminatedUnion(\"type\", [\n\tInteractiveSlice.InputSchema,\n\tExperimentSlice.InputSchema,\n\tStripSlice.InputSchema,\n\tTopperSlice.InputSchema,\n\tHeroSlice.InputSchema,\n\tStoryGroupSlice.InputSchema,\n] as const);\n\n/**\n * All possible slice outputs for the Page API.\n * The same discriminated union but with each slice requiring `sliceId`.\n */\nexport const SliceApiOutputSchema = z.discriminatedUnion(\"type\", [\n\tInteractiveSlice.OutputSchema,\n\tExperimentSlice.OutputSchema,\n\tStripSlice.OutputSchema,\n\tTopperSlice.OutputSchema,\n\tHeroSlice.OutputSchema,\n\tStoryGroupSlice.OutputSchema,\n] as const);\n\n//\n// 5) WRAPPER SCHEMAS FOR THE ENTIRE PAGE STRUCTURE\n//\n\nconst BasePagePropertiesSchema = z.object({\n\ttitle: z.string(),\n\tpageId: z.string().uuid(),\n\tpublicationId: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tmetaDescription: z.string().optional(),\n\tpageTheme: z.string().optional(),\n\tsponsorText: z.string().optional(),\n\tsponsorImage: z.string().url().optional(),\n\tpageCategory: z.string().optional(),\n});\n\n/**\n * Page structure as submitted by clients.\n * - `properties`: Metadata about the page\n * - `children`: Array of slice inputs (each with an optional `sliceId`).\n */\nexport const PageStructureInputSchema = z.object({\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiInputSchema),\n});\n\n/**\n * Page structure as stored or returned by the server.\n */\nexport const PageStructureOutputSchema = z.object({\n\ttype: z.literal(\"Page\"),\n\tschemaVersion: z.number(),\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiOutputSchema),\n});\n\n//\n// 6) EXPORT TYPES FOR CONSUMPTION IN CODE\n//\n\n/** Client-side type for page structure input */\nexport type PageStructureInput = z.infer<typeof PageStructureInputSchema>;\n\n/** Server-side type for page structure output */\nexport type PageStructureOutput = z.infer<typeof PageStructureOutputSchema>;\n\n/** Union of all possible slice outputs for type-checking convenience */\nexport type Slice = z.infer<typeof SliceApiOutputSchema>;\n\n/** Individual slice output types */\nexport type InteractiveSliceType = z.infer<typeof InteractiveSlice.OutputSchema>;\nexport type ExperimentSliceType = z.infer<typeof ExperimentSlice.OutputSchema>;\nexport type StripSliceType = z.infer<typeof StripSlice.OutputSchema>;\nexport type TopperSliceType = z.infer<typeof TopperSlice.OutputSchema>;\nexport type HeroSliceType = z.infer<typeof HeroSlice.OutputSchema>;\nexport type StoryGroupSliceType = z.infer<typeof StoryGroupSlice.OutputSchema>;\n","import { z } from \"zod\";\n\n/** Accept http(s) and mailto: (matches your editor config) */\nconst HrefSchema = z.string().refine((v) => /^(https?:\\/\\/|mailto:).+/.test(v), {\n\tmessage: \"Expected http(s):// or mailto: URL\",\n});\n\n/** Link mark. */\nconst ProseMirrorLinkMark = z.object({\n\ttype: z.literal(\"link\"),\n\tattrs: z.object({\n\t\thref: HrefSchema,\n\t}),\n});\n\n/** Supported text marks */\nconst ProseMirrorMark = z.discriminatedUnion(\"type\", [\n\tProseMirrorLinkMark,\n\tz.object({ type: z.literal(\"bold\") }),\n\tz.object({ type: z.literal(\"italic\") }),\n\tz.object({ type: z.literal(\"underline\") }),\n\tz.object({ type: z.literal(\"strike\") }),\n]);\n\n/** Text node */\nconst ProseMirrorTextNode = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tmarks: z.array(ProseMirrorMark).optional(),\n});\n\n/** Paragraph node — content can be empty/omitted */\nconst ProseMirrorParagraphNode = z.object({\n\ttype: z.literal(\"paragraph\"),\n\tcontent: z.array(ProseMirrorTextNode),\n});\n\n/** ProseMirror Node Union. */\nconst ProseMirrorNode = z.union([ProseMirrorParagraphNode, ProseMirrorTextNode]);\n\n/** Root node of a ProseMirror document - enforcing at least 1 paragraph */\nexport const ProseMirrorDocSchema = z.object({\n\ttype: z.literal(\"doc\"),\n\tcontent: z\n\t\t.array(ProseMirrorNode)\n\t\t.min(1, { message: \"Document must contain at least one paragraph\" }),\n});\n\n/** Rich text editor TS type. */\nexport type RichTextEditorType = z.infer<typeof ProseMirrorDocSchema>;\n\nexport {};\n","import { z } from \"zod\";\nimport { PageStructureInputSchema, PageStructureOutputSchema } from \"../page\";\n\nexport const DraftContributorInputSchema = z.object({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\temail: z.string().email().optional(),\n});\n\nexport const DraftContributorSchema = DraftContributorInputSchema.extend({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\tfirstTouchedAt: z.string().datetime(),\n\tlastTouchedAt: z.string().datetime(),\n});\n\nconst DraftMetadataSchema = z.object({\n\tdraftId: z.string().uuid(),\n\tcreatedAt: z.string().datetime(),\n\tupdatedAt: z.string().datetime(),\n\tcontributors: z.array(DraftContributorSchema),\n});\n\nexport const PageDraftSchema = DraftMetadataSchema.extend({\n\tstructure: PageStructureOutputSchema,\n});\n\nexport const DraftSchema = PageDraftSchema;\n\nexport const PersistPageDraftInputSchema = z.object({\n\tstructure: PageStructureInputSchema,\n\tcontributor: DraftContributorInputSchema,\n});\n\nexport type DraftContributorInput = z.infer<typeof DraftContributorInputSchema>;\nexport type DraftContributor = z.infer<typeof DraftContributorSchema>;\nexport type PageDraft = z.infer<typeof PageDraftSchema>;\nexport type Draft = z.infer<typeof DraftSchema>;\nexport type PersistPageDraftInput = z.infer<typeof PersistPageDraftInputSchema>;\n","import { BaseApiClient } from \"./base\";\nimport { ApiServiceError } from \"./errors\";\nimport type { LegacyPageStructureOutput } from \"./schemas/ftpink/legacyHubPage\";\nimport { LegacyPageStructureOutputSchema } from \"./schemas/ftpink/legacyHubPage\";\nimport {\n\tPageStructureInputSchema,\n\tPageStructureOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\n/**\n * Client for Page structure endpoints\n */\nexport class PageClient extends BaseApiClient {\n\tasync getStructure(pageId: string): Promise<PageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/structure`, PageStructureOutputSchema);\n\t}\n\n\tasync getDraft(pageId: string): Promise<PageDraft | null> {\n\t\ttry {\n\t\t\treturn await this.get(`/v1/page/${pageId}/draft`, PageDraftSchema);\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiServiceError && error.code === \"NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync getLegacyHubPageStructure(pageId: string): Promise<LegacyPageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/legacyHubPageStructure`, LegacyPageStructureOutputSchema);\n\t}\n\n\tasync upsertStructure(\n\t\tpageId: string,\n\t\tdata: Omit<PageStructureInput, \"type\">,\n\t): Promise<PageStructureOutput> {\n\t\treturn this.put(\n\t\t\t`/v1/page/${pageId}/structure`,\n\t\t\tdata,\n\t\t\tPageStructureInputSchema,\n\t\t\tPageStructureOutputSchema,\n\t\t);\n\t}\n}\n","import type { ApiClientConfig } from \"./base\";\nimport { BaseApiClient } from \"./base\";\nimport { PageClient } from \"./page\";\n\n/**\n * Main API client that provides access to all API endpoints\n */\nexport class ApiClient extends BaseApiClient {\n\tpage: PageClient;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tsuper(config);\n\n\t\t// Initialize sub-client\n\t\tthis.page = new PageClient(config);\n\t}\n}\n"],"mappings":";AA4CO,IAAM,iBAAN,cAA6B,MAAM;AAAA;AAAA,EAElC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAES;AAAA,EAEhB,YACC,SACA,YACA,WACA,WAAmC,EAAE,QAAQ,UAAU,GACtD;AACD,UAAM,QAAQ,OAAO;AACrB,SAAK,OAAO,WAAW;AACvB,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,YAAY;AACjB,SAAK,OAAO,QAAQ;AACpB,SAAK,UAAU,QAAQ;AACvB,SAAK,OAAO,QAAQ;AACpB,SAAK,YAAY,QAAQ;AACzB,SAAK,SAAS,SAAS;AACvB,SAAK,MAAM,SAAS;AACpB,SAAK,cAAc,SAAS;AAC5B,SAAK,WAAW,SAAS;AACzB,SAAK,QAAQ,SAAS;AAAA,EACvB;AACD;AAKO,IAAM,oBAAN,cAAgC,eAAe;AAAA,EACrC;AAAA,EACA;AAAA;AAAA,EAET;AAAA,EAEP,YACC,SACA,YACA,WACA,UACC;AACD,UAAM,SAAS,YAAY,WAAW;AAAA,MACrC,GAAG;AAAA,MACH,QAAQ;AAAA,IACT,CAAC;AACD,SAAK,UAAU;AACf,SAAK,SAAS;AACd,SAAK,gBAAgB,SAAS;AAAA,EAC/B;AACD;AAMO,IAAM,kBAAN,cAA8B,eAAe;AAAA,EACnC;AAAA,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