@tivio/sdk-react 4.1.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -6,6 +6,18 @@ settings in the administration of Tivio Studio while having the freedom to build
6
6
 
7
7
  ## Changelog
8
8
 
9
+ * v4.3.0:
10
+ * minor: add GetPurchaseInfoResponse and PurchaseEndpointPayload to exported types
11
+ * minor: support for disabling purchase of specified subscriptions (new param in useOrganizationSubscriptions hook)
12
+ * minor: more specific PurchasableMonetization type usage instead of Monetization
13
+ * minor: monetization property deleted from Video type
14
+ * minor: monetization now has originalPrice and promotion properties available
15
+ * patch: remove not used OrganizationSubscriptionsContext, **this change requires bundle 3.20.0 or newer**
16
+
17
+ * v4.2.0:
18
+ * minor: fix useSearch loading type
19
+ * patch: added italian language to `LangCode` enum
20
+
9
21
  * v4.1.0
10
22
  * patch: added italian language to `LangCode` enum
11
23
  * minor: fixed spanish language code in `LangCode` enum (`sp` -> `es`)
package/README.md.bak CHANGED
@@ -6,6 +6,18 @@ settings in the administration of Tivio Studio while having the freedom to build
6
6
 
7
7
  ## Changelog
8
8
 
9
+ * v4.3.0:
10
+ * minor: add GetPurchaseInfoResponse and PurchaseEndpointPayload to exported types
11
+ * minor: support for disabling purchase of specified subscriptions (new param in useOrganizationSubscriptions hook)
12
+ * minor: more specific PurchasableMonetization type usage instead of Monetization
13
+ * minor: monetization property deleted from Video type
14
+ * minor: monetization now has originalPrice and promotion properties available
15
+ * patch: remove not used OrganizationSubscriptionsContext, **this change requires bundle 3.20.0 or newer**
16
+
17
+ * v4.2.0:
18
+ * minor: fix useSearch loading type
19
+ * patch: added italian language to `LangCode` enum
20
+
9
21
  * v4.1.0
10
22
  * patch: added italian language to `LangCode` enum
11
23
  * minor: fixed spanish language code in `LangCode` enum (`sp` -> `es`)
package/dist/index.d.ts CHANGED
@@ -55,6 +55,12 @@ export declare type AdMetadata = {
55
55
  skip: () => void;
56
56
  } | null;
57
57
 
58
+ /**
59
+ * @public
60
+ */
61
+ export declare interface AdMonetization extends Monetization {
62
+ }
63
+
58
64
  /**
59
65
  * @public
60
66
  */
@@ -156,35 +162,6 @@ export declare type Assets = {
156
162
  [assetName: string]: ScalableAsset;
157
163
  };
158
164
 
159
- /**
160
- * @public
161
- */
162
- export declare type AuthOverlayPayload = {
163
- prefilledData?: {
164
- email: string;
165
- };
166
- /**
167
- * "Goto" function (see router.utils.ts) to run after the overlay is closed. Null if no redirect is required.
168
- * Defaults to homepage.
169
- */
170
- redirectAfterSubmit?: ((...args: any[]) => void) | null;
171
- };
172
-
173
- /**
174
- * @public
175
- */
176
- export declare type AuthOverlayState = {
177
- type: AuthOverlayType;
178
- closeAuthOverlay: () => void;
179
- openAuthOverlay: (type: AuthOverlayType, payload?: AuthOverlayPayload) => void;
180
- payload?: AuthOverlayPayload | null;
181
- };
182
-
183
- /**
184
- * @public
185
- */
186
- export declare type AuthOverlayType = 'login' | 'registration' | 'closed' | 'reset-password';
187
-
188
165
  /**
189
166
  * @public
190
167
  */
@@ -210,6 +187,11 @@ export declare type BadRequestError = Error & {
210
187
  };
211
188
  };
212
189
 
190
+ export declare enum BannerItemComponent {
191
+ CLASSIC = "CLASSIC",
192
+ SPLITTED = "SPLITTED"
193
+ }
194
+
213
195
  /**
214
196
  * @public
215
197
  */
