@tivio/sdk-react 10.1.0 → 10.2.1
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 +86 -0
- package/README.md.bak +86 -0
- package/dist/index.d.ts +89 -47
- package/dist/index.js +1 -1
- package/dist/sdk-react.d.ts +89 -47
- package/package.json +4 -2
- package/CHANGELOG.md +0 -333
package/README.md
CHANGED
|
@@ -535,3 +535,89 @@ useTaggedVideos: (tagIds: string[], options?: SubscribeToItemsInRowOptions) => {
|
|
|
535
535
|
error: Error | null
|
|
536
536
|
}
|
|
537
537
|
```
|
|
538
|
+
|
|
539
|
+
### useVoucher hook
|
|
540
|
+
|
|
541
|
+
Activates a voucher for the current user. Reading vouchers directly from the client is
|
|
542
|
+
forbidden, so the hook does not fetch the voucher — calling `activate()` invokes the
|
|
543
|
+
`activateVoucher` cloud function, which detects on its own whether the code is a single-use
|
|
544
|
+
or a multi-use voucher.
|
|
545
|
+
|
|
546
|
+
After a successful activation the `voucher` object exposes server-provided metadata
|
|
547
|
+
(`voucherInfo`, `videoId`, `subscriptionsToShow`) as flat attributes. Until the voucher is
|
|
548
|
+
initialized, `voucher` is `null`.
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
/**
|
|
552
|
+
* Use voucher
|
|
553
|
+
* @param voucherId - voucher code entered by the user
|
|
554
|
+
*/
|
|
555
|
+
useVoucher: (voucherId: string) => {
|
|
556
|
+
/**
|
|
557
|
+
* Triggers the `activateVoucher` cloud function for the current user.
|
|
558
|
+
* On success, `activationSuccess` becomes `true` and `voucher` is populated
|
|
559
|
+
* with the activation metadata.
|
|
560
|
+
*/
|
|
561
|
+
activate: () => Promise<void>
|
|
562
|
+
voucher: {
|
|
563
|
+
organizationId: string | null
|
|
564
|
+
isInitialized: boolean
|
|
565
|
+
/** Public, server-safe metadata about the activated voucher. */
|
|
566
|
+
voucherInfo: VoucherInfoPublic | null
|
|
567
|
+
/** Video the voucher relates to, when its document references one (`voucherInfo.videoId`). */
|
|
568
|
+
videoId?: string
|
|
569
|
+
/** Monetizations to offer when the voucher does not fully cover the content. */
|
|
570
|
+
subscriptionsToShow: PurchasableMonetization[]
|
|
571
|
+
} | null
|
|
572
|
+
error: Error | BadRequestError | null
|
|
573
|
+
activationSuccess: boolean
|
|
574
|
+
}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
`voucherInfo` is a discriminated union by `type`:
|
|
578
|
+
|
|
579
|
+
```ts
|
|
580
|
+
type VoucherInfoPublic = VoucherInfoSubscriptionPublic | VoucherInfoTransactionPublic
|
|
581
|
+
|
|
582
|
+
interface VoucherInfoBasePublic {
|
|
583
|
+
id: string
|
|
584
|
+
isExpired: boolean
|
|
585
|
+
status: 'NEW' | 'USED' | 'FULFILLED'
|
|
586
|
+
/** True when the voucher fully covers the content (no further payment needed). */
|
|
587
|
+
fullDiscount?: boolean
|
|
588
|
+
/** Video the voucher relates to, when its document references one. Present for both types. */
|
|
589
|
+
videoId?: string
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
interface VoucherInfoSubscriptionPublic extends VoucherInfoBasePublic {
|
|
593
|
+
type: 'subscription'
|
|
594
|
+
name: string
|
|
595
|
+
benefits: string[]
|
|
596
|
+
frequency?: MONETIZATION_FREQUENCY
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
interface VoucherInfoTransactionPublic extends VoucherInfoBasePublic {
|
|
600
|
+
type: 'transaction'
|
|
601
|
+
name: string
|
|
602
|
+
videoId: string
|
|
603
|
+
cover: string
|
|
604
|
+
description: string
|
|
605
|
+
}
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
When activation fails, `error` may be a `BadRequestError` whose `details.reason` explains why:
|
|
609
|
+
|
|
610
|
+
```ts
|
|
611
|
+
type BadRequestError = Error & {
|
|
612
|
+
details?: {
|
|
613
|
+
reason?:
|
|
614
|
+
| 'DOES_NOT_EXIST'
|
|
615
|
+
| 'EXPIRED'
|
|
616
|
+
| 'ALREADY_USED'
|
|
617
|
+
| 'ALREADY_USED_BY_CURRENT_USER'
|
|
618
|
+
| 'LIMIT_REACHED'
|
|
619
|
+
| 'FULFILLED'
|
|
620
|
+
| 'INVALID_VOUCHER_TYPE'
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
```
|
package/README.md.bak
CHANGED
|
@@ -535,3 +535,89 @@ useTaggedVideos: (tagIds: string[], options?: SubscribeToItemsInRowOptions) => {
|
|
|
535
535
|
error: Error | null
|
|
536
536
|
}
|
|
537
537
|
```
|
|
538
|
+
|
|
539
|
+
### useVoucher hook
|
|
540
|
+
|
|
541
|
+
Activates a voucher for the current user. Reading vouchers directly from the client is
|
|
542
|
+
forbidden, so the hook does not fetch the voucher — calling `activate()` invokes the
|
|
543
|
+
`activateVoucher` cloud function, which detects on its own whether the code is a single-use
|
|
544
|
+
or a multi-use voucher.
|
|
545
|
+
|
|
546
|
+
After a successful activation the `voucher` object exposes server-provided metadata
|
|
547
|
+
(`voucherInfo`, `videoId`, `subscriptionsToShow`) as flat attributes. Until the voucher is
|
|
548
|
+
initialized, `voucher` is `null`.
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
/**
|
|
552
|
+
* Use voucher
|
|
553
|
+
* @param voucherId - voucher code entered by the user
|
|
554
|
+
*/
|
|
555
|
+
useVoucher: (voucherId: string) => {
|
|
556
|
+
/**
|
|
557
|
+
* Triggers the `activateVoucher` cloud function for the current user.
|
|
558
|
+
* On success, `activationSuccess` becomes `true` and `voucher` is populated
|
|
559
|
+
* with the activation metadata.
|
|
560
|
+
*/
|
|
561
|
+
activate: () => Promise<void>
|
|
562
|
+
voucher: {
|
|
563
|
+
organizationId: string | null
|
|
564
|
+
isInitialized: boolean
|
|
565
|
+
/** Public, server-safe metadata about the activated voucher. */
|
|
566
|
+
voucherInfo: VoucherInfoPublic | null
|
|
567
|
+
/** Video the voucher relates to, when its document references one (`voucherInfo.videoId`). */
|
|
568
|
+
videoId?: string
|
|
569
|
+
/** Monetizations to offer when the voucher does not fully cover the content. */
|
|
570
|
+
subscriptionsToShow: PurchasableMonetization[]
|
|
571
|
+
} | null
|
|
572
|
+
error: Error | BadRequestError | null
|
|
573
|
+
activationSuccess: boolean
|
|
574
|
+
}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
`voucherInfo` is a discriminated union by `type`:
|
|
578
|
+
|
|
579
|
+
```ts
|
|
580
|
+
type VoucherInfoPublic = VoucherInfoSubscriptionPublic | VoucherInfoTransactionPublic
|
|
581
|
+
|
|
582
|
+
interface VoucherInfoBasePublic {
|
|
583
|
+
id: string
|
|
584
|
+
isExpired: boolean
|
|
585
|
+
status: 'NEW' | 'USED' | 'FULFILLED'
|
|
586
|
+
/** True when the voucher fully covers the content (no further payment needed). */
|
|
587
|
+
fullDiscount?: boolean
|
|
588
|
+
/** Video the voucher relates to, when its document references one. Present for both types. */
|
|
589
|
+
videoId?: string
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
interface VoucherInfoSubscriptionPublic extends VoucherInfoBasePublic {
|
|
593
|
+
type: 'subscription'
|
|
594
|
+
name: string
|
|
595
|
+
benefits: string[]
|
|
596
|
+
frequency?: MONETIZATION_FREQUENCY
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
interface VoucherInfoTransactionPublic extends VoucherInfoBasePublic {
|
|
600
|
+
type: 'transaction'
|
|
601
|
+
name: string
|
|
602
|
+
videoId: string
|
|
603
|
+
cover: string
|
|
604
|
+
description: string
|
|
605
|
+
}
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
When activation fails, `error` may be a `BadRequestError` whose `details.reason` explains why:
|
|
609
|
+
|
|
610
|
+
```ts
|
|
611
|
+
type BadRequestError = Error & {
|
|
612
|
+
details?: {
|
|
613
|
+
reason?:
|
|
614
|
+
| 'DOES_NOT_EXIST'
|
|
615
|
+
| 'EXPIRED'
|
|
616
|
+
| 'ALREADY_USED'
|
|
617
|
+
| 'ALREADY_USED_BY_CURRENT_USER'
|
|
618
|
+
| 'LIMIT_REACHED'
|
|
619
|
+
| 'FULFILLED'
|
|
620
|
+
| 'INVALID_VOUCHER_TYPE'
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import { DocumentReference } from '@firebase/firestore-types';
|
|
3
3
|
import type duration from 'dayjs/plugin/duration';
|
|
4
|
-
import type
|
|
5
|
-
import type { default as firebase_3 } from 'firebase';
|
|
4
|
+
import type firebase from '@firebase/app-types';
|
|
6
5
|
import { FunctionComponentElement } from 'react';
|
|
7
6
|
import type { GeoPoint } from '@firebase/firestore-types';
|
|
8
7
|
import { OperatingSystem } from 'detect-browser';
|
|
@@ -26,7 +25,22 @@ export declare interface ActivatedPromotionsWithIdsResponse {
|
|
|
26
25
|
activatedPromotionsIds: string[];
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Response returned when `activateVoucher` is called with `responseFormat: 'extended'`.
|
|
30
|
+
*
|
|
31
|
+
* It always carries `voucherInfo` (safe server-side metadata) and, depending on the
|
|
32
|
+
* voucher type, either a `purchaseId` (transaction / subscription) or the list of
|
|
33
|
+
* `activatedPromotions` (promotion voucher).
|
|
34
|
+
*/
|
|
35
|
+
export declare interface ActivateVoucherExtendedResponse {
|
|
36
|
+
voucherInfo: VoucherInfoPublic;
|
|
37
|
+
purchaseId?: string;
|
|
38
|
+
activatedPromotions?: ActivatedPromotion[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare type ActivateVoucherResponse = string | ActivatedPromotionsResponse | ActivatedPromotionsWithIdsResponse | ActivateVoucherExtendedResponse;
|
|
42
|
+
|
|
43
|
+
export declare type ActivateVoucherResponseFormat = 'legacy' | 'extended';
|
|
30
44
|
|
|
31
45
|
declare interface actualPriceDetails {
|
|
32
46
|
amountCents: number;
|
|
@@ -599,7 +613,7 @@ export declare interface AvatarProps {
|
|
|
599
613
|
*/
|
|
600
614
|
export declare type BadRequestError = Error & {
|
|
601
615
|
details?: {
|
|
602
|
-
reason?: 'DOES_NOT_EXIST' | 'EXPIRED' | 'ALREADY_USED' | 'ALREADY_USED_BY_CURRENT_USER';
|
|
616
|
+
reason?: 'DOES_NOT_EXIST' | 'EXPIRED' | 'ALREADY_USED' | 'ALREADY_USED_BY_CURRENT_USER' | 'LIMIT_REACHED' | 'FULFILLED' | 'INVALID_VOUCHER_TYPE';
|
|
603
617
|
};
|
|
604
618
|
};
|
|
605
619
|
|
|
@@ -1456,7 +1470,10 @@ export declare enum CustomerId {
|
|
|
1456
1470
|
THE_JOHNY = "THE_JOHNY",
|
|
1457
1471
|
GOOD_MOVE = "GOOD_MOVE",
|
|
1458
1472
|
JANA_HANZ = "JANA_HANZ",
|
|
1459
|
-
MYSTICO = "MYSTICO"
|
|
1473
|
+
MYSTICO = "MYSTICO",
|
|
1474
|
+
MORAVEC = "MORAVEC",
|
|
1475
|
+
JAN_TUNA = "JAN_TUNA",
|
|
1476
|
+
PODNIKATELSKY_MINDSET = "PODNIKATELSKY_MINDSET"
|
|
1460
1477
|
}
|
|
1461
1478
|
|
|
1462
1479
|
export declare interface CustomScript {
|
|
@@ -3227,6 +3244,16 @@ export declare interface MonetizationCardProps {
|
|
|
3227
3244
|
focused?: boolean;
|
|
3228
3245
|
}
|
|
3229
3246
|
|
|
3247
|
+
/**
|
|
3248
|
+
* @public
|
|
3249
|
+
*/
|
|
3250
|
+
export declare type MonetizationCta = {
|
|
3251
|
+
type: 'email';
|
|
3252
|
+
payload: {
|
|
3253
|
+
email: string;
|
|
3254
|
+
};
|
|
3255
|
+
};
|
|
3256
|
+
|
|
3230
3257
|
export declare interface MonetizationsCountsSummaryItem {
|
|
3231
3258
|
/**
|
|
3232
3259
|
* Unix timestamp at which the data is aggregated
|
|
@@ -4617,6 +4644,11 @@ export declare interface PubSub {
|
|
|
4617
4644
|
* @public
|
|
4618
4645
|
*/
|
|
4619
4646
|
export declare interface PurchasableMonetization extends Monetization {
|
|
4647
|
+
/**
|
|
4648
|
+
* If CTA is configured, the monetization should not be directly purchasable in clients.
|
|
4649
|
+
* Client apps should render CTA action instead of purchase button.
|
|
4650
|
+
*/
|
|
4651
|
+
cta?: MonetizationCta;
|
|
4620
4652
|
/**
|
|
4621
4653
|
* Price before any discounts (e.g. promotions).
|
|
4622
4654
|
*/
|
|
@@ -6594,14 +6626,6 @@ export declare type SubscribeToTaggedVideosOptions = Omit<SubscribeToItemsInRowO
|
|
|
6594
6626
|
orderBy?: OrderBy<TaggedVideosOrderByField>[];
|
|
6595
6627
|
};
|
|
6596
6628
|
|
|
6597
|
-
declare interface SubscriptionInfo {
|
|
6598
|
-
id: string;
|
|
6599
|
-
type: 'subscription';
|
|
6600
|
-
name: string;
|
|
6601
|
-
benefits: string[];
|
|
6602
|
-
frequency: string;
|
|
6603
|
-
}
|
|
6604
|
-
|
|
6605
6629
|
/**
|
|
6606
6630
|
* Extended language codes for subtitle tracks.
|
|
6607
6631
|
* Includes all LangCode values plus additional languages only needed for subtitles.
|
|
@@ -6984,7 +7008,7 @@ export declare interface TivioConfig {
|
|
|
6984
7008
|
debug?: boolean;
|
|
6985
7009
|
verbose?: boolean;
|
|
6986
7010
|
firebaseApp?: any | null;
|
|
6987
|
-
firebaseFactory?: (config: object, appName?: string) =>
|
|
7011
|
+
firebaseFactory?: (config: object, appName?: string) => firebase.FirebaseApp;
|
|
6988
7012
|
authDomainOverride?: string;
|
|
6989
7013
|
/**
|
|
6990
7014
|
* @deprecated this field is no longer in use and has no impact when set.
|
|
@@ -7113,7 +7137,7 @@ export declare type TivioHooks = {
|
|
|
7113
7137
|
data: Video | null;
|
|
7114
7138
|
error: string | null;
|
|
7115
7139
|
};
|
|
7116
|
-
useVoucher: (voucherId: string) =>
|
|
7140
|
+
useVoucher: (voucherId: string) => UseVoucherReturn;
|
|
7117
7141
|
useApplyInviteCode: () => {
|
|
7118
7142
|
applyInviteCodeResult?: boolean;
|
|
7119
7143
|
loading: boolean;
|
|
@@ -7356,7 +7380,7 @@ export declare type TivioReactBundle = {
|
|
|
7356
7380
|
}, email?: string) => Promise<QerkoPaymentInfo>;
|
|
7357
7381
|
purchaseSubscriptionWithQerko: (monetizationId: string, voucher?: {
|
|
7358
7382
|
expirationDate: Date;
|
|
7359
|
-
}) => Promise<QerkoPaymentInfo>;
|
|
7383
|
+
}, email?: string, quantity?: number) => Promise<QerkoPaymentInfo>;
|
|
7360
7384
|
cancelSubscriptionWithQerko: (subscriptionId: string) => Promise<QerkoCancellationInfo>;
|
|
7361
7385
|
showConsentPreferences: () => void;
|
|
7362
7386
|
/**
|
|
@@ -7465,17 +7489,6 @@ export declare interface Track {
|
|
|
7465
7489
|
language: LangCode;
|
|
7466
7490
|
}
|
|
7467
7491
|
|
|
7468
|
-
declare interface TransactionInfo {
|
|
7469
|
-
id: string;
|
|
7470
|
-
type: 'transaction';
|
|
7471
|
-
name: string;
|
|
7472
|
-
videoId: string;
|
|
7473
|
-
cover: string;
|
|
7474
|
-
description: string;
|
|
7475
|
-
promotions?: firebase_3.firestore.DocumentReference<Promotion>[];
|
|
7476
|
-
fullDiscount?: boolean;
|
|
7477
|
-
}
|
|
7478
|
-
|
|
7479
7492
|
/**
|
|
7480
7493
|
* Represents one string in every supported language mutation.
|
|
7481
7494
|
* @public
|
|
@@ -8324,19 +8337,28 @@ export declare const useVideo: (videoIdOrUrlName?: string) => {
|
|
|
8324
8337
|
/**
|
|
8325
8338
|
* @public
|
|
8326
8339
|
*/
|
|
8327
|
-
export declare const useVoucher: (voucherId: string) =>
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8340
|
+
export declare const useVoucher: (voucherId: string) => UseVoucherReturn;
|
|
8341
|
+
|
|
8342
|
+
/**
|
|
8343
|
+
* Return type of `useVoucher` hook (core-react / sdk-react).
|
|
8344
|
+
*
|
|
8345
|
+
* Activation is triggered via the top-level `activate`. After a successful activation
|
|
8346
|
+
* `voucher` carries the server-provided metadata (`voucherInfo`, `videoId`,
|
|
8347
|
+
* `subscriptionsToShow`) as flat attributes. While the voucher is still initializing,
|
|
8348
|
+
* `voucher` is `null`.
|
|
8349
|
+
*/
|
|
8350
|
+
export declare interface UseVoucherReturn {
|
|
8351
|
+
activate: () => Promise<void>;
|
|
8352
|
+
voucher: {
|
|
8353
|
+
organizationId: string | null;
|
|
8354
|
+
isInitialized: boolean;
|
|
8355
|
+
voucherInfo: VoucherInfoPublic | null;
|
|
8356
|
+
videoId?: string;
|
|
8357
|
+
subscriptionsToShow: PurchasableMonetization[];
|
|
8358
|
+
} | null;
|
|
8359
|
+
error: Error | null;
|
|
8338
8360
|
activationSuccess: boolean;
|
|
8339
|
-
}
|
|
8361
|
+
}
|
|
8340
8362
|
|
|
8341
8363
|
/**
|
|
8342
8364
|
* @public
|
|
@@ -8970,15 +8992,35 @@ export declare interface VodTivioSourceParams extends PlayerSourceParams<SourceT
|
|
|
8970
8992
|
sessionId?: string;
|
|
8971
8993
|
}
|
|
8972
8994
|
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
*/
|
|
8976
|
-
declare interface Voucher {
|
|
8977
|
-
activate: () => void;
|
|
8978
|
-
isUsed: boolean;
|
|
8995
|
+
export declare interface VoucherInfoBasePublic {
|
|
8996
|
+
id: string;
|
|
8979
8997
|
isExpired: boolean;
|
|
8980
|
-
status:
|
|
8981
|
-
|
|
8998
|
+
status: VoucherInfoPublicStatus;
|
|
8999
|
+
fullDiscount?: boolean;
|
|
9000
|
+
/**
|
|
9001
|
+
* Video the voucher relates to, when the voucher document references one
|
|
9002
|
+
* (`videoRef`). Present for both subscription and transaction vouchers.
|
|
9003
|
+
*/
|
|
9004
|
+
videoId?: string;
|
|
9005
|
+
}
|
|
9006
|
+
|
|
9007
|
+
export declare type VoucherInfoPublic = VoucherInfoSubscriptionPublic | VoucherInfoTransactionPublic;
|
|
9008
|
+
|
|
9009
|
+
export declare type VoucherInfoPublicStatus = 'NEW' | 'USED' | 'FULFILLED';
|
|
9010
|
+
|
|
9011
|
+
export declare interface VoucherInfoSubscriptionPublic extends VoucherInfoBasePublic {
|
|
9012
|
+
type: 'subscription';
|
|
9013
|
+
name: string;
|
|
9014
|
+
benefits: string[];
|
|
9015
|
+
frequency?: MONETIZATION_FREQUENCY;
|
|
9016
|
+
}
|
|
9017
|
+
|
|
9018
|
+
export declare interface VoucherInfoTransactionPublic extends VoucherInfoBasePublic {
|
|
9019
|
+
type: 'transaction';
|
|
9020
|
+
name: string;
|
|
9021
|
+
videoId: string;
|
|
9022
|
+
cover: string;
|
|
9023
|
+
description: string;
|
|
8982
9024
|
}
|
|
8983
9025
|
|
|
8984
9026
|
declare interface VoucherPageConfiguration {
|