@financial-times/content-curation-client 5.4.0 → 6.0.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/README.md +2 -51
- package/dist/_tsup-dts-rollup.d.cts +237 -3211
- package/dist/_tsup-dts-rollup.d.ts +237 -3211
- package/dist/index.cjs +82 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +143 -190
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -523,51 +523,132 @@ function trimTrailingSlashes(value) {
|
|
|
523
523
|
return end === value.length ? value : value.slice(0, end);
|
|
524
524
|
}
|
|
525
525
|
|
|
526
|
+
// src/schemas/ftpink/legacyHubPage/index.ts
|
|
527
|
+
import { z as z2 } from "zod";
|
|
528
|
+
var LegacyFlourishChildSchema = z2.object({
|
|
529
|
+
source: z2.literal("flourish"),
|
|
530
|
+
properties: z2.object({
|
|
531
|
+
id: z2.string().min(1)
|
|
532
|
+
// e.g. "visualisation/21901162"
|
|
533
|
+
})
|
|
534
|
+
});
|
|
535
|
+
var LegacyListChildSchema = z2.object({
|
|
536
|
+
source: z2.literal("list"),
|
|
537
|
+
properties: z2.object({
|
|
538
|
+
id: z2.string().uuid(),
|
|
539
|
+
maxItems: z2.number().optional()
|
|
540
|
+
})
|
|
541
|
+
});
|
|
542
|
+
var LegacyContentChildSchema = z2.object({
|
|
543
|
+
source: z2.literal("content"),
|
|
544
|
+
properties: z2.object({
|
|
545
|
+
ids: z2.array(z2.string()).nonempty()
|
|
546
|
+
})
|
|
547
|
+
});
|
|
548
|
+
var LegacyContainerChildSchema = z2.discriminatedUnion("source", [
|
|
549
|
+
LegacyFlourishChildSchema,
|
|
550
|
+
LegacyListChildSchema,
|
|
551
|
+
LegacyContentChildSchema
|
|
552
|
+
]);
|
|
553
|
+
var LegacyTopperSchema = z2.object({
|
|
554
|
+
type: z2.literal("topper-basic"),
|
|
555
|
+
properties: z2.object({
|
|
556
|
+
title: z2.string(),
|
|
557
|
+
sponsorText: z2.string().optional(),
|
|
558
|
+
sponsorImage: z2.string().url().optional()
|
|
559
|
+
})
|
|
560
|
+
});
|
|
561
|
+
var LegacyInfoBoxSchema = z2.object({
|
|
562
|
+
type: z2.literal("info-box"),
|
|
563
|
+
properties: z2.object({
|
|
564
|
+
bodyHTML: z2.string(),
|
|
565
|
+
title: z2.string().optional()
|
|
566
|
+
})
|
|
567
|
+
});
|
|
568
|
+
var LegacyContainerSchema = z2.object({
|
|
569
|
+
type: z2.literal("container"),
|
|
570
|
+
children: z2.array(LegacyContainerChildSchema).min(1),
|
|
571
|
+
properties: z2.object({
|
|
572
|
+
title: z2.string().optional(),
|
|
573
|
+
design: z2.enum(["chart", "four-story", "freeform", "hero-lead"]).default("freeform"),
|
|
574
|
+
backgroundColor: z2.string().optional()
|
|
575
|
+
})
|
|
576
|
+
});
|
|
577
|
+
var LegacyExperimentSchema = z2.object({
|
|
578
|
+
type: z2.literal("experiment"),
|
|
579
|
+
children: z2.tuple([]),
|
|
580
|
+
properties: z2.object({
|
|
581
|
+
experimentName: z2.string(),
|
|
582
|
+
id: z2.string(),
|
|
583
|
+
title: z2.string().optional(),
|
|
584
|
+
config: z2.object({
|
|
585
|
+
value: z2.unknown().optional(),
|
|
586
|
+
// Hub pages support experiments with HTML and Text.
|
|
587
|
+
// For now we just support JSON. As we migrate pages, this may change.
|
|
588
|
+
format: z2.enum(["json"]).default("json")
|
|
589
|
+
}).partial().optional()
|
|
590
|
+
})
|
|
591
|
+
});
|
|
592
|
+
var LegacyBlockSchema = z2.discriminatedUnion("type", [
|
|
593
|
+
LegacyTopperSchema,
|
|
594
|
+
LegacyInfoBoxSchema,
|
|
595
|
+
LegacyContainerSchema,
|
|
596
|
+
LegacyExperimentSchema
|
|
597
|
+
]);
|
|
598
|
+
var LegacyPageStructureOutputSchema = z2.object({
|
|
599
|
+
uuid: z2.string().uuid(),
|
|
600
|
+
title: z2.string(),
|
|
601
|
+
conceptId: z2.string().uuid().optional(),
|
|
602
|
+
themeName: z2.string().optional(),
|
|
603
|
+
metaDescription: z2.string().optional(),
|
|
604
|
+
blocks: z2.array(LegacyBlockSchema)
|
|
605
|
+
});
|
|
606
|
+
|
|
526
607
|
// src/schemas/ftpink/page/index.ts
|
|
527
|
-
import { z as
|
|
608
|
+
import { z as z4 } from "zod";
|
|
528
609
|
|
|
529
610
|
// src/schemas/prosemirror.ts
|
|
530
|
-
import { z as
|
|
531
|
-
var HrefSchema =
|
|
611
|
+
import { z as z3 } from "zod";
|
|
612
|
+
var HrefSchema = z3.string().refine((v) => /^(https?:\/\/|mailto:).+/.test(v), {
|
|
532
613
|
message: "Expected http(s):// or mailto: URL"
|
|
533
614
|
});
|
|
534
|
-
var ProseMirrorLinkMark =
|
|
535
|
-
type:
|
|
536
|
-
attrs:
|
|
615
|
+
var ProseMirrorLinkMark = z3.object({
|
|
616
|
+
type: z3.literal("link"),
|
|
617
|
+
attrs: z3.object({
|
|
537
618
|
href: HrefSchema
|
|
538
619
|
})
|
|
539
620
|
});
|
|
540
|
-
var ProseMirrorMark =
|
|
621
|
+
var ProseMirrorMark = z3.discriminatedUnion("type", [
|
|
541
622
|
ProseMirrorLinkMark,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
623
|
+
z3.object({ type: z3.literal("bold") }),
|
|
624
|
+
z3.object({ type: z3.literal("italic") }),
|
|
625
|
+
z3.object({ type: z3.literal("underline") }),
|
|
626
|
+
z3.object({ type: z3.literal("strike") })
|
|
546
627
|
]);
|
|
547
|
-
var ProseMirrorTextNode =
|
|
548
|
-
type:
|
|
549
|
-
text:
|
|
550
|
-
marks:
|
|
628
|
+
var ProseMirrorTextNode = z3.object({
|
|
629
|
+
type: z3.literal("text"),
|
|
630
|
+
text: z3.string(),
|
|
631
|
+
marks: z3.array(ProseMirrorMark).optional()
|
|
551
632
|
});
|
|
552
|
-
var ProseMirrorParagraphNode =
|
|
553
|
-
type:
|
|
554
|
-
content:
|
|
633
|
+
var ProseMirrorParagraphNode = z3.object({
|
|
634
|
+
type: z3.literal("paragraph"),
|
|
635
|
+
content: z3.array(ProseMirrorTextNode)
|
|
555
636
|
});
|
|
556
|
-
var ProseMirrorNode =
|
|
557
|
-
var ProseMirrorDocSchema =
|
|
558
|
-
type:
|
|
559
|
-
content:
|
|
637
|
+
var ProseMirrorNode = z3.union([ProseMirrorParagraphNode, ProseMirrorTextNode]);
|
|
638
|
+
var ProseMirrorDocSchema = z3.object({
|
|
639
|
+
type: z3.literal("doc"),
|
|
640
|
+
content: z3.array(ProseMirrorNode).min(1, { message: "Document must contain at least one paragraph" })
|
|
560
641
|
});
|
|
561
642
|
|
|
562
643
|
// src/schemas/ftpink/page/index.ts
|
|
563
|
-
var HeadingSchema =
|
|
564
|
-
text:
|
|
565
|
-
href:
|
|
644
|
+
var HeadingSchema = z4.object({
|
|
645
|
+
text: z4.string(),
|
|
646
|
+
href: z4.string().url().optional()
|
|
566
647
|
});
|
|
567
|
-
var BasePageItemProps =
|
|
648
|
+
var BasePageItemProps = z4.object({
|
|
568
649
|
heading: HeadingSchema.optional()
|
|
569
650
|
});
|
|
570
|
-
var ValidJSONStringSchema =
|
|
651
|
+
var ValidJSONStringSchema = z4.string().refine(
|
|
571
652
|
(val) => {
|
|
572
653
|
try {
|
|
573
654
|
JSON.parse(val);
|
|
@@ -580,40 +661,36 @@ var ValidJSONStringSchema = z3.string().refine(
|
|
|
580
661
|
);
|
|
581
662
|
function defineSliceSchema(options) {
|
|
582
663
|
const { typeName, propsShape } = options;
|
|
583
|
-
const BaseSchema =
|
|
584
|
-
type:
|
|
585
|
-
hidden:
|
|
664
|
+
const BaseSchema = z4.object({
|
|
665
|
+
type: z4.literal(typeName),
|
|
666
|
+
hidden: z4.boolean().optional(),
|
|
586
667
|
properties: propsShape
|
|
587
668
|
});
|
|
588
669
|
const InputSchema = BaseSchema.extend({
|
|
589
|
-
sliceId:
|
|
670
|
+
sliceId: z4.string().uuid().optional()
|
|
590
671
|
});
|
|
591
672
|
const OutputSchema = BaseSchema.extend({
|
|
592
|
-
sliceId:
|
|
673
|
+
sliceId: z4.string().uuid()
|
|
593
674
|
});
|
|
594
675
|
return { InputSchema, OutputSchema };
|
|
595
676
|
}
|
|
596
|
-
var HomepageSlice = defineSliceSchema({
|
|
597
|
-
typeName: "HomepageSlice",
|
|
598
|
-
propsShape: BasePageItemProps.optional()
|
|
599
|
-
});
|
|
600
677
|
var InteractiveSlice = defineSliceSchema({
|
|
601
678
|
typeName: "Interactive",
|
|
602
679
|
propsShape: BasePageItemProps.extend({
|
|
603
|
-
flourishDescription:
|
|
680
|
+
flourishDescription: z4.string().optional(),
|
|
604
681
|
// Optional description for the Flourish graphic
|
|
605
|
-
flourishId:
|
|
606
|
-
flourishAltText:
|
|
607
|
-
storyUUID:
|
|
608
|
-
theme:
|
|
682
|
+
flourishId: z4.string().nonempty(),
|
|
683
|
+
flourishAltText: z4.string().nonempty(),
|
|
684
|
+
storyUUID: z4.string().uuid().optional(),
|
|
685
|
+
theme: z4.string().optional()
|
|
609
686
|
})
|
|
610
687
|
});
|
|
611
688
|
var ExperimentSlice = defineSliceSchema({
|
|
612
689
|
typeName: "Experiment",
|
|
613
690
|
propsShape: BasePageItemProps.extend({
|
|
614
|
-
experimentId:
|
|
691
|
+
experimentId: z4.string().nonempty(),
|
|
615
692
|
// Unique ID for the experiment
|
|
616
|
-
experimentName:
|
|
693
|
+
experimentName: z4.string().nonempty(),
|
|
617
694
|
// Human-readable name of the experiment
|
|
618
695
|
contentJson: ValidJSONStringSchema
|
|
619
696
|
// The experiment’s JSON payload as a valid JSON string
|
|
@@ -622,9 +699,9 @@ var ExperimentSlice = defineSliceSchema({
|
|
|
622
699
|
var StripSlice = defineSliceSchema({
|
|
623
700
|
typeName: "Strip",
|
|
624
701
|
propsShape: BasePageItemProps.extend({
|
|
625
|
-
listId:
|
|
702
|
+
listId: z4.string().uuid(),
|
|
626
703
|
// The ID of the strip to display
|
|
627
|
-
maxStories:
|
|
704
|
+
maxStories: z4.number().int().min(1).max(20)
|
|
628
705
|
// Maximum number of stories to display in the strip
|
|
629
706
|
})
|
|
630
707
|
});
|
|
@@ -632,26 +709,25 @@ var TopperSlice = defineSliceSchema({
|
|
|
632
709
|
typeName: "Topper",
|
|
633
710
|
propsShape: BasePageItemProps.extend({
|
|
634
711
|
description: ProseMirrorDocSchema,
|
|
635
|
-
strapline:
|
|
712
|
+
strapline: z4.string().optional()
|
|
636
713
|
})
|
|
637
714
|
});
|
|
638
715
|
var HeroSlice = defineSliceSchema({
|
|
639
716
|
typeName: "Hero",
|
|
640
717
|
propsShape: BasePageItemProps.extend({
|
|
641
|
-
listId:
|
|
718
|
+
listId: z4.string().uuid(),
|
|
642
719
|
// The ID of the spark list to display
|
|
643
|
-
maxStories:
|
|
720
|
+
maxStories: z4.number().int().min(1).max(20)
|
|
644
721
|
// Maximum number of stories to display in the hero
|
|
645
722
|
})
|
|
646
723
|
});
|
|
647
724
|
var StoryGroupSlice = defineSliceSchema({
|
|
648
725
|
typeName: "StoryGroup",
|
|
649
726
|
propsShape: BasePageItemProps.extend({
|
|
650
|
-
storySlots:
|
|
727
|
+
storySlots: z4.array(z4.string().uuid()).nonempty()
|
|
651
728
|
})
|
|
652
729
|
});
|
|
653
|
-
var SliceApiInputSchema =
|
|
654
|
-
HomepageSlice.InputSchema,
|
|
730
|
+
var SliceApiInputSchema = z4.discriminatedUnion("type", [
|
|
655
731
|
InteractiveSlice.InputSchema,
|
|
656
732
|
ExperimentSlice.InputSchema,
|
|
657
733
|
StripSlice.InputSchema,
|
|
@@ -659,8 +735,7 @@ var SliceApiInputSchema = z3.discriminatedUnion("type", [
|
|
|
659
735
|
HeroSlice.InputSchema,
|
|
660
736
|
StoryGroupSlice.InputSchema
|
|
661
737
|
]);
|
|
662
|
-
var SliceApiOutputSchema =
|
|
663
|
-
HomepageSlice.OutputSchema,
|
|
738
|
+
var SliceApiOutputSchema = z4.discriminatedUnion("type", [
|
|
664
739
|
InteractiveSlice.OutputSchema,
|
|
665
740
|
ExperimentSlice.OutputSchema,
|
|
666
741
|
StripSlice.OutputSchema,
|
|
@@ -668,139 +743,25 @@ var SliceApiOutputSchema = z3.discriminatedUnion("type", [
|
|
|
668
743
|
HeroSlice.OutputSchema,
|
|
669
744
|
StoryGroupSlice.OutputSchema
|
|
670
745
|
]);
|
|
671
|
-
var BasePagePropertiesSchema =
|
|
672
|
-
title:
|
|
673
|
-
pageId:
|
|
674
|
-
publicationId:
|
|
675
|
-
conceptId:
|
|
676
|
-
metaDescription:
|
|
677
|
-
pageTheme:
|
|
678
|
-
sponsorText:
|
|
679
|
-
sponsorImage:
|
|
746
|
+
var BasePagePropertiesSchema = z4.object({
|
|
747
|
+
title: z4.string(),
|
|
748
|
+
pageId: z4.string().uuid(),
|
|
749
|
+
publicationId: z4.string(),
|
|
750
|
+
conceptId: z4.string().uuid().optional(),
|
|
751
|
+
metaDescription: z4.string().optional(),
|
|
752
|
+
pageTheme: z4.string().optional(),
|
|
753
|
+
sponsorText: z4.string().optional(),
|
|
754
|
+
sponsorImage: z4.string().url().optional()
|
|
680
755
|
});
|
|
681
|
-
var PageStructureInputSchema =
|
|
756
|
+
var PageStructureInputSchema = z4.object({
|
|
682
757
|
properties: BasePagePropertiesSchema,
|
|
683
|
-
children:
|
|
758
|
+
children: z4.array(SliceApiInputSchema)
|
|
684
759
|
});
|
|
685
|
-
var
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
homepageListId: z3.string().uuid()
|
|
689
|
-
})
|
|
690
|
-
});
|
|
691
|
-
var PageStructureOutputSchema = z3.object({
|
|
692
|
-
type: z3.literal("Page"),
|
|
693
|
-
schemaVersion: z3.number(),
|
|
760
|
+
var PageStructureOutputSchema = z4.object({
|
|
761
|
+
type: z4.literal("Page"),
|
|
762
|
+
schemaVersion: z4.number(),
|
|
694
763
|
properties: BasePagePropertiesSchema,
|
|
695
|
-
children:
|
|
696
|
-
});
|
|
697
|
-
var HomepageStructureOutputSchema = PageStructureOutputSchema.extend({
|
|
698
|
-
type: z3.literal("Homepage"),
|
|
699
|
-
properties: BasePagePropertiesSchema.extend({
|
|
700
|
-
homepageListId: z3.string().uuid()
|
|
701
|
-
})
|
|
702
|
-
});
|
|
703
|
-
|
|
704
|
-
// src/homepage.ts
|
|
705
|
-
var HomepageClient = class extends BaseApiClient {
|
|
706
|
-
async getStructure(pageId) {
|
|
707
|
-
return this.get(`/v1/homepage/${pageId}/structure`, HomepageStructureOutputSchema);
|
|
708
|
-
}
|
|
709
|
-
async getStructuresByHomepageListId(homepageListId) {
|
|
710
|
-
return this.get(
|
|
711
|
-
`/v1/homepage/list/${homepageListId}/structures`,
|
|
712
|
-
HomepageStructureOutputSchema.array()
|
|
713
|
-
);
|
|
714
|
-
}
|
|
715
|
-
async upsertStructure(pageId, data) {
|
|
716
|
-
return this.put(
|
|
717
|
-
`/v1/homepage/${pageId}/structure`,
|
|
718
|
-
data,
|
|
719
|
-
HomepageStructureInputSchema,
|
|
720
|
-
HomepageStructureOutputSchema
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
|
|
725
|
-
// src/schemas/ftpink/legacyHubPage/index.ts
|
|
726
|
-
import { z as z4 } from "zod";
|
|
727
|
-
var LegacyFlourishChildSchema = z4.object({
|
|
728
|
-
source: z4.literal("flourish"),
|
|
729
|
-
properties: z4.object({
|
|
730
|
-
id: z4.string().min(1)
|
|
731
|
-
// e.g. "visualisation/21901162"
|
|
732
|
-
})
|
|
733
|
-
});
|
|
734
|
-
var LegacyListChildSchema = z4.object({
|
|
735
|
-
source: z4.literal("list"),
|
|
736
|
-
properties: z4.object({
|
|
737
|
-
id: z4.string().uuid(),
|
|
738
|
-
maxItems: z4.number().optional()
|
|
739
|
-
})
|
|
740
|
-
});
|
|
741
|
-
var LegacyContentChildSchema = z4.object({
|
|
742
|
-
source: z4.literal("content"),
|
|
743
|
-
properties: z4.object({
|
|
744
|
-
ids: z4.array(z4.string()).nonempty()
|
|
745
|
-
})
|
|
746
|
-
});
|
|
747
|
-
var LegacyContainerChildSchema = z4.discriminatedUnion("source", [
|
|
748
|
-
LegacyFlourishChildSchema,
|
|
749
|
-
LegacyListChildSchema,
|
|
750
|
-
LegacyContentChildSchema
|
|
751
|
-
]);
|
|
752
|
-
var LegacyTopperSchema = z4.object({
|
|
753
|
-
type: z4.literal("topper-basic"),
|
|
754
|
-
properties: z4.object({
|
|
755
|
-
title: z4.string(),
|
|
756
|
-
sponsorText: z4.string().optional(),
|
|
757
|
-
sponsorImage: z4.string().url().optional()
|
|
758
|
-
})
|
|
759
|
-
});
|
|
760
|
-
var LegacyInfoBoxSchema = z4.object({
|
|
761
|
-
type: z4.literal("info-box"),
|
|
762
|
-
properties: z4.object({
|
|
763
|
-
bodyHTML: z4.string(),
|
|
764
|
-
title: z4.string().optional()
|
|
765
|
-
})
|
|
766
|
-
});
|
|
767
|
-
var LegacyContainerSchema = z4.object({
|
|
768
|
-
type: z4.literal("container"),
|
|
769
|
-
children: z4.array(LegacyContainerChildSchema).min(1),
|
|
770
|
-
properties: z4.object({
|
|
771
|
-
title: z4.string().optional(),
|
|
772
|
-
design: z4.enum(["chart", "four-story", "freeform", "hero-lead"]).default("freeform"),
|
|
773
|
-
backgroundColor: z4.string().optional()
|
|
774
|
-
})
|
|
775
|
-
});
|
|
776
|
-
var LegacyExperimentSchema = z4.object({
|
|
777
|
-
type: z4.literal("experiment"),
|
|
778
|
-
children: z4.tuple([]),
|
|
779
|
-
properties: z4.object({
|
|
780
|
-
experimentName: z4.string(),
|
|
781
|
-
id: z4.string(),
|
|
782
|
-
title: z4.string().optional(),
|
|
783
|
-
config: z4.object({
|
|
784
|
-
value: z4.unknown().optional(),
|
|
785
|
-
// Hub pages support experiments with HTML and Text.
|
|
786
|
-
// For now we just support JSON. As we migrate pages, this may change.
|
|
787
|
-
format: z4.enum(["json"]).default("json")
|
|
788
|
-
}).partial().optional()
|
|
789
|
-
})
|
|
790
|
-
});
|
|
791
|
-
var LegacyBlockSchema = z4.discriminatedUnion("type", [
|
|
792
|
-
LegacyTopperSchema,
|
|
793
|
-
LegacyInfoBoxSchema,
|
|
794
|
-
LegacyContainerSchema,
|
|
795
|
-
LegacyExperimentSchema
|
|
796
|
-
]);
|
|
797
|
-
var LegacyPageStructureOutputSchema = z4.object({
|
|
798
|
-
uuid: z4.string().uuid(),
|
|
799
|
-
title: z4.string(),
|
|
800
|
-
conceptId: z4.string().uuid().optional(),
|
|
801
|
-
themeName: z4.string().optional(),
|
|
802
|
-
metaDescription: z4.string().optional(),
|
|
803
|
-
blocks: z4.array(LegacyBlockSchema)
|
|
764
|
+
children: z4.array(SliceApiOutputSchema)
|
|
804
765
|
});
|
|
805
766
|
|
|
806
767
|
// src/schemas/ftpink/draft/index.ts
|
|
@@ -861,14 +822,9 @@ var PageClient = class extends BaseApiClient {
|
|
|
861
822
|
|
|
862
823
|
// src/client.ts
|
|
863
824
|
var ApiClient = class extends BaseApiClient {
|
|
864
|
-
/**
|
|
865
|
-
* Homepage API endpoints
|
|
866
|
-
*/
|
|
867
|
-
homepage;
|
|
868
825
|
page;
|
|
869
826
|
constructor(config) {
|
|
870
827
|
super(config);
|
|
871
|
-
this.homepage = new HomepageClient(config);
|
|
872
828
|
this.page = new PageClient(config);
|
|
873
829
|
}
|
|
874
830
|
};
|
|
@@ -886,9 +842,6 @@ export {
|
|
|
886
842
|
DraftContributorInputSchema,
|
|
887
843
|
DraftContributorSchema,
|
|
888
844
|
DraftSchema,
|
|
889
|
-
HomepageClient,
|
|
890
|
-
HomepageStructureInputSchema,
|
|
891
|
-
HomepageStructureOutputSchema,
|
|
892
845
|
LegacyPageStructureOutputSchema,
|
|
893
846
|
PageClient,
|
|
894
847
|
PageDraftSchema,
|