@@ -224,7 +206,7 @@ export declare type BannerProps = {
224
206
  cover: string;
225
207
  overlay: boolean;
226
208
  price: string;
227
- hasRoundCorners: boolean;
209
+ borderRadius?: string | number;
228
210
  buttonText?: string;
229
211
  onButtonClick?: () => void;
230
212
  };
@@ -355,6 +337,7 @@ export declare type CreateUserWithEmailAndPassword = (email: string, password: s
355
337
  export declare const CURRENCIES: string[];
356
338
 
357
339
  /**
340
+ * Three upper-case letters according to ISO-4217.
358
341
  * @public
359
342
  */
360
343
  export declare type Currency = 'CZK' | 'EUR' | 'USD';
@@ -425,6 +408,22 @@ export declare type DocumentOptions = Partial<{
425
408
  subscribeOnChanges: boolean;
426
409
  }>;
427
410
 
411
+ /**
412
+ * @public
413
+ */
414
+ export declare interface Duration {
415
+ units: DurationUnits;
416
+ value: number;
417
+ }
418
+
419
+ /**
420
+ * @public
421
+ */
422
+ export declare enum DurationUnits {
423
+ DAY = "day",
424
+ MONTH = "month"
425
+ }
426
+
428
427
  /**
429
428
  * @public
430
429
  */
@@ -477,6 +476,21 @@ export declare interface GenericOnCallError {
477
476
  */
478
477
  export declare const getPubSub: () => PubSub;
479
478
 
479
+ /**
480
+ * Response from Tivio getPurchaseInfo HTTP endpoint.
481
+ *
482
+ * @public
483
+ */
484
+ export declare type GetPurchaseInfoResponse = {
485
+ monetizationId: string;
486
+ monetization: PurchaseMonetization;
487
+ status: PurchaseStatus;
488
+ video?: {
489
+ id: string;
490
+ name: string | Translation;
491
+ };
492
+ };
493
+
480
494
  /**
481
495
  * @public
482
496
  */
@@ -614,6 +628,7 @@ export declare enum LangCode {
614
628
  FR = "fr",
615
629
  IT = "it",
616
630
  PL = "pl",
631
+ PT = "pt",
617
632
  SK = "sk",
618
633
  ES = "es"
619
634
  }
@@ -666,6 +681,20 @@ export declare type LiveTvChannelSource = SourceBase & {
666
681
  channelName: string;
667
682
  };
668
683
 
684
+ /**
685
+ * @public
686
+ */
687
+ export declare type LocationField = {
688
+ /**
689
+ * Two-letter uppercase continent code (TODO not sure if this ISO-3166 format or something else, we get these from maxmind service)
690
+ */
691
+ continentCode?: 'AF' | 'AN' | 'AS' | 'EU' | 'NA' | 'OC' | 'SA';
692
+ /**
693
+ * Two-letter uppercase country code according to ISO-3166 format (see https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
694
+ */
695
+ countryIsoCode?: string;
696
+ };
697
+
669
698
  declare interface Logger {
670
699
  /** important messages */
671
700
  warn(...data: LoggerArgs): void;
@@ -721,14 +750,9 @@ export declare interface MigratedVideoExternals {
721
750
  */
722
751
  export declare interface Monetization {
723
752
  id: string;
724
- price?: string | number;
725
753
  type?: MonetizationType;
726
- frequency?: MONETIZATION_FREQUENCY;
727
- isPurchased?: boolean;
728
754
  name?: string;
729
755
  description?: string;
730
- benefits?: Translation[];
731
- localizedBenefits?: string[];
732
756
  }
733
757
 
734
758
  /**
@@ -788,6 +812,13 @@ export declare interface OrderBy {
788
812
  directionStr?: OrderByDirection;
789
813
  }
790
814
 
815
+ /**
816
+ * The same as WhereFilter, but in array, for easier usage.
817
+ * Format: [field, directionStr] or [field]
818
+ * @public
819
+ */
820
+ export declare type OrderByArray = [string, OrderByDirection] | [string];
821
+
791
822
  declare type OrderByDirection = 'desc' | 'asc';
792
823
 
793
824
  /**
@@ -1078,6 +1109,14 @@ export declare enum PlayerWrapperEventType {
1078
1109
  */
1079
1110
  export declare type PlayerWrapperEventTypeType = `${PlayerWrapperEventType}`;
1080
1111
 
1112
+ /**
1113
+ * @public
1114
+ */
1115
+ export declare interface Promotion {
1116
+ duration?: Duration;
1117
+ price?: number;
1118
+ }
1119
+
1081
1120
  /**
1082
1121
  * @public
1083
1122
  */
@@ -1086,6 +1125,30 @@ export declare interface PubSub {
1086
1125
  subscribe: <K extends keyof Events>(triggerName: K, onMessage: (data: Events[K]) => Empty) => Disposer;
1087
1126
  }
1088
1127
 
1128
+ /**
1129
+ * @public
1130
+ */
1131
+ export declare interface PurchasableMonetization extends Monetization {
1132
+ /**
1133
+ * Price before any discounts (e.g. promotions).
1134
+ */
1135
+ originalPrice: number;
1136
+ /**
1137
+ * Final price (after discounts).
1138
+ */
1139
+ price?: string | number;
1140
+ promotion: Promotion | null;
1141
+ frequency?: MONETIZATION_FREQUENCY;
1142
+ isPurchased?: boolean;
1143
+ benefits?: Translation[];
1144
+ localizedBenefits?: string[];
1145
+ /**
1146
+ * Set to true for subscriptions which is not possible to buy - typically for historical subscriptions which users
1147
+ * still have bought but can't be purchased anymore.
1148
+ */
1149
+ purchaseDisabled?: boolean;
1150
+ }
1151
+
1089
1152
  /**
1090
1153
  * @public
1091
1154
  */
@@ -1117,6 +1180,132 @@ export declare type Purchase = {
1117
1180
  voucherId?: string;
1118
1181
  };
1119
1182
 
1183
+ /**
1184
+ * @public
1185
+ */
1186
+ export declare enum PurchaseDocumentGateway {
1187
+ 'qerko' = "qerko",
1188
+ 'oktagon' = "oktagon",
1189
+ 'voucher' = "voucher",
1190
+ 'comgate' = "comgate"
1191
+ }
1192
+
1193
+ /**
1194
+ * Payload which is sent to organization's webhook (if provided). It is send only when purchase status changes to PAID,
1195
+ * it means that it is send also when user applies the voucher.
1196
+ *
1197
+ * @public
1198
+ */
1199
+ export declare type PurchaseEndpointPayload = {
1200
+ /**
1201
+ * Information about the purchase which changes status to PAID.
1202
+ */
1203
+ purchase: {
1204
+ /**
1205
+ * Two-letter upper-case continent code.
1206
+ */
1207
+ continentCode?: LocationField['continentCode'];
1208
+ /**
1209
+ * Two-letter upper-case country code according to ISO-3166 format (see https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).
1210
+ */
1211
+ countryIsoCode?: LocationField['countryIsoCode'];
1212
+ /**
1213
+ * Gateway name or "voucher".
1214
+ */
1215
+ gateway: PurchaseDocumentGateway;
1216
+ /**
1217
+ * Tivio ID of the purchase.
1218
+ */
1219
+ id: string;
1220
+ /**
1221
+ * Timestamp of the last change of the purchase - in this case it is timestamp when it was paid.
1222
+ */
1223
+ updated: number;
1224
+ };
1225
+ /**
1226
+ * Information about the monetization which has been bought by this purchase. Monetization definition may change in time so information provided here
1227
+ * reflects monetization definition in time of the purchase.
1228
+ */
1229
+ monetization: {
1230
+ /**
1231
+ * Currency in which the purchase has been made. Three upper-case letters according to ISO-4217.
1232
+ */
1233
+ currency?: Currency;
1234
+ /**
1235
+ * Frequency in which the user will be charged.
1236
+ * One of "ONE_TIME_PAYMENT", "DAILY", "WEEKLY", "MONTHLY" and "ANNUALLY.
1237
+ */
1238
+ frequency?: MONETIZATION_FREQUENCY | null;
1239
+ /**
1240
+ * Tivio ID of the monetization.
1241
+ */
1242
+ id: string;
1243
+ /**
1244
+ * Price of the purchase.
1245
+ */
1246
+ price?: number;
1247
+ /**
1248
+ * Name of the monetization.
1249
+ */
1250
+ title?: string;
1251
+ /**
1252
+ * Type of the monetization ("transaction" or "subscription").
1253
+ */
1254
+ type: MonetizationType;
1255
+ };
1256
+ /**
1257
+ * Information about the video which has been bought by this purchase. Provided only for transaction purchases.
1258
+ */
1259
+ video?: {
1260
+ /**
1261
+ * Tivio ID of the video.
1262
+ */
1263
+ id: string;
1264
+ /**
1265
+ * Name of the video.
1266
+ */
1267
+ name: string | Translation;
1268
+ };
1269
+ /**
1270
+ * Information about the user who made this purchase.
1271
+ */
1272
+ user: {
1273
+ /**
1274
+ * User's e-mail.
1275
+ */
1276
+ email: string;
1277
+ /**
1278
+ * External ID of the user.
1279
+ */
1280
+ externalUserId: string;
1281
+ /**
1282
+ * Tivio ID of the user.
1283
+ */
1284
+ id: string;
1285
+ /**
1286
+ * User's name.
1287
+ */
1288
+ name: string;
1289
+ };
1290
+ /**
1291
+ * Information about the voucher. Provided only when purchase is purchase (not application) of the voucher.
1292
+ */
1293
+ voucher?: {
1294
+ /**
1295
+ * Voucher code.
1296
+ */
1297
+ code: string;
1298
+ /**
1299
+ * Voucher expiration timestamp.
1300
+ */
1301
+ expiration: number;
1302
+ /**
1303
+ * Duration (in seconds) after which purchase is considered expired. If undefined, monetization's duration is used.
1304
+ */
1305
+ purchaseDuration?: number;
1306
+ };
1307
+ };
1308
+
1120
1309
  /**
1121
1310
  * @public
1122
1311
  */
@@ -1170,7 +1359,7 @@ export declare interface QerkoCancellationInfo {
1170
1359
  * @public
1171
1360
  */
1172
1361
  export declare interface QerkoData {
1173
- monetization: Monetization;
1362
+ monetization: PurchasableMonetization;
1174
1363
  item?: Video | TvChannel;
1175
1364
  onPurchase?: () => void;
1176
1365
  onClose?: () => void;
@@ -1259,13 +1448,14 @@ export declare type RemoteProviderProps = {
1259
1448
  * @public
1260
1449
  */
1261
1450
  export declare interface RouterOverrides {
1262
- goToVideoDetailPage: (videoId: string) => void;
1451
+ goToVideoDetailPage: (videoIdOrUrlName: string) => void;
1263
1452
  goToSeriesDetailPage: (tagId: string) => void;
1264
1453
  goToTagPage: (tagId: string) => void;
1265
- goToLoginScreen: () => void;
1454
+ goToLoginPage: () => void;
1455
+ goToRegistrationPage: () => void;
1266
1456
  goBack: () => void;
1267
- goLivePlayer: (videoId: string) => void;
1268
- goVodPlayer: (tvChannelId: string) => void;
1457
+ goLivePlayer: (tvChannelId: string) => void;
1458
+ goVodPlayer: (videoIdOrUrlName: string) => void;
1269
1459
  goToHome: () => void;
1270
1460
  }
1271
1461
 
@@ -1562,8 +1752,8 @@ export declare type SubscribeToTaggedVideosOptions = SubscribeToItemsInRowOption
1562
1752
  * @public
1563
1753
  */
1564
1754
  export declare interface SubscriptionCardProps {
1565
- subscription: Monetization;
1566
- onClick: (subscription: Monetization) => void;
1755
+ subscription: PurchasableMonetization;
1756
+ onClick: (subscription: PurchasableMonetization) => void;
1567
1757
  buttonLabel: string;
1568
1758
  purchased: boolean;
1569
1759
  focused?: boolean;
@@ -1580,7 +1770,7 @@ declare type SubscriptionInfo = {
1580
1770
  * @public
1581
1771
  */
1582
1772
  export declare interface SubscriptionOverlayData {
1583
- subscriptions?: Monetization[];
1773
+ subscriptions?: PurchasableMonetization[];
1584
1774
  onPurchase?: () => void;
1585
1775
  onClose?: () => void;
1586
1776
  }
@@ -1622,6 +1812,7 @@ export declare type TileProps = {
1622
1812
  cover: string;
1623
1813
  bottomLabel: string;
1624
1814
  bottomLabelAreaHeight: number;
1815
+ bottomLabelTextLinesCount: number;
1625
1816
  innerLabel: string;
1626
1817
  duration: string;
1627
1818
  price: string | null;
@@ -1662,6 +1853,7 @@ export declare interface TivioAuth {
1662
1853
  * @param password
1663
1854
  */
1664
1855
  signInWithEmailAndPassword: (email: string, password: string) => Promise<string | null>;
1856
+ signInWithCustomToken: (token: string) => Promise<string | null>;
1665
1857
  signOut: () => Promise<void>;
1666
1858
  /**
1667
1859
  * Used for reset forgotten password by user
@@ -1853,7 +2045,7 @@ export declare type TivioInternalComponents = {
1853
2045
  logo?: string;
1854
2046
  }>;
1855
2047
  WebVideoScreen: React_2.ComponentType<{
1856
- videoId: string;
2048
+ videoIdOrUrlName: string;
1857
2049
  }>;
1858
2050
  WebSeriesDetailScreen: React_2.ComponentType<WebSeriesDetailScreenProps>;
1859
2051
  };
@@ -1862,20 +2054,33 @@ export declare type TivioInternalComponents = {
1862
2054
  * @public
1863
2055
  */
1864
2056
  export declare type TivioInternalHooks = {
1865
- useAuthOverlay: () => AuthOverlayState;
1866
2057
  useSubscriptionsOverlay: () => SubscriptionOverlayState;
1867
2058
  useQerkoOverlay: () => QerkoOverlayState;
1868
2059
  usePurchasesWithVideos: () => {
1869
2060
  purchases: Purchase[];
1870
2061
  };
1871
- useOrganizationSubscriptions: () => {
1872
- subscriptions: Monetization[];
2062
+ useOrganizationSubscriptions: (onlyPurchasableSubscriptions?: boolean) => {
2063
+ subscriptions: PurchasableMonetization[];
1873
2064
  };
1874
2065
  useIsMonetizationPurchased: () => {
1875
2066
  isOneOfSubscriptionPurchased: (subscriptionIds: string[]) => boolean;
1876
2067
  };
1877
- useReferralInfo: any;
2068
+ useReferralInfo: (referralToken: string) => ({
2069
+ data: {
2070
+ email: string;
2071
+ externalUserId: string;
2072
+ promotionId?: string;
2073
+ referralId: string;
2074
+ promotion?: any;
2075
+ };
2076
+ error: Error | null;
2077
+ loading: boolean;
2078
+ });
1878
2079
  useTvChannel: UseTvChannel;
2080
+ usePaymentOverlay: () => {
2081
+ videoIdOrUrlName: string | null;
2082
+ setVideoIdOrUrlName: (videoIdOrUrlName: string | null) => void;
2083
+ };
1879
2084
  useChannelSource: UseChannelSource;
1880
2085
  useUser: () => {
1881
2086
  user: User | null;
@@ -1889,7 +2094,6 @@ export declare type TivioInternalHooks = {
1889
2094
  */
1890
2095
  export declare type TivioInternalProviders = {
1891
2096
  AppThemeProvider: React_2.ComponentType;
1892
- AuthOverlayContextProvider: React_2.ComponentType;
1893
2097
  CustomerProvider: React_2.ComponentType<{
1894
2098
  customer: CUSTOMER_BUILD;
1895
2099
  platform: PLATFORM;
@@ -1900,6 +2104,10 @@ export declare type TivioInternalProviders = {
1900
2104
  SubscriptionOverlayContextProvider: React_2.ComponentType;
1901
2105
  QerkoOverlayContextProvider: React_2.ComponentType;
1902
2106
  PurchasesWithVideosContextProvider: React_2.ComponentType;
2107
+ PaymentOverlayContextProvider: React_2.ComponentType;
2108
+ /**
2109
+ * @deprecated not used in our app, can be removed when no sdk in production uses it
2110
+ */
1903
2111
  OrganizationSubscriptionsContextProvider: React_2.ComponentType;
1904
2112
  RouterOverridesContextProvider: React_2.ComponentType<RouterOverridesContextState>;
1905
2113
  };
@@ -2279,8 +2487,8 @@ export declare const useMarkers: () => Marker[] | null;
2279
2487
  /**
2280
2488
  * @public
2281
2489
  */
2282
- export declare const useOrganizationSubscriptions: () => {
2283
- subscriptions: Monetization[];
2490
+ export declare const useOrganizationSubscriptions: (onlyPurchasableSubscriptions?: boolean | undefined) => {
2491
+ subscriptions: PurchasableMonetization[];
2284
2492
  };
2285
2493
 
2286
2494
  /**
@@ -2381,7 +2589,7 @@ export declare enum UserType {
2381
2589
  */
2382
2590
  export declare type UseSearch = <T extends ALGOLIA_INDEX_NAME>(indexName: T, options?: UseSearchOptions) => {
2383
2591
  search: (query: string) => void;
2384
- pagination: PaginationInterface<UseSearchResult<T>> | null;
2592
+ pagination: Omit<PaginationInterface<UseSearchResult<T>>, 'loading'> | null;
2385
2593
  error: Error | null;
2386
2594
  isLoading: boolean;
2387
2595
  lastQuery: string;
@@ -2458,10 +2666,10 @@ export declare const useUser: () => {
2458
2666
 
2459
2667
  /**
2460
2668
  * Use video
2461
- * @param videoId - video id
2669
+ * @param videoIdOrUrlName - video id or video nice url (e.g. some-interesting-video)
2462
2670
  * @public
2463
2671
  */
2464
- export declare const useVideo: (videoId?: string | undefined) => {
2672
+ export declare const useVideo: (videoIdOrUrlName?: string | undefined) => {
2465
2673
  data: Video | null;
2466
2674
  error: string | null;
2467
2675
  };
@@ -2547,14 +2755,15 @@ export declare interface Video extends RowItem {
2547
2755
  image: string | null;
2548
2756
  isPlayable: boolean;
2549
2757
  monetizations: Monetization[];
2550
- monetization: Monetization | undefined;
2551
2758
  transactionId?: string;
2552
- transaction: Monetization | undefined;
2553
- subscriptions: Monetization[];
2759
+ sources?: any[];
2760
+ transaction: PurchasableMonetization | undefined;
2761
+ subscriptions: PurchasableMonetization[];
2554
2762
  subscriptionIds: string[];
2555
2763
  isPlaylist: boolean;
2556
2764
  name: string;
2557
- description?: string;
2765
+ urlNames?: string[];
2766
+ urlName?: string;
2558
2767
  price: number | null;
2559
2768
  detailedPrice: DetailedPrice | null;
2560
2769
  uri: string;
@@ -2629,6 +2838,13 @@ export declare enum VideoType {
2629
2838
  SERIES = "SERIES"
2630
2839
  }
2631
2840
 
2841
+ /**
2842
+ * @public
2843
+ */
2844
+ export declare type VideoUrlName = {
2845
+ [key in LangCode]?: string[];
2846
+ };
2847
+
2632
2848
  /**
2633
2849
  * @public
2634
2850
  */
@@ -2754,6 +2970,13 @@ export declare interface WhereFilter {
2754
2970
  value: any;
2755
2971
  }
2756
2972
 
2973
+ /**
2974
+ * The same as WhereFilter, but in array, for easier usage.
2975
+ * Format: [field, operator, value]
2976
+ * @public
2977
+ */
2978
+ export declare type WhereFilterArray = [string, WhereFilterOp, any];
2979
+
2757
2980
  declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any' | 'not-in';
2758
2981
 
2759
2982
  /**