@tivio/sdk-react 4.2.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,14 @@ 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
+
9
17
  * v4.2.0:
10
18
  * minor: fix useSearch loading type
11
19
  * patch: added italian language to `LangCode` enum
package/README.md.bak CHANGED
@@ -6,6 +6,14 @@ 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
+
9
17
  * v4.2.0:
10
18
  * minor: fix useSearch loading type
11
19
  * patch: added italian language to `LangCode` enum
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
  */
@@ -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
  */
@@ -667,6 +681,20 @@ export declare type LiveTvChannelSource = SourceBase & {
667
681
  channelName: string;
668
682
  };
669
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
+
670
698
  declare interface Logger {
671
699
  /** important messages */
672
700
  warn(...data: LoggerArgs): void;
@@ -722,14 +750,9 @@ export declare interface MigratedVideoExternals {
722
750
  */
723
751
  export declare interface Monetization {
724
752
  id: string;
725
- price?: string | number;
726
753
  type?: MonetizationType;
727
- frequency?: MONETIZATION_FREQUENCY;
728
- isPurchased?: boolean;
729
754
  name?: string;
730
755
  description?: string;
731
- benefits?: Translation[];
732
- localizedBenefits?: string[];
733
756
  }
734
757
 
735
758
  /**
@@ -789,6 +812,13 @@ export declare interface OrderBy {
789
812
  directionStr?: OrderByDirection;
790
813
  }
791
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
+
792
822
  declare type OrderByDirection = 'desc' | 'asc';
793
823
 
794
824
  /**
@@ -1079,6 +1109,14 @@ export declare enum PlayerWrapperEventType {
1079
1109
  */
1080
1110
  export declare type PlayerWrapperEventTypeType = `${PlayerWrapperEventType}`;
1081
1111
 
1112
+ /**
1113
+ * @public
1114
+ */
1115
+ export declare interface Promotion {
1116
+ duration?: Duration;
1117
+ price?: number;
1118
+ }
1119
+
1082
1120
  /**
1083
1121
  * @public
1084
1122
  */
@@ -1087,6 +1125,30 @@ export declare interface PubSub {
1087
1125
  subscribe: <K extends keyof Events>(triggerName: K, onMessage: (data: Events[K]) => Empty) => Disposer;
1088
1126
  }
1089
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
+
1090
1152
  /**
1091
1153
  * @public
1092
1154
  */
@@ -1118,6 +1180,132 @@ export declare type Purchase = {
1118
1180
  voucherId?: string;
1119
1181
  };
1120
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
+
1121
1309
  /**
1122
1310
  * @public
1123
1311
  */
@@ -1171,7 +1359,7 @@ export declare interface QerkoCancellationInfo {
1171
1359
  * @public
1172
1360
  */
1173
1361
  export declare interface QerkoData {
1174
- monetization: Monetization;
1362
+ monetization: PurchasableMonetization;
1175
1363
  item?: Video | TvChannel;
1176
1364
  onPurchase?: () => void;
1177
1365
  onClose?: () => void;
@@ -1260,13 +1448,14 @@ export declare type RemoteProviderProps = {
1260
1448
  * @public
1261
1449
  */
1262
1450
  export declare interface RouterOverrides {
1263
- goToVideoDetailPage: (videoId: string) => void;
1451
+ goToVideoDetailPage: (videoIdOrUrlName: string) => void;
1264
1452
  goToSeriesDetailPage: (tagId: string) => void;
1265
1453
  goToTagPage: (tagId: string) => void;
1266
- goToLoginScreen: () => void;
1454
+ goToLoginPage: () => void;
1455
+ goToRegistrationPage: () => void;
1267
1456
  goBack: () => void;
1268
- goLivePlayer: (videoId: string) => void;
1269
- goVodPlayer: (tvChannelId: string) => void;
1457
+ goLivePlayer: (tvChannelId: string) => void;
1458
+ goVodPlayer: (videoIdOrUrlName: string) => void;
1270
1459
  goToHome: () => void;
1271
1460
  }
1272
1461
 
@@ -1563,8 +1752,8 @@ export declare type SubscribeToTaggedVideosOptions = SubscribeToItemsInRowOption
1563
1752
  * @public
1564
1753
  */
1565
1754
  export declare interface SubscriptionCardProps {
1566
- subscription: Monetization;
1567
- onClick: (subscription: Monetization) => void;
1755
+ subscription: PurchasableMonetization;
1756
+ onClick: (subscription: PurchasableMonetization) => void;
1568
1757
  buttonLabel: string;
1569
1758
  purchased: boolean;
1570
1759
  focused?: boolean;
@@ -1581,7 +1770,7 @@ declare type SubscriptionInfo = {
1581
1770
  * @public
1582
1771
  */
1583
1772
  export declare interface SubscriptionOverlayData {
1584
- subscriptions?: Monetization[];
1773
+ subscriptions?: PurchasableMonetization[];
1585
1774
  onPurchase?: () => void;
1586
1775
  onClose?: () => void;
1587
1776
  }
@@ -1623,6 +1812,7 @@ export declare type TileProps = {
1623
1812
  cover: string;
1624
1813
  bottomLabel: string;
1625
1814
  bottomLabelAreaHeight: number;
1815
+ bottomLabelTextLinesCount: number;
1626
1816
  innerLabel: string;
1627
1817
  duration: string;
1628
1818
  price: string | null;
@@ -1663,6 +1853,7 @@ export declare interface TivioAuth {
1663
1853
  * @param password
1664
1854
  */
1665
1855
  signInWithEmailAndPassword: (email: string, password: string) => Promise<string | null>;
1856
+ signInWithCustomToken: (token: string) => Promise<string | null>;
1666
1857
  signOut: () => Promise<void>;
1667
1858
  /**
1668
1859
  * Used for reset forgotten password by user
@@ -1854,7 +2045,7 @@ export declare type TivioInternalComponents = {
1854
2045
  logo?: string;
1855
2046
  }>;
1856
2047
  WebVideoScreen: React_2.ComponentType<{
1857
- videoId: string;
2048
+ videoIdOrUrlName: string;
1858
2049
  }>;
1859
2050
  WebSeriesDetailScreen: React_2.ComponentType<WebSeriesDetailScreenProps>;
1860
2051
  };
@@ -1863,20 +2054,33 @@ export declare type TivioInternalComponents = {
1863
2054
  * @public
1864
2055
  */
1865
2056
  export declare type TivioInternalHooks = {
1866
- useAuthOverlay: () => AuthOverlayState;
1867
2057
  useSubscriptionsOverlay: () => SubscriptionOverlayState;
1868
2058
  useQerkoOverlay: () => QerkoOverlayState;
1869
2059
  usePurchasesWithVideos: () => {
1870
2060
  purchases: Purchase[];
1871
2061
  };
1872
- useOrganizationSubscriptions: () => {
1873
- subscriptions: Monetization[];
2062
+ useOrganizationSubscriptions: (onlyPurchasableSubscriptions?: boolean) => {
2063
+ subscriptions: PurchasableMonetization[];
1874
2064
  };
1875
2065
  useIsMonetizationPurchased: () => {
1876
2066
  isOneOfSubscriptionPurchased: (subscriptionIds: string[]) => boolean;
1877
2067
  };
1878
- 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
+ });
1879
2079
  useTvChannel: UseTvChannel;
2080
+ usePaymentOverlay: () => {
2081
+ videoIdOrUrlName: string | null;
2082
+ setVideoIdOrUrlName: (videoIdOrUrlName: string | null) => void;
2083
+ };
1880
2084
  useChannelSource: UseChannelSource;
1881
2085
  useUser: () => {
1882
2086
  user: User | null;
@@ -1890,7 +2094,6 @@ export declare type TivioInternalHooks = {
1890
2094
  */
1891
2095
  export declare type TivioInternalProviders = {
1892
2096
  AppThemeProvider: React_2.ComponentType;
1893
- AuthOverlayContextProvider: React_2.ComponentType;
1894
2097
  CustomerProvider: React_2.ComponentType<{
1895
2098
  customer: CUSTOMER_BUILD;
1896
2099
  platform: PLATFORM;
@@ -1901,6 +2104,10 @@ export declare type TivioInternalProviders = {
1901
2104
  SubscriptionOverlayContextProvider: React_2.ComponentType;
1902
2105
  QerkoOverlayContextProvider: React_2.ComponentType;
1903
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
+ */
1904
2111
  OrganizationSubscriptionsContextProvider: React_2.ComponentType;
1905
2112
  RouterOverridesContextProvider: React_2.ComponentType<RouterOverridesContextState>;
1906
2113
  };
@@ -2280,8 +2487,8 @@ export declare const useMarkers: () => Marker[] | null;
2280
2487
  /**
2281
2488
  * @public
2282
2489
  */
2283
- export declare const useOrganizationSubscriptions: () => {
2284
- subscriptions: Monetization[];
2490
+ export declare const useOrganizationSubscriptions: (onlyPurchasableSubscriptions?: boolean | undefined) => {
2491
+ subscriptions: PurchasableMonetization[];
2285
2492
  };
2286
2493
 
2287
2494
  /**
@@ -2459,10 +2666,10 @@ export declare const useUser: () => {
2459
2666
 
2460
2667
  /**
2461
2668
  * Use video
2462
- * @param videoId - video id
2669
+ * @param videoIdOrUrlName - video id or video nice url (e.g. some-interesting-video)
2463
2670
  * @public
2464
2671
  */
2465
- export declare const useVideo: (videoId?: string | undefined) => {
2672
+ export declare const useVideo: (videoIdOrUrlName?: string | undefined) => {
2466
2673
  data: Video | null;
2467
2674
  error: string | null;
2468
2675
  };
@@ -2548,14 +2755,15 @@ export declare interface Video extends RowItem {
2548
2755
  image: string | null;
2549
2756
  isPlayable: boolean;
2550
2757
  monetizations: Monetization[];
2551
- monetization: Monetization | undefined;
2552
2758
  transactionId?: string;
2553
- transaction: Monetization | undefined;
2554
- subscriptions: Monetization[];
2759
+ sources?: any[];
2760
+ transaction: PurchasableMonetization | undefined;
2761
+ subscriptions: PurchasableMonetization[];
2555
2762
  subscriptionIds: string[];
2556
2763
  isPlaylist: boolean;
2557
2764
  name: string;
2558
- description?: string;
2765
+ urlNames?: string[];
2766
+ urlName?: string;
2559
2767
  price: number | null;
2560
2768
  detailedPrice: DetailedPrice | null;
2561
2769
  uri: string;
@@ -2630,6 +2838,13 @@ export declare enum VideoType {
2630
2838
  SERIES = "SERIES"
2631
2839
  }
2632
2840
 
2841
+ /**
2842
+ * @public
2843
+ */
2844
+ export declare type VideoUrlName = {
2845
+ [key in LangCode]?: string[];
2846
+ };
2847
+
2633
2848
  /**
2634
2849
  * @public
2635
2850
  */
@@ -2755,6 +2970,13 @@ export declare interface WhereFilter {
2755
2970
  value: any;
2756
2971
  }
2757
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
+
2758
2980
  declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any' | 'not-in';
2759
2981
 
2760
2982
  /**