@financial-times/content-curation-client 0.1.1 → 0.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/README.md CHANGED
@@ -17,14 +17,18 @@ npm install @financial-times/content-curation-client
17
17
 
18
18
  ## Usage
19
19
 
20
+ ### API Key
21
+
22
+ If you don’t already have one, you can request an API Gateway key by completing the [API Key Request Form](https://apigateway.in.ft.com/key-form).
23
+
20
24
  ### Initialize the client
21
25
 
22
26
  ```typescript
23
27
  import { ApiClient } from "@financial-times/content-curation-client";
24
28
 
25
29
  const client = new ApiClient({
26
- baseUrl: "https://content-curation.eu-west-1.edtech-test.ftweb.tech/api",
27
- apiToken: "your-api-token",
30
+ baseUrl: "https://api-t.ft.com/content-curation",
31
+ apiKey: "your-api-key",
28
32
  });
29
33
  ```
30
34
 
@@ -146,7 +150,7 @@ import { ApiClient } from "@financial-times/content-curation-client";
146
150
 
147
151
  const client = new ApiClient({
148
152
  baseUrl: "https://your-api-url.com/api",
149
- apiToken: "your-api-token",
153
+ apiKey: "your-api-key",
150
154
  fetch: customFetchFunction,
151
155
  });
152
156
  ```
@@ -19,11 +19,17 @@ export { ApiClient as ApiClient_alias_1 }
19
19
  /**
20
20
  * Configuration options for the API client
21
21
  */
22
- declare interface ApiClientConfig {
22
+ declare type ApiClientConfig = {
23
23
  baseUrl: string;
24
+ apiKey: string;
25
+ apiToken?: never;
26
+ fetch?: typeof fetch;
27
+ } | {
28
+ baseUrl: string;
29
+ apiKey?: never;
24
30
  apiToken: string;
25
31
  fetch?: typeof fetch;
26
- }
32
+ };
27
33
  export { ApiClientConfig }
28
34
  export { ApiClientConfig as ApiClientConfig_alias_1 }
29
35
 
@@ -1674,11 +1680,537 @@ declare type InteractiveSlice = FlourishGraphicSliceType | CustomIframeSliceType
1674
1680
  export { InteractiveSlice }
1675
1681
  export { InteractiveSlice as InteractiveSlice_alias_1 }
1676
1682
 
1683
+ declare type LegacyBlock = z.infer<typeof LegacyBlockSchema>;
1684
+ export { LegacyBlock }
1685
+ export { LegacyBlock as LegacyBlock_alias_1 }
1686
+
1687
+ declare const LegacyBlockSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1688
+ type: z.ZodLiteral<"topper-basic">;
1689
+ children: z.ZodTuple<[], null>;
1690
+ properties: z.ZodObject<{
1691
+ title: z.ZodString;
1692
+ sponsorText: z.ZodDefault<z.ZodString>;
1693
+ }, "strip", z.ZodTypeAny, {
1694
+ title: string;
1695
+ sponsorText: string;
1696
+ }, {
1697
+ title: string;
1698
+ sponsorText?: string | undefined;
1699
+ }>;
1700
+ }, "strip", z.ZodTypeAny, {
1701
+ type: "topper-basic";
1702
+ properties: {
1703
+ title: string;
1704
+ sponsorText: string;
1705
+ };
1706
+ children: [];
1707
+ }, {
1708
+ type: "topper-basic";
1709
+ properties: {
1710
+ title: string;
1711
+ sponsorText?: string | undefined;
1712
+ };
1713
+ children: [];
1714
+ }>, z.ZodObject<{
1715
+ type: z.ZodLiteral<"info-box">;
1716
+ children: z.ZodTuple<[], null>;
1717
+ properties: z.ZodObject<{
1718
+ bodyHTML: z.ZodString;
1719
+ }, "strip", z.ZodTypeAny, {
1720
+ bodyHTML: string;
1721
+ }, {
1722
+ bodyHTML: string;
1723
+ }>;
1724
+ }, "strip", z.ZodTypeAny, {
1725
+ type: "info-box";
1726
+ properties: {
1727
+ bodyHTML: string;
1728
+ };
1729
+ children: [];
1730
+ }, {
1731
+ type: "info-box";
1732
+ properties: {
1733
+ bodyHTML: string;
1734
+ };
1735
+ children: [];
1736
+ }>, z.ZodObject<{
1737
+ type: z.ZodLiteral<"container">;
1738
+ children: z.ZodArray<z.ZodDiscriminatedUnion<"source", [z.ZodObject<{
1739
+ source: z.ZodLiteral<"flourish">;
1740
+ properties: z.ZodObject<{
1741
+ id: z.ZodString;
1742
+ }, "strip", z.ZodTypeAny, {
1743
+ id: string;
1744
+ }, {
1745
+ id: string;
1746
+ }>;
1747
+ }, "strip", z.ZodTypeAny, {
1748
+ properties: {
1749
+ id: string;
1750
+ };
1751
+ source: "flourish";
1752
+ }, {
1753
+ properties: {
1754
+ id: string;
1755
+ };
1756
+ source: "flourish";
1757
+ }>, z.ZodObject<{
1758
+ source: z.ZodLiteral<"list">;
1759
+ properties: z.ZodObject<{
1760
+ id: z.ZodString;
1761
+ maxItems: z.ZodOptional<z.ZodNumber>;
1762
+ }, "strip", z.ZodTypeAny, {
1763
+ id: string;
1764
+ maxItems?: number | undefined;
1765
+ }, {
1766
+ id: string;
1767
+ maxItems?: number | undefined;
1768
+ }>;
1769
+ }, "strip", z.ZodTypeAny, {
1770
+ properties: {
1771
+ id: string;
1772
+ maxItems?: number | undefined;
1773
+ };
1774
+ source: "list";
1775
+ }, {
1776
+ properties: {
1777
+ id: string;
1778
+ maxItems?: number | undefined;
1779
+ };
1780
+ source: "list";
1781
+ }>]>, "many">;
1782
+ properties: z.ZodObject<{
1783
+ title: z.ZodOptional<z.ZodString>;
1784
+ design: z.ZodDefault<z.ZodEnum<["chart", "four-story", "freeform", "hero-lead"]>>;
1785
+ backgroundColor: z.ZodOptional<z.ZodString>;
1786
+ }, "strip", z.ZodTypeAny, {
1787
+ design: "chart" | "four-story" | "freeform" | "hero-lead";
1788
+ title?: string | undefined;
1789
+ backgroundColor?: string | undefined;
1790
+ }, {
1791
+ title?: string | undefined;
1792
+ design?: "chart" | "four-story" | "freeform" | "hero-lead" | undefined;
1793
+ backgroundColor?: string | undefined;
1794
+ }>;
1795
+ }, "strip", z.ZodTypeAny, {
1796
+ type: "container";
1797
+ properties: {
1798
+ design: "chart" | "four-story" | "freeform" | "hero-lead";
1799
+ title?: string | undefined;
1800
+ backgroundColor?: string | undefined;
1801
+ };
1802
+ children: ({
1803
+ properties: {
1804
+ id: string;
1805
+ };
1806
+ source: "flourish";
1807
+ } | {
1808
+ properties: {
1809
+ id: string;
1810
+ maxItems?: number | undefined;
1811
+ };
1812
+ source: "list";
1813
+ })[];
1814
+ }, {
1815
+ type: "container";
1816
+ properties: {
1817
+ title?: string | undefined;
1818
+ design?: "chart" | "four-story" | "freeform" | "hero-lead" | undefined;
1819
+ backgroundColor?: string | undefined;
1820
+ };
1821
+ children: ({
1822
+ properties: {
1823
+ id: string;
1824
+ };
1825
+ source: "flourish";
1826
+ } | {
1827
+ properties: {
1828
+ id: string;
1829
+ maxItems?: number | undefined;
1830
+ };
1831
+ source: "list";
1832
+ })[];
1833
+ }>, z.ZodObject<{
1834
+ type: z.ZodLiteral<"experiment">;
1835
+ children: z.ZodTuple<[], null>;
1836
+ properties: z.ZodObject<{
1837
+ experimentName: z.ZodString;
1838
+ id: z.ZodString;
1839
+ title: z.ZodOptional<z.ZodString>;
1840
+ config: z.ZodOptional<z.ZodObject<{
1841
+ value: z.ZodOptional<z.ZodOptional<z.ZodUnknown>>;
1842
+ format: z.ZodOptional<z.ZodDefault<z.ZodEnum<["json"]>>>;
1843
+ }, "strip", z.ZodTypeAny, {
1844
+ format?: "json" | undefined;
1845
+ value?: unknown;
1846
+ }, {
1847
+ format?: "json" | undefined;
1848
+ value?: unknown;
1849
+ }>>;
1850
+ }, "strip", z.ZodTypeAny, {
1851
+ experimentName: string;
1852
+ id: string;
1853
+ config?: {
1854
+ format?: "json" | undefined;
1855
+ value?: unknown;
1856
+ } | undefined;
1857
+ title?: string | undefined;
1858
+ }, {
1859
+ experimentName: string;
1860
+ id: string;
1861
+ config?: {
1862
+ format?: "json" | undefined;
1863
+ value?: unknown;
1864
+ } | undefined;
1865
+ title?: string | undefined;
1866
+ }>;
1867
+ }, "strip", z.ZodTypeAny, {
1868
+ type: "experiment";
1869
+ properties: {
1870
+ experimentName: string;
1871
+ id: string;
1872
+ config?: {
1873
+ format?: "json" | undefined;
1874
+ value?: unknown;
1875
+ } | undefined;
1876
+ title?: string | undefined;
1877
+ };
1878
+ children: [];
1879
+ }, {
1880
+ type: "experiment";
1881
+ properties: {
1882
+ experimentName: string;
1883
+ id: string;
1884
+ config?: {
1885
+ format?: "json" | undefined;
1886
+ value?: unknown;
1887
+ } | undefined;
1888
+ title?: string | undefined;
1889
+ };
1890
+ children: [];
1891
+ }>]>;
1892
+
1893
+ declare type LegacyPageStructureOutput = z.infer<typeof LegacyPageStructureOutputSchema>;
1894
+ export { LegacyPageStructureOutput }
1895
+ export { LegacyPageStructureOutput as LegacyPageStructureOutput_alias_1 }
1896
+
1897
+ declare const LegacyPageStructureOutputSchema: z.ZodObject<{
1898
+ blocks: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1899
+ type: z.ZodLiteral<"topper-basic">;
1900
+ children: z.ZodTuple<[], null>;
1901
+ properties: z.ZodObject<{
1902
+ title: z.ZodString;
1903
+ sponsorText: z.ZodDefault<z.ZodString>;
1904
+ }, "strip", z.ZodTypeAny, {
1905
+ title: string;
1906
+ sponsorText: string;
1907
+ }, {
1908
+ title: string;
1909
+ sponsorText?: string | undefined;
1910
+ }>;
1911
+ }, "strip", z.ZodTypeAny, {
1912
+ type: "topper-basic";
1913
+ properties: {
1914
+ title: string;
1915
+ sponsorText: string;
1916
+ };
1917
+ children: [];
1918
+ }, {
1919
+ type: "topper-basic";
1920
+ properties: {
1921
+ title: string;
1922
+ sponsorText?: string | undefined;
1923
+ };
1924
+ children: [];
1925
+ }>, z.ZodObject<{
1926
+ type: z.ZodLiteral<"info-box">;
1927
+ children: z.ZodTuple<[], null>;
1928
+ properties: z.ZodObject<{
1929
+ bodyHTML: z.ZodString;
1930
+ }, "strip", z.ZodTypeAny, {
1931
+ bodyHTML: string;
1932
+ }, {
1933
+ bodyHTML: string;
1934
+ }>;
1935
+ }, "strip", z.ZodTypeAny, {
1936
+ type: "info-box";
1937
+ properties: {
1938
+ bodyHTML: string;
1939
+ };
1940
+ children: [];
1941
+ }, {
1942
+ type: "info-box";
1943
+ properties: {
1944
+ bodyHTML: string;
1945
+ };
1946
+ children: [];
1947
+ }>, z.ZodObject<{
1948
+ type: z.ZodLiteral<"container">;
1949
+ children: z.ZodArray<z.ZodDiscriminatedUnion<"source", [z.ZodObject<{
1950
+ source: z.ZodLiteral<"flourish">;
1951
+ properties: z.ZodObject<{
1952
+ id: z.ZodString;
1953
+ }, "strip", z.ZodTypeAny, {
1954
+ id: string;
1955
+ }, {
1956
+ id: string;
1957
+ }>;
1958
+ }, "strip", z.ZodTypeAny, {
1959
+ properties: {
1960
+ id: string;
1961
+ };
1962
+ source: "flourish";
1963
+ }, {
1964
+ properties: {
1965
+ id: string;
1966
+ };
1967
+ source: "flourish";
1968
+ }>, z.ZodObject<{
1969
+ source: z.ZodLiteral<"list">;
1970
+ properties: z.ZodObject<{
1971
+ id: z.ZodString;
1972
+ maxItems: z.ZodOptional<z.ZodNumber>;
1973
+ }, "strip", z.ZodTypeAny, {
1974
+ id: string;
1975
+ maxItems?: number | undefined;
1976
+ }, {
1977
+ id: string;
1978
+ maxItems?: number | undefined;
1979
+ }>;
1980
+ }, "strip", z.ZodTypeAny, {
1981
+ properties: {
1982
+ id: string;
1983
+ maxItems?: number | undefined;
1984
+ };
1985
+ source: "list";
1986
+ }, {
1987
+ properties: {
1988
+ id: string;
1989
+ maxItems?: number | undefined;
1990
+ };
1991
+ source: "list";
1992
+ }>]>, "many">;
1993
+ properties: z.ZodObject<{
1994
+ title: z.ZodOptional<z.ZodString>;
1995
+ design: z.ZodDefault<z.ZodEnum<["chart", "four-story", "freeform", "hero-lead"]>>;
1996
+ backgroundColor: z.ZodOptional<z.ZodString>;
1997
+ }, "strip", z.ZodTypeAny, {
1998
+ design: "chart" | "four-story" | "freeform" | "hero-lead";
1999
+ title?: string | undefined;
2000
+ backgroundColor?: string | undefined;
2001
+ }, {
2002
+ title?: string | undefined;
2003
+ design?: "chart" | "four-story" | "freeform" | "hero-lead" | undefined;
2004
+ backgroundColor?: string | undefined;
2005
+ }>;
2006
+ }, "strip", z.ZodTypeAny, {
2007
+ type: "container";
2008
+ properties: {
2009
+ design: "chart" | "four-story" | "freeform" | "hero-lead";
2010
+ title?: string | undefined;
2011
+ backgroundColor?: string | undefined;
2012
+ };
2013
+ children: ({
2014
+ properties: {
2015
+ id: string;
2016
+ };
2017
+ source: "flourish";
2018
+ } | {
2019
+ properties: {
2020
+ id: string;
2021
+ maxItems?: number | undefined;
2022
+ };
2023
+ source: "list";
2024
+ })[];
2025
+ }, {
2026
+ type: "container";
2027
+ properties: {
2028
+ title?: string | undefined;
2029
+ design?: "chart" | "four-story" | "freeform" | "hero-lead" | undefined;
2030
+ backgroundColor?: string | undefined;
2031
+ };
2032
+ children: ({
2033
+ properties: {
2034
+ id: string;
2035
+ };
2036
+ source: "flourish";
2037
+ } | {
2038
+ properties: {
2039
+ id: string;
2040
+ maxItems?: number | undefined;
2041
+ };
2042
+ source: "list";
2043
+ })[];
2044
+ }>, z.ZodObject<{
2045
+ type: z.ZodLiteral<"experiment">;
2046
+ children: z.ZodTuple<[], null>;
2047
+ properties: z.ZodObject<{
2048
+ experimentName: z.ZodString;
2049
+ id: z.ZodString;
2050
+ title: z.ZodOptional<z.ZodString>;
2051
+ config: z.ZodOptional<z.ZodObject<{
2052
+ value: z.ZodOptional<z.ZodOptional<z.ZodUnknown>>;
2053
+ format: z.ZodOptional<z.ZodDefault<z.ZodEnum<["json"]>>>;
2054
+ }, "strip", z.ZodTypeAny, {
2055
+ format?: "json" | undefined;
2056
+ value?: unknown;
2057
+ }, {
2058
+ format?: "json" | undefined;
2059
+ value?: unknown;
2060
+ }>>;
2061
+ }, "strip", z.ZodTypeAny, {
2062
+ experimentName: string;
2063
+ id: string;
2064
+ config?: {
2065
+ format?: "json" | undefined;
2066
+ value?: unknown;
2067
+ } | undefined;
2068
+ title?: string | undefined;
2069
+ }, {
2070
+ experimentName: string;
2071
+ id: string;
2072
+ config?: {
2073
+ format?: "json" | undefined;
2074
+ value?: unknown;
2075
+ } | undefined;
2076
+ title?: string | undefined;
2077
+ }>;
2078
+ }, "strip", z.ZodTypeAny, {
2079
+ type: "experiment";
2080
+ properties: {
2081
+ experimentName: string;
2082
+ id: string;
2083
+ config?: {
2084
+ format?: "json" | undefined;
2085
+ value?: unknown;
2086
+ } | undefined;
2087
+ title?: string | undefined;
2088
+ };
2089
+ children: [];
2090
+ }, {
2091
+ type: "experiment";
2092
+ properties: {
2093
+ experimentName: string;
2094
+ id: string;
2095
+ config?: {
2096
+ format?: "json" | undefined;
2097
+ value?: unknown;
2098
+ } | undefined;
2099
+ title?: string | undefined;
2100
+ };
2101
+ children: [];
2102
+ }>]>, "many">;
2103
+ conceptId: z.ZodOptional<z.ZodString>;
2104
+ themeName: z.ZodOptional<z.ZodString>;
2105
+ uuid: z.ZodString;
2106
+ }, "strip", z.ZodTypeAny, {
2107
+ blocks: ({
2108
+ type: "topper-basic";
2109
+ properties: {
2110
+ title: string;
2111
+ sponsorText: string;
2112
+ };
2113
+ children: [];
2114
+ } | {
2115
+ type: "info-box";
2116
+ properties: {
2117
+ bodyHTML: string;
2118
+ };
2119
+ children: [];
2120
+ } | {
2121
+ type: "container";
2122
+ properties: {
2123
+ design: "chart" | "four-story" | "freeform" | "hero-lead";
2124
+ title?: string | undefined;
2125
+ backgroundColor?: string | undefined;
2126
+ };
2127
+ children: ({
2128
+ properties: {
2129
+ id: string;
2130
+ };
2131
+ source: "flourish";
2132
+ } | {
2133
+ properties: {
2134
+ id: string;
2135
+ maxItems?: number | undefined;
2136
+ };
2137
+ source: "list";
2138
+ })[];
2139
+ } | {
2140
+ type: "experiment";
2141
+ properties: {
2142
+ experimentName: string;
2143
+ id: string;
2144
+ config?: {
2145
+ format?: "json" | undefined;
2146
+ value?: unknown;
2147
+ } | undefined;
2148
+ title?: string | undefined;
2149
+ };
2150
+ children: [];
2151
+ })[];
2152
+ uuid: string;
2153
+ conceptId?: string | undefined;
2154
+ themeName?: string | undefined;
2155
+ }, {
2156
+ blocks: ({
2157
+ type: "topper-basic";
2158
+ properties: {
2159
+ title: string;
2160
+ sponsorText?: string | undefined;
2161
+ };
2162
+ children: [];
2163
+ } | {
2164
+ type: "info-box";
2165
+ properties: {
2166
+ bodyHTML: string;
2167
+ };
2168
+ children: [];
2169
+ } | {
2170
+ type: "container";
2171
+ properties: {
2172
+ title?: string | undefined;
2173
+ design?: "chart" | "four-story" | "freeform" | "hero-lead" | undefined;
2174
+ backgroundColor?: string | undefined;
2175
+ };
2176
+ children: ({
2177
+ properties: {
2178
+ id: string;
2179
+ };
2180
+ source: "flourish";
2181
+ } | {
2182
+ properties: {
2183
+ id: string;
2184
+ maxItems?: number | undefined;
2185
+ };
2186
+ source: "list";
2187
+ })[];
2188
+ } | {
2189
+ type: "experiment";
2190
+ properties: {
2191
+ experimentName: string;
2192
+ id: string;
2193
+ config?: {
2194
+ format?: "json" | undefined;
2195
+ value?: unknown;
2196
+ } | undefined;
2197
+ title?: string | undefined;
2198
+ };
2199
+ children: [];
2200
+ })[];
2201
+ uuid: string;
2202
+ conceptId?: string | undefined;
2203
+ themeName?: string | undefined;
2204
+ }>;
2205
+ export { LegacyPageStructureOutputSchema }
2206
+ export { LegacyPageStructureOutputSchema as LegacyPageStructureOutputSchema_alias_1 }
2207
+
1677
2208
  /**
1678
2209
  * Client for Page structure endpoints
1679
2210
  */
1680
2211
  declare class PageClient extends BaseApiClient {
1681
2212
  getStructure(pageId: string): Promise<PageStructureOutput>;
2213
+ getLegacyHubPageStructure(pageId: string): Promise<LegacyPageStructureOutput>;
1682
2214
  upsertStructure(pageId: string, data: Omit<PageStructureInput, "type">): Promise<PageStructureOutput>;
1683
2215
  }
1684
2216
  export { PageClient }
@@ -2579,7 +3111,7 @@ export { Slice as Slice_alias_1 }
2579
3111
  * All possible slice inputs for the Page API.
2580
3112
  * This discriminated union allows Zod to pick the correct schema based on the `type` field.
2581
3113
  */
2582
- export declare const SliceApiInputSchema: z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
3114
+ declare const SliceApiInputSchema: z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
2583
3115
  type: z.ZodLiteral<"HomepageSlice">;
2584
3116
  hidden: z.ZodOptional<z.ZodBoolean>;
2585
3117
  properties: z.ZodOptional<z.ZodObject<{
@@ -2865,12 +3397,14 @@ export declare const SliceApiInputSchema: z.ZodDiscriminatedUnion<"type", readon
2865
3397
  hidden?: boolean | undefined;
2866
3398
  sliceId?: string | undefined;
2867
3399
  }>]>;
3400
+ export { SliceApiInputSchema }
3401
+ export { SliceApiInputSchema as SliceApiInputSchema_alias_1 }
2868
3402
 
2869
3403
  /**
2870
3404
  * All possible slice outputs for the Page API.
2871
3405
  * The same discriminated union but with each slice requiring `sliceId`.
2872
3406
  */
2873
- export declare const SliceApiOutputSchema: z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
3407
+ declare const SliceApiOutputSchema: z.ZodDiscriminatedUnion<"type", readonly [z.ZodObject<{
2874
3408
  type: z.ZodLiteral<"HomepageSlice">;
2875
3409
  hidden: z.ZodOptional<z.ZodBoolean>;
2876
3410
  properties: z.ZodOptional<z.ZodObject<{
@@ -3156,6 +3690,8 @@ export declare const SliceApiOutputSchema: z.ZodDiscriminatedUnion<"type", reado
3156
3690
  sliceId: string;
3157
3691
  hidden?: boolean | undefined;
3158
3692
  }>]>;
3693
+ export { SliceApiOutputSchema }
3694
+ export { SliceApiOutputSchema as SliceApiOutputSchema_alias_1 }
3159
3695
 
3160
3696
  declare const SparkListSlice: {
3161
3697
  InputSchema: z.ZodObject<{