@financial-times/content-curation-client 6.2.0 → 6.3.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 +29 -0
- package/dist/_tsup-dts-rollup.d.ts +29 -0
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -493,6 +493,8 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
493
493
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
494
494
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
495
495
|
pageCategory: z.ZodOptional<z.ZodString>;
|
|
496
|
+
} & {
|
|
497
|
+
lastPublishedDate: z.ZodOptional<z.ZodString>;
|
|
496
498
|
}, "strip", z.ZodTypeAny, {
|
|
497
499
|
title: string;
|
|
498
500
|
pageId: string;
|
|
@@ -503,6 +505,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
503
505
|
metaDescription?: string | undefined;
|
|
504
506
|
pageTheme?: string | undefined;
|
|
505
507
|
pageCategory?: string | undefined;
|
|
508
|
+
lastPublishedDate?: string | undefined;
|
|
506
509
|
}, {
|
|
507
510
|
title: string;
|
|
508
511
|
pageId: string;
|
|
@@ -513,6 +516,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
513
516
|
metaDescription?: string | undefined;
|
|
514
517
|
pageTheme?: string | undefined;
|
|
515
518
|
pageCategory?: string | undefined;
|
|
519
|
+
lastPublishedDate?: string | undefined;
|
|
516
520
|
}>;
|
|
517
521
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
518
522
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -1338,6 +1342,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1338
1342
|
metaDescription?: string | undefined;
|
|
1339
1343
|
pageTheme?: string | undefined;
|
|
1340
1344
|
pageCategory?: string | undefined;
|
|
1345
|
+
lastPublishedDate?: string | undefined;
|
|
1341
1346
|
};
|
|
1342
1347
|
children: ({
|
|
1343
1348
|
type: "Interactive";
|
|
@@ -1468,6 +1473,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1468
1473
|
metaDescription?: string | undefined;
|
|
1469
1474
|
pageTheme?: string | undefined;
|
|
1470
1475
|
pageCategory?: string | undefined;
|
|
1476
|
+
lastPublishedDate?: string | undefined;
|
|
1471
1477
|
};
|
|
1472
1478
|
children: ({
|
|
1473
1479
|
type: "Interactive";
|
|
@@ -1610,6 +1616,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1610
1616
|
metaDescription?: string | undefined;
|
|
1611
1617
|
pageTheme?: string | undefined;
|
|
1612
1618
|
pageCategory?: string | undefined;
|
|
1619
|
+
lastPublishedDate?: string | undefined;
|
|
1613
1620
|
};
|
|
1614
1621
|
children: ({
|
|
1615
1622
|
type: "Interactive";
|
|
@@ -1752,6 +1759,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1752
1759
|
metaDescription?: string | undefined;
|
|
1753
1760
|
pageTheme?: string | undefined;
|
|
1754
1761
|
pageCategory?: string | undefined;
|
|
1762
|
+
lastPublishedDate?: string | undefined;
|
|
1755
1763
|
};
|
|
1756
1764
|
children: ({
|
|
1757
1765
|
type: "Interactive";
|
|
@@ -2943,6 +2951,8 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
2943
2951
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
2944
2952
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
2945
2953
|
pageCategory: z.ZodOptional<z.ZodString>;
|
|
2954
|
+
} & {
|
|
2955
|
+
lastPublishedDate: z.ZodOptional<z.ZodString>;
|
|
2946
2956
|
}, "strip", z.ZodTypeAny, {
|
|
2947
2957
|
title: string;
|
|
2948
2958
|
pageId: string;
|
|
@@ -2953,6 +2963,7 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
2953
2963
|
metaDescription?: string | undefined;
|
|
2954
2964
|
pageTheme?: string | undefined;
|
|
2955
2965
|
pageCategory?: string | undefined;
|
|
2966
|
+
lastPublishedDate?: string | undefined;
|
|
2956
2967
|
}, {
|
|
2957
2968
|
title: string;
|
|
2958
2969
|
pageId: string;
|
|
@@ -2963,6 +2974,7 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
2963
2974
|
metaDescription?: string | undefined;
|
|
2964
2975
|
pageTheme?: string | undefined;
|
|
2965
2976
|
pageCategory?: string | undefined;
|
|
2977
|
+
lastPublishedDate?: string | undefined;
|
|
2966
2978
|
}>;
|
|
2967
2979
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
2968
2980
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -3788,6 +3800,7 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
3788
3800
|
metaDescription?: string | undefined;
|
|
3789
3801
|
pageTheme?: string | undefined;
|
|
3790
3802
|
pageCategory?: string | undefined;
|
|
3803
|
+
lastPublishedDate?: string | undefined;
|
|
3791
3804
|
};
|
|
3792
3805
|
children: ({
|
|
3793
3806
|
type: "Interactive";
|
|
@@ -3918,6 +3931,7 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
3918
3931
|
metaDescription?: string | undefined;
|
|
3919
3932
|
pageTheme?: string | undefined;
|
|
3920
3933
|
pageCategory?: string | undefined;
|
|
3934
|
+
lastPublishedDate?: string | undefined;
|
|
3921
3935
|
};
|
|
3922
3936
|
children: ({
|
|
3923
3937
|
type: "Interactive";
|
|
@@ -4058,6 +4072,7 @@ declare class PageClient extends BaseApiClient {
|
|
|
4058
4072
|
metaDescription?: string | undefined;
|
|
4059
4073
|
pageTheme?: string | undefined;
|
|
4060
4074
|
pageCategory?: string | undefined;
|
|
4075
|
+
lastPublishedDate?: string | undefined;
|
|
4061
4076
|
};
|
|
4062
4077
|
children: ({
|
|
4063
4078
|
type: "Interactive";
|
|
@@ -4223,6 +4238,8 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4223
4238
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
4224
4239
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
4225
4240
|
pageCategory: z.ZodOptional<z.ZodString>;
|
|
4241
|
+
} & {
|
|
4242
|
+
lastPublishedDate: z.ZodOptional<z.ZodString>;
|
|
4226
4243
|
}, "strip", z.ZodTypeAny, {
|
|
4227
4244
|
title: string;
|
|
4228
4245
|
pageId: string;
|
|
@@ -4233,6 +4250,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4233
4250
|
metaDescription?: string | undefined;
|
|
4234
4251
|
pageTheme?: string | undefined;
|
|
4235
4252
|
pageCategory?: string | undefined;
|
|
4253
|
+
lastPublishedDate?: string | undefined;
|
|
4236
4254
|
}, {
|
|
4237
4255
|
title: string;
|
|
4238
4256
|
pageId: string;
|
|
@@ -4243,6 +4261,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4243
4261
|
metaDescription?: string | undefined;
|
|
4244
4262
|
pageTheme?: string | undefined;
|
|
4245
4263
|
pageCategory?: string | undefined;
|
|
4264
|
+
lastPublishedDate?: string | undefined;
|
|
4246
4265
|
}>;
|
|
4247
4266
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
4248
4267
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -5068,6 +5087,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
5068
5087
|
metaDescription?: string | undefined;
|
|
5069
5088
|
pageTheme?: string | undefined;
|
|
5070
5089
|
pageCategory?: string | undefined;
|
|
5090
|
+
lastPublishedDate?: string | undefined;
|
|
5071
5091
|
};
|
|
5072
5092
|
children: ({
|
|
5073
5093
|
type: "Interactive";
|
|
@@ -5198,6 +5218,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
5198
5218
|
metaDescription?: string | undefined;
|
|
5199
5219
|
pageTheme?: string | undefined;
|
|
5200
5220
|
pageCategory?: string | undefined;
|
|
5221
|
+
lastPublishedDate?: string | undefined;
|
|
5201
5222
|
};
|
|
5202
5223
|
children: ({
|
|
5203
5224
|
type: "Interactive";
|
|
@@ -5340,6 +5361,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
5340
5361
|
metaDescription?: string | undefined;
|
|
5341
5362
|
pageTheme?: string | undefined;
|
|
5342
5363
|
pageCategory?: string | undefined;
|
|
5364
|
+
lastPublishedDate?: string | undefined;
|
|
5343
5365
|
};
|
|
5344
5366
|
children: ({
|
|
5345
5367
|
type: "Interactive";
|
|
@@ -5482,6 +5504,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
5482
5504
|
metaDescription?: string | undefined;
|
|
5483
5505
|
pageTheme?: string | undefined;
|
|
5484
5506
|
pageCategory?: string | undefined;
|
|
5507
|
+
lastPublishedDate?: string | undefined;
|
|
5485
5508
|
};
|
|
5486
5509
|
children: ({
|
|
5487
5510
|
type: "Interactive";
|
|
@@ -6740,6 +6763,8 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6740
6763
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
6741
6764
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
6742
6765
|
pageCategory: z.ZodOptional<z.ZodString>;
|
|
6766
|
+
} & {
|
|
6767
|
+
lastPublishedDate: z.ZodOptional<z.ZodString>;
|
|
6743
6768
|
}, "strip", z.ZodTypeAny, {
|
|
6744
6769
|
title: string;
|
|
6745
6770
|
pageId: string;
|
|
@@ -6750,6 +6775,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6750
6775
|
metaDescription?: string | undefined;
|
|
6751
6776
|
pageTheme?: string | undefined;
|
|
6752
6777
|
pageCategory?: string | undefined;
|
|
6778
|
+
lastPublishedDate?: string | undefined;
|
|
6753
6779
|
}, {
|
|
6754
6780
|
title: string;
|
|
6755
6781
|
pageId: string;
|
|
@@ -6760,6 +6786,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6760
6786
|
metaDescription?: string | undefined;
|
|
6761
6787
|
pageTheme?: string | undefined;
|
|
6762
6788
|
pageCategory?: string | undefined;
|
|
6789
|
+
lastPublishedDate?: string | undefined;
|
|
6763
6790
|
}>;
|
|
6764
6791
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
6765
6792
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -7585,6 +7612,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
7585
7612
|
metaDescription?: string | undefined;
|
|
7586
7613
|
pageTheme?: string | undefined;
|
|
7587
7614
|
pageCategory?: string | undefined;
|
|
7615
|
+
lastPublishedDate?: string | undefined;
|
|
7588
7616
|
};
|
|
7589
7617
|
children: ({
|
|
7590
7618
|
type: "Interactive";
|
|
@@ -7715,6 +7743,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
7715
7743
|
metaDescription?: string | undefined;
|
|
7716
7744
|
pageTheme?: string | undefined;
|
|
7717
7745
|
pageCategory?: string | undefined;
|
|
7746
|
+
lastPublishedDate?: string | undefined;
|
|
7718
7747
|
};
|
|
7719
7748
|
children: ({
|
|
7720
7749
|
type: "Interactive";
|
|
@@ -493,6 +493,8 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
493
493
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
494
494
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
495
495
|
pageCategory: z.ZodOptional<z.ZodString>;
|
|
496
|
+
} & {
|
|
497
|
+
lastPublishedDate: z.ZodOptional<z.ZodString>;
|
|
496
498
|
}, "strip", z.ZodTypeAny, {
|
|
497
499
|
title: string;
|
|
498
500
|
pageId: string;
|
|
@@ -503,6 +505,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
503
505
|
metaDescription?: string | undefined;
|
|
504
506
|
pageTheme?: string | undefined;
|
|
505
507
|
pageCategory?: string | undefined;
|
|
508
|
+
lastPublishedDate?: string | undefined;
|
|
506
509
|
}, {
|
|
507
510
|
title: string;
|
|
508
511
|
pageId: string;
|
|
@@ -513,6 +516,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
513
516
|
metaDescription?: string | undefined;
|
|
514
517
|
pageTheme?: string | undefined;
|
|
515
518
|
pageCategory?: string | undefined;
|
|
519
|
+
lastPublishedDate?: string | undefined;
|
|
516
520
|
}>;
|
|
517
521
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
518
522
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -1338,6 +1342,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1338
1342
|
metaDescription?: string | undefined;
|
|
1339
1343
|
pageTheme?: string | undefined;
|
|
1340
1344
|
pageCategory?: string | undefined;
|
|
1345
|
+
lastPublishedDate?: string | undefined;
|
|
1341
1346
|
};
|
|
1342
1347
|
children: ({
|
|
1343
1348
|
type: "Interactive";
|
|
@@ -1468,6 +1473,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1468
1473
|
metaDescription?: string | undefined;
|
|
1469
1474
|
pageTheme?: string | undefined;
|
|
1470
1475
|
pageCategory?: string | undefined;
|
|
1476
|
+
lastPublishedDate?: string | undefined;
|
|
1471
1477
|
};
|
|
1472
1478
|
children: ({
|
|
1473
1479
|
type: "Interactive";
|
|
@@ -1610,6 +1616,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1610
1616
|
metaDescription?: string | undefined;
|
|
1611
1617
|
pageTheme?: string | undefined;
|
|
1612
1618
|
pageCategory?: string | undefined;
|
|
1619
|
+
lastPublishedDate?: string | undefined;
|
|
1613
1620
|
};
|
|
1614
1621
|
children: ({
|
|
1615
1622
|
type: "Interactive";
|
|
@@ -1752,6 +1759,7 @@ declare const DraftSchema: z.ZodObject<{
|
|
|
1752
1759
|
metaDescription?: string | undefined;
|
|
1753
1760
|
pageTheme?: string | undefined;
|
|
1754
1761
|
pageCategory?: string | undefined;
|
|
1762
|
+
lastPublishedDate?: string | undefined;
|
|
1755
1763
|
};
|
|
1756
1764
|
children: ({
|
|
1757
1765
|
type: "Interactive";
|
|
@@ -2943,6 +2951,8 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
2943
2951
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
2944
2952
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
2945
2953
|
pageCategory: z.ZodOptional<z.ZodString>;
|
|
2954
|
+
} & {
|
|
2955
|
+
lastPublishedDate: z.ZodOptional<z.ZodString>;
|
|
2946
2956
|
}, "strip", z.ZodTypeAny, {
|
|
2947
2957
|
title: string;
|
|
2948
2958
|
pageId: string;
|
|
@@ -2953,6 +2963,7 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
2953
2963
|
metaDescription?: string | undefined;
|
|
2954
2964
|
pageTheme?: string | undefined;
|
|
2955
2965
|
pageCategory?: string | undefined;
|
|
2966
|
+
lastPublishedDate?: string | undefined;
|
|
2956
2967
|
}, {
|
|
2957
2968
|
title: string;
|
|
2958
2969
|
pageId: string;
|
|
@@ -2963,6 +2974,7 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
2963
2974
|
metaDescription?: string | undefined;
|
|
2964
2975
|
pageTheme?: string | undefined;
|
|
2965
2976
|
pageCategory?: string | undefined;
|
|
2977
|
+
lastPublishedDate?: string | undefined;
|
|
2966
2978
|
}>;
|
|
2967
2979
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
2968
2980
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -3788,6 +3800,7 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
3788
3800
|
metaDescription?: string | undefined;
|
|
3789
3801
|
pageTheme?: string | undefined;
|
|
3790
3802
|
pageCategory?: string | undefined;
|
|
3803
|
+
lastPublishedDate?: string | undefined;
|
|
3791
3804
|
};
|
|
3792
3805
|
children: ({
|
|
3793
3806
|
type: "Interactive";
|
|
@@ -3918,6 +3931,7 @@ export declare const ListPagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
3918
3931
|
metaDescription?: string | undefined;
|
|
3919
3932
|
pageTheme?: string | undefined;
|
|
3920
3933
|
pageCategory?: string | undefined;
|
|
3934
|
+
lastPublishedDate?: string | undefined;
|
|
3921
3935
|
};
|
|
3922
3936
|
children: ({
|
|
3923
3937
|
type: "Interactive";
|
|
@@ -4058,6 +4072,7 @@ declare class PageClient extends BaseApiClient {
|
|
|
4058
4072
|
metaDescription?: string | undefined;
|
|
4059
4073
|
pageTheme?: string | undefined;
|
|
4060
4074
|
pageCategory?: string | undefined;
|
|
4075
|
+
lastPublishedDate?: string | undefined;
|
|
4061
4076
|
};
|
|
4062
4077
|
children: ({
|
|
4063
4078
|
type: "Interactive";
|
|
@@ -4223,6 +4238,8 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4223
4238
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
4224
4239
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
4225
4240
|
pageCategory: z.ZodOptional<z.ZodString>;
|
|
4241
|
+
} & {
|
|
4242
|
+
lastPublishedDate: z.ZodOptional<z.ZodString>;
|
|
4226
4243
|
}, "strip", z.ZodTypeAny, {
|
|
4227
4244
|
title: string;
|
|
4228
4245
|
pageId: string;
|
|
@@ -4233,6 +4250,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4233
4250
|
metaDescription?: string | undefined;
|
|
4234
4251
|
pageTheme?: string | undefined;
|
|
4235
4252
|
pageCategory?: string | undefined;
|
|
4253
|
+
lastPublishedDate?: string | undefined;
|
|
4236
4254
|
}, {
|
|
4237
4255
|
title: string;
|
|
4238
4256
|
pageId: string;
|
|
@@ -4243,6 +4261,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
4243
4261
|
metaDescription?: string | undefined;
|
|
4244
4262
|
pageTheme?: string | undefined;
|
|
4245
4263
|
pageCategory?: string | undefined;
|
|
4264
|
+
lastPublishedDate?: string | undefined;
|
|
4246
4265
|
}>;
|
|
4247
4266
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
4248
4267
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -5068,6 +5087,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
5068
5087
|
metaDescription?: string | undefined;
|
|
5069
5088
|
pageTheme?: string | undefined;
|
|
5070
5089
|
pageCategory?: string | undefined;
|
|
5090
|
+
lastPublishedDate?: string | undefined;
|
|
5071
5091
|
};
|
|
5072
5092
|
children: ({
|
|
5073
5093
|
type: "Interactive";
|
|
@@ -5198,6 +5218,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
5198
5218
|
metaDescription?: string | undefined;
|
|
5199
5219
|
pageTheme?: string | undefined;
|
|
5200
5220
|
pageCategory?: string | undefined;
|
|
5221
|
+
lastPublishedDate?: string | undefined;
|
|
5201
5222
|
};
|
|
5202
5223
|
children: ({
|
|
5203
5224
|
type: "Interactive";
|
|
@@ -5340,6 +5361,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
5340
5361
|
metaDescription?: string | undefined;
|
|
5341
5362
|
pageTheme?: string | undefined;
|
|
5342
5363
|
pageCategory?: string | undefined;
|
|
5364
|
+
lastPublishedDate?: string | undefined;
|
|
5343
5365
|
};
|
|
5344
5366
|
children: ({
|
|
5345
5367
|
type: "Interactive";
|
|
@@ -5482,6 +5504,7 @@ declare const PageDraftSchema: z.ZodObject<{
|
|
|
5482
5504
|
metaDescription?: string | undefined;
|
|
5483
5505
|
pageTheme?: string | undefined;
|
|
5484
5506
|
pageCategory?: string | undefined;
|
|
5507
|
+
lastPublishedDate?: string | undefined;
|
|
5485
5508
|
};
|
|
5486
5509
|
children: ({
|
|
5487
5510
|
type: "Interactive";
|
|
@@ -6740,6 +6763,8 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6740
6763
|
sponsorText: z.ZodOptional<z.ZodString>;
|
|
6741
6764
|
sponsorImage: z.ZodOptional<z.ZodString>;
|
|
6742
6765
|
pageCategory: z.ZodOptional<z.ZodString>;
|
|
6766
|
+
} & {
|
|
6767
|
+
lastPublishedDate: z.ZodOptional<z.ZodString>;
|
|
6743
6768
|
}, "strip", z.ZodTypeAny, {
|
|
6744
6769
|
title: string;
|
|
6745
6770
|
pageId: string;
|
|
@@ -6750,6 +6775,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6750
6775
|
metaDescription?: string | undefined;
|
|
6751
6776
|
pageTheme?: string | undefined;
|
|
6752
6777
|
pageCategory?: string | undefined;
|
|
6778
|
+
lastPublishedDate?: string | undefined;
|
|
6753
6779
|
}, {
|
|
6754
6780
|
title: string;
|
|
6755
6781
|
pageId: string;
|
|
@@ -6760,6 +6786,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
6760
6786
|
metaDescription?: string | undefined;
|
|
6761
6787
|
pageTheme?: string | undefined;
|
|
6762
6788
|
pageCategory?: string | undefined;
|
|
6789
|
+
lastPublishedDate?: string | undefined;
|
|
6763
6790
|
}>;
|
|
6764
6791
|
children: z.ZodArray<z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
|
|
6765
6792
|
type: z.ZodLiteral<"Interactive">;
|
|
@@ -7585,6 +7612,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
7585
7612
|
metaDescription?: string | undefined;
|
|
7586
7613
|
pageTheme?: string | undefined;
|
|
7587
7614
|
pageCategory?: string | undefined;
|
|
7615
|
+
lastPublishedDate?: string | undefined;
|
|
7588
7616
|
};
|
|
7589
7617
|
children: ({
|
|
7590
7618
|
type: "Interactive";
|
|
@@ -7715,6 +7743,7 @@ declare const PageStructureOutputSchema: z.ZodObject<{
|
|
|
7715
7743
|
metaDescription?: string | undefined;
|
|
7716
7744
|
pageTheme?: string | undefined;
|
|
7717
7745
|
pageCategory?: string | undefined;
|
|
7746
|
+
lastPublishedDate?: string | undefined;
|
|
7718
7747
|
};
|
|
7719
7748
|
children: ({
|
|
7720
7749
|
type: "Interactive";
|
package/dist/index.cjs
CHANGED
|
@@ -754,6 +754,9 @@ var BasePagePropertiesSchema = _zod.z.object({
|
|
|
754
754
|
sponsorImage: _zod.z.string().url().optional(),
|
|
755
755
|
pageCategory: _zod.z.string().optional()
|
|
756
756
|
});
|
|
757
|
+
var PageStructureOutputPropertiesSchema = BasePagePropertiesSchema.extend({
|
|
758
|
+
lastPublishedDate: _zod.z.string().datetime().optional()
|
|
759
|
+
});
|
|
757
760
|
var PageStructureInputSchema = _zod.z.object({
|
|
758
761
|
properties: BasePagePropertiesSchema,
|
|
759
762
|
children: _zod.z.array(SliceApiInputSchema)
|
|
@@ -761,7 +764,7 @@ var PageStructureInputSchema = _zod.z.object({
|
|
|
761
764
|
var PageStructureOutputSchema = _zod.z.object({
|
|
762
765
|
type: _zod.z.literal("Page"),
|
|
763
766
|
schemaVersion: _zod.z.number(),
|
|
764
|
-
properties:
|
|
767
|
+
properties: PageStructureOutputPropertiesSchema,
|
|
765
768
|
children: _zod.z.array(SliceApiOutputSchema)
|
|
766
769
|
});
|
|
767
770
|
var ListPagesOutputSchema = _zod.z.array(PageStructureOutputSchema);
|
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,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0D,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;AAEgD,EAAA;AACzB,IAAA;AAIQ,IAAA;AACvB,IAAA;AACR,EAAA;AACD;AXgwBkC;AACA;AYtzBH;AAC9B,EAAA;AAEqC,EAAA;AACxB,IAAA;AAGe,IAAA;AAC5B,EAAA;AACD;AZqzBkC;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 * Array of Page Structures\n */\nexport const ListPagesOutputSchema = z.array(PageStructureOutputSchema);\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\tListPagesOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\nexport type ListPagesOptions = {\n\tpageCategory?: string;\n};\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\tasync listPages(options: ListPagesOptions = {}) {\n\t\tconst query = options.pageCategory\n\t\t\t? `?${new URLSearchParams({ pageCategory: options.pageCategory })}`\n\t\t\t: \"\";\n\n\t\tconst result = await this.get(`/v1/page${query}`, ListPagesOutputSchema);\n\t\treturn result;\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"],"mappings":"AAAA;AC4CO,IAAM,eAAA,EAAN,MAAA,QAA6B,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,WAAA,CACC,OAAA,EACA,UAAA,EACA,SAAA,EACA,SAAA,EAAmC,EAAE,MAAA,EAAQ,UAAU,CAAA,EACtD;AACD,IAAA,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA;AACrB,IAAA,IAAA,CAAK,KAAA,EAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AACf,IAAA,IAAA,CAAK,WAAA,EAAa,UAAA;AAClB,IAAA,IAAA,CAAK,UAAA,EAAY,SAAA;AACjB,IAAA,IAAA,CAAK,KAAA,EAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA,CAAQ,OAAA;AACvB,IAAA,IAAA,CAAK,KAAA,EAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,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A;AACO,EAAA;AACN,EAAA;AACzB;AAMK;AACyB,EAAA;AAC9B;AAOyC;AAC7B,EAAA;AACM,EAAA;AAClB;AAKwCA;AAClB,EAAA;AACE,EAAA;AACZ,EAAA;AACM,EAAA;AAClB;AAKsC;ARghBL;AACA;AUnwBhB;AAGyBA;AAClB,EAAA;AACK,EAAA;AACH,EAAA;AAC1B;AAEqC;AACb,EAAA;AACK,EAAA;AACF,EAAA;AACD,EAAA;AAC1B;AAE6B;AACJ,EAAA;AACM,EAAA;AACA,EAAA;AACT,EAAA;AACtB;AAE8B;AACnB,EAAA;AACX;AAE0B;AAEgBA;AAC/B,EAAA;AACE,EAAA;AACb;AV8vBiC;AACA;AW3wBF;AACkC,EAAA;AACpC,IAAA;AAC7B,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;AAEgD,EAAA;AACzB,IAAA;AAIQ,IAAA;AACvB,IAAA;AACR,EAAA;AACD;AXmwBkC;AACA;AYzzBH;AAC9B,EAAA;AAEqC,EAAA;AACxB,IAAA;AAGe,IAAA;AAC5B,EAAA;AACD;AZwzBkC;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 properties returned by the server.\n * - `lastPublishedDate`: Derived publish timestamp for API consumers.\n */\nconst PageStructureOutputPropertiesSchema = BasePagePropertiesSchema.extend({\n\tlastPublishedDate: z.string().datetime().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: PageStructureOutputPropertiesSchema,\n\tchildren: z.array(SliceApiOutputSchema),\n});\n\n/**\n * Array of Page Structures\n */\nexport const ListPagesOutputSchema = z.array(PageStructureOutputSchema);\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\tListPagesOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\nexport type ListPagesOptions = {\n\tpageCategory?: string;\n};\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\tasync listPages(options: ListPagesOptions = {}) {\n\t\tconst query = options.pageCategory\n\t\t\t? `?${new URLSearchParams({ pageCategory: options.pageCategory })}`\n\t\t\t: \"\";\n\n\t\tconst result = await this.get(`/v1/page${query}`, ListPagesOutputSchema);\n\t\treturn result;\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
|
@@ -754,6 +754,9 @@ var BasePagePropertiesSchema = z4.object({
|
|
|
754
754
|
sponsorImage: z4.string().url().optional(),
|
|
755
755
|
pageCategory: z4.string().optional()
|
|
756
756
|
});
|
|
757
|
+
var PageStructureOutputPropertiesSchema = BasePagePropertiesSchema.extend({
|
|
758
|
+
lastPublishedDate: z4.string().datetime().optional()
|
|
759
|
+
});
|
|
757
760
|
var PageStructureInputSchema = z4.object({
|
|
758
761
|
properties: BasePagePropertiesSchema,
|
|
759
762
|
children: z4.array(SliceApiInputSchema)
|
|
@@ -761,7 +764,7 @@ var PageStructureInputSchema = z4.object({
|
|
|
761
764
|
var PageStructureOutputSchema = z4.object({
|
|
762
765
|
type: z4.literal("Page"),
|
|
763
766
|
schemaVersion: z4.number(),
|
|
764
|
-
properties:
|
|
767
|
+
properties: PageStructureOutputPropertiesSchema,
|
|
765
768
|
children: z4.array(SliceApiOutputSchema)
|
|
766
769
|
});
|
|
767
770
|
var ListPagesOutputSchema = z4.array(PageStructureOutputSchema);
|
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\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 * Array of Page Structures\n */\nexport const ListPagesOutputSchema = z.array(PageStructureOutputSchema);\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\tListPagesOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\nexport type ListPagesOptions = {\n\tpageCategory?: string;\n};\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\tasync listPages(options: ListPagesOptions = {}) {\n\t\tconst query = options.pageCategory\n\t\t\t? `?${new URLSearchParams({ pageCategory: options.pageCategory })}`\n\t\t\t: \"\";\n\n\t\tconst result = await this.get(`/v1/page${query}`, ListPagesOutputSchema);\n\t\treturn result;\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: ApiClientCon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;ACrDO,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 properties returned by the server.\n * - `lastPublishedDate`: Derived publish timestamp for API consumers.\n */\nconst PageStructureOutputPropertiesSchema = BasePagePropertiesSchema.extend({\n\tlastPublishedDate: z.string().datetime().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: PageStructureOutputPropertiesSchema,\n\tchildren: z.array(SliceApiOutputSchema),\n});\n\n/**\n * Array of Page Structures\n */\nexport const ListPagesOutputSchema = z.array(PageStructureOutputSchema);\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\tListPagesOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\nexport type ListPagesOptions = {\n\tpageCategory?: string;\n};\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\tasync listPages(options: ListPagesOptions = {}) {\n\t\tconst query = options.pageCategory\n\t\t\t? `?${new URLSearchParams({ pageCategory: options.pageCategory })}`\n\t\t\t: \"\";\n\n\t\tconst result = await this.get(`/v1/page${query}`, ListPagesOutputSchema);\n\t\treturn result;\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,EACA;AAAA,EAEhB,YACC,SACA,YACA,WACA,WAAmD,CAAC,GACnD;AACD,UAAM,SAAS,YAAY,WAAW;AAAA,MACrC,GAAG;AA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