@financial-times/content-curation-client 5.3.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/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 z3 } from "zod";
608
+ import { z as z4 } from "zod";
528
609
 
529
610
  // src/schemas/prosemirror.ts
530
- import { z as z2 } from "zod";
531
- var HrefSchema = z2.string().refine((v) => /^(https?:\/\/|mailto:).+/.test(v), {
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 = z2.object({
535
- type: z2.literal("link"),
536
- attrs: z2.object({
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 = z2.discriminatedUnion("type", [
621
+ var ProseMirrorMark = z3.discriminatedUnion("type", [
541
622
  ProseMirrorLinkMark,
542
- z2.object({ type: z2.literal("bold") }),
543
- z2.object({ type: z2.literal("italic") }),
544
- z2.object({ type: z2.literal("underline") }),
545
- z2.object({ type: z2.literal("strike") })
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 = z2.object({
548
- type: z2.literal("text"),
549
- text: z2.string(),
550
- marks: z2.array(ProseMirrorMark).optional()
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 = z2.object({
553
- type: z2.literal("paragraph"),
554
- content: z2.array(ProseMirrorTextNode)
633
+ var ProseMirrorParagraphNode = z3.object({
634
+ type: z3.literal("paragraph"),
635
+ content: z3.array(ProseMirrorTextNode)
555
636
  });
556
- var ProseMirrorNode = z2.union([ProseMirrorParagraphNode, ProseMirrorTextNode]);
557
- var ProseMirrorDocSchema = z2.object({
558
- type: z2.literal("doc"),
559
- content: z2.array(ProseMirrorNode).min(1, { message: "Document must contain at least one paragraph" })
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 = z3.object({
564
- text: z3.string(),
565
- href: z3.string().url().optional()
644
+ var HeadingSchema = z4.object({
645
+ text: z4.string(),
646
+ href: z4.string().url().optional()
566
647
  });
567
- var BasePageItemProps = z3.object({
648
+ var BasePageItemProps = z4.object({
568
649
  heading: HeadingSchema.optional()
569
650
  });
570
- var ValidJSONStringSchema = z3.string().refine(
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 = z3.object({
584
- type: z3.literal(typeName),
585
- hidden: z3.boolean().optional(),
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: z3.string().uuid().optional()
670
+ sliceId: z4.string().uuid().optional()
590
671
  });
591
672
  const OutputSchema = BaseSchema.extend({
592
- sliceId: z3.string().uuid()
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: z3.string().optional(),
680
+ flourishDescription: z4.string().optional(),
604
681
  // Optional description for the Flourish graphic
605
- flourishId: z3.string().nonempty(),
606
- flourishAltText: z3.string().nonempty(),
607
- storyUUID: z3.string().uuid().optional(),
608
- theme: z3.string().optional()
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: z3.string().nonempty(),
691
+ experimentId: z4.string().nonempty(),
615
692
  // Unique ID for the experiment
616
- experimentName: z3.string().nonempty(),
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: z3.string().uuid(),
702
+ listId: z4.string().uuid(),
626
703
  // The ID of the strip to display
627
- maxStories: z3.number().int().min(1).max(20)
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,167 +709,59 @@ var TopperSlice = defineSliceSchema({
632
709
  typeName: "Topper",
633
710
  propsShape: BasePageItemProps.extend({
634
711
  description: ProseMirrorDocSchema,
635
- strapline: z3.string().optional()
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: z3.string().uuid(),
718
+ listId: z4.string().uuid(),
642
719
  // The ID of the spark list to display
643
- maxStories: z3.number().int().min(1).max(20)
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
- var SliceApiInputSchema = z3.discriminatedUnion("type", [
648
- HomepageSlice.InputSchema,
724
+ var StoryGroupSlice = defineSliceSchema({
725
+ typeName: "StoryGroup",
726
+ propsShape: BasePageItemProps.extend({
727
+ storySlots: z4.array(z4.string().uuid()).nonempty()
728
+ })
729
+ });
730
+ var SliceApiInputSchema = z4.discriminatedUnion("type", [
649
731
  InteractiveSlice.InputSchema,
650
732
  ExperimentSlice.InputSchema,
651
733
  StripSlice.InputSchema,
652
734
  TopperSlice.InputSchema,
653
- HeroSlice.InputSchema
735
+ HeroSlice.InputSchema,
736
+ StoryGroupSlice.InputSchema
654
737
  ]);
655
- var SliceApiOutputSchema = z3.discriminatedUnion("type", [
656
- HomepageSlice.OutputSchema,
738
+ var SliceApiOutputSchema = z4.discriminatedUnion("type", [
657
739
  InteractiveSlice.OutputSchema,
658
740
  ExperimentSlice.OutputSchema,
659
741
  StripSlice.OutputSchema,
660
742
  TopperSlice.OutputSchema,
661
- HeroSlice.OutputSchema
743
+ HeroSlice.OutputSchema,
744
+ StoryGroupSlice.OutputSchema
662
745
  ]);
663
- var BasePagePropertiesSchema = z3.object({
664
- title: z3.string(),
665
- pageId: z3.string().uuid(),
666
- publicationId: z3.string(),
667
- conceptId: z3.string().uuid().optional(),
668
- metaDescription: z3.string().optional(),
669
- pageTheme: z3.string().optional(),
670
- sponsorText: z3.string().optional(),
671
- sponsorImage: z3.string().url().optional()
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()
672
755
  });
673
- var PageStructureInputSchema = z3.object({
756
+ var PageStructureInputSchema = z4.object({
674
757
  properties: BasePagePropertiesSchema,
675
- children: z3.array(SliceApiInputSchema)
676
- });
677
- var HomepageStructureInputSchema = PageStructureInputSchema.extend({
678
- properties: BasePagePropertiesSchema.extend({
679
- // This is optional for the input. If clients don't send it, we generate a uuid.
680
- homepageListId: z3.string().uuid()
681
- })
758
+ children: z4.array(SliceApiInputSchema)
682
759
  });
683
- var PageStructureOutputSchema = z3.object({
684
- type: z3.literal("Page"),
685
- schemaVersion: z3.number(),
760
+ var PageStructureOutputSchema = z4.object({
761
+ type: z4.literal("Page"),
762
+ schemaVersion: z4.number(),
686
763
  properties: BasePagePropertiesSchema,
687
- children: z3.array(SliceApiOutputSchema)
688
- });
689
- var HomepageStructureOutputSchema = PageStructureOutputSchema.extend({
690
- type: z3.literal("Homepage"),
691
- properties: BasePagePropertiesSchema.extend({
692
- homepageListId: z3.string().uuid()
693
- })
694
- });
695
-
696
- // src/homepage.ts
697
- var HomepageClient = class extends BaseApiClient {
698
- async getStructure(pageId) {
699
- return this.get(`/v1/homepage/${pageId}/structure`, HomepageStructureOutputSchema);
700
- }
701
- async getStructuresByHomepageListId(homepageListId) {
702
- return this.get(
703
- `/v1/homepage/list/${homepageListId}/structures`,
704
- HomepageStructureOutputSchema.array()
705
- );
706
- }
707
- async upsertStructure(pageId, data) {
708
- return this.put(
709
- `/v1/homepage/${pageId}/structure`,
710
- data,
711
- HomepageStructureInputSchema,
712
- HomepageStructureOutputSchema
713
- );
714
- }
715
- };
716
-
717
- // src/schemas/ftpink/legacyHubPage/index.ts
718
- import { z as z4 } from "zod";
719
- var LegacyFlourishChildSchema = z4.object({
720
- source: z4.literal("flourish"),
721
- properties: z4.object({
722
- id: z4.string().min(1)
723
- // e.g. "visualisation/21901162"
724
- })
725
- });
726
- var LegacyListChildSchema = z4.object({
727
- source: z4.literal("list"),
728
- properties: z4.object({
729
- id: z4.string().uuid(),
730
- maxItems: z4.number().optional()
731
- })
732
- });
733
- var LegacyContentChildSchema = z4.object({
734
- source: z4.literal("content"),
735
- properties: z4.object({
736
- ids: z4.array(z4.string()).nonempty()
737
- })
738
- });
739
- var LegacyContainerChildSchema = z4.discriminatedUnion("source", [
740
- LegacyFlourishChildSchema,
741
- LegacyListChildSchema,
742
- LegacyContentChildSchema
743
- ]);
744
- var LegacyTopperSchema = z4.object({
745
- type: z4.literal("topper-basic"),
746
- properties: z4.object({
747
- title: z4.string(),
748
- sponsorText: z4.string().optional(),
749
- sponsorImage: z4.string().url().optional()
750
- })
751
- });
752
- var LegacyInfoBoxSchema = z4.object({
753
- type: z4.literal("info-box"),
754
- properties: z4.object({
755
- bodyHTML: z4.string(),
756
- title: z4.string().optional()
757
- })
758
- });
759
- var LegacyContainerSchema = z4.object({
760
- type: z4.literal("container"),
761
- children: z4.array(LegacyContainerChildSchema).min(1),
762
- properties: z4.object({
763
- title: z4.string().optional(),
764
- design: z4.enum(["chart", "four-story", "freeform", "hero-lead"]).default("freeform"),
765
- backgroundColor: z4.string().optional()
766
- })
767
- });
768
- var LegacyExperimentSchema = z4.object({
769
- type: z4.literal("experiment"),
770
- children: z4.tuple([]),
771
- properties: z4.object({
772
- experimentName: z4.string(),
773
- id: z4.string(),
774
- title: z4.string().optional(),
775
- config: z4.object({
776
- value: z4.unknown().optional(),
777
- // Hub pages support experiments with HTML and Text.
778
- // For now we just support JSON. As we migrate pages, this may change.
779
- format: z4.enum(["json"]).default("json")
780
- }).partial().optional()
781
- })
782
- });
783
- var LegacyBlockSchema = z4.discriminatedUnion("type", [
784
- LegacyTopperSchema,
785
- LegacyInfoBoxSchema,
786
- LegacyContainerSchema,
787
- LegacyExperimentSchema
788
- ]);
789
- var LegacyPageStructureOutputSchema = z4.object({
790
- uuid: z4.string().uuid(),
791
- title: z4.string(),
792
- conceptId: z4.string().uuid().optional(),
793
- themeName: z4.string().optional(),
794
- metaDescription: z4.string().optional(),
795
- blocks: z4.array(LegacyBlockSchema)
764
+ children: z4.array(SliceApiOutputSchema)
796
765
  });
797
766
 
798
767
  // src/schemas/ftpink/draft/index.ts
@@ -853,14 +822,9 @@ var PageClient = class extends BaseApiClient {
853
822
 
854
823
  // src/client.ts
855
824
  var ApiClient = class extends BaseApiClient {
856
- /**
857
- * Homepage API endpoints
858
- */
859
- homepage;
860
825
  page;
861
826
  constructor(config) {
862
827
  super(config);
863
- this.homepage = new HomepageClient(config);
864
828
  this.page = new PageClient(config);
865
829
  }
866
830
  };
@@ -878,9 +842,6 @@ export {
878
842
  DraftContributorInputSchema,
879
843
  DraftContributorSchema,
880
844
  DraftSchema,
881
- HomepageClient,
882
- HomepageStructureInputSchema,
883
- HomepageStructureOutputSchema,
884
845
  LegacyPageStructureOutputSchema,
885
846
  PageClient,
886
847
  PageDraftSchema,