@domino-sdk/relay 1.55.0 → 1.59.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/CHANGELOG.md +85 -0
- package/dist/{accounts-DRPENuZe.d.ts → accounts-CVonEkdb.d.ts} +18 -7
- package/dist/{attempt-captures-CxxO7DeD.d.ts → attempt-captures-DBj-rxak.d.ts} +1 -1
- package/dist/authoring.d.ts +306 -72
- package/dist/authoring.js +264 -9
- package/dist/{automatic-outcomes-DxW_v5Wc.d.ts → automatic-outcomes-FS9okvBP.d.ts} +1 -1
- package/dist/avatar.d.ts +1 -2
- package/dist/browser.d.ts +8 -9
- package/dist/browser.js +10 -10
- package/dist/{capability-error-DSd8EMQC.d.ts → capability-error-DDJl0LY-.d.ts} +0 -6
- package/dist/{chunk-IZRITLVV.js → chunk-2LKGAL63.js} +2 -2
- package/dist/{chunk-GL43VQ5D.js → chunk-577DG2IT.js} +38 -8
- package/dist/{chunk-UY6KMLQG.js → chunk-6U5WWH3W.js} +141 -100
- package/dist/{chunk-YCOKTQ4E.js → chunk-AWWCEP7F.js} +1403 -882
- package/dist/{chunk-56DBFNR2.js → chunk-EQF4ID47.js} +1 -1
- package/dist/{chunk-YEVD4A5X.js → chunk-IBROKMFV.js} +2 -2
- package/dist/{chunk-XALIFNMD.js → chunk-KBCTII6C.js} +1 -1
- package/dist/{chunk-WHG5WE43.js → chunk-KYUQEZZA.js} +1 -1
- package/dist/{chunk-WUEQOKJH.js → chunk-LDLOB2UZ.js} +4 -4
- package/dist/{chunk-IUF7DW76.js → chunk-M2JQPDUX.js} +39 -9
- package/dist/{chunk-MLIXJPKL.js → chunk-MHPKEVEW.js} +1 -0
- package/dist/{chunk-TLK2MD4S.js → chunk-R4S6BFOH.js} +1 -1
- package/dist/{chunk-VFBQVY4X.js → chunk-TZJT5CRF.js} +1 -1
- package/dist/{chunk-C7QZ4UBB.js → chunk-UEMLYPKJ.js} +21 -5
- package/dist/{chunk-F6HECAXA.js → chunk-W42KMMH5.js} +140 -101
- package/dist/{chunk-WHMXXHPX.js → chunk-XGXDINGM.js} +16 -3
- package/dist/{chunk-SABMNPF2.js → chunk-YMWRLAAP.js} +1 -1
- package/dist/{chunk-YE3XYB2F.js → chunk-YRSU2X2P.js} +2 -2
- package/dist/{client-C4zUZKpj.d.ts → client-3b9HjSzZ.d.ts} +191 -117
- package/dist/{deployments-B32QS1CI.d.ts → deployments-BydFVj4Q.d.ts} +798 -235
- package/dist/{groups-O6onGPmC.d.ts → groups-CFuTfFqG.d.ts} +15 -9
- package/dist/index.d.ts +9 -10
- package/dist/index.js +9 -9
- package/dist/{integrations-C6_uUh-s.d.ts → integrations-DrbKQSTD.d.ts} +42 -22
- package/dist/internal.d.ts +10 -10
- package/dist/internal.js +9 -9
- package/dist/{offers-BMDNcvwB.d.ts → offers-DAfe1O3_.d.ts} +211 -2
- package/dist/{pages-BFloMpyQ.d.ts → pages-ChDVLrgR.d.ts} +95 -10
- package/dist/portal-proxy.js +4 -4
- package/dist/react/index.d.ts +149 -72
- package/dist/react/index.js +65 -10
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/BG43KQ2T.js +1 -0
- package/dist/runtime/chunks/EWU4OKSY.js +62 -0
- package/dist/runtime/manifest.json +5 -5
- package/dist/runtime/schema.js +1 -1
- package/dist/runtime/zod.js +1 -1
- package/dist/{schema-C4m9RhCR.d.ts → schema-BA0nRRlt.d.ts} +184 -35
- package/dist/schema.d.ts +1265 -697
- package/dist/schema.js +96 -12
- package/dist/server/index.d.ts +10 -10
- package/dist/server/index.js +1644 -1105
- package/dist/{submission-input-BbdawqVy.d.ts → submission-input-DxQ6RnKo.d.ts} +2 -2
- package/dist/{telegram-browser-CwaxROAZ.d.ts → telegram-browser-o3OIxGrJ.d.ts} +3 -3
- package/dist/testing.d.ts +89 -9
- package/dist/testing.js +215 -10
- package/dist/{transport-CZJOW5Sr.d.ts → transport-D_Eqf78J.d.ts} +8592 -4384
- package/dist/wallet-B06zvDXp.d.ts +972 -0
- package/dist/{x-1czZFVUW.d.ts → x-C28SNifw.d.ts} +2 -2
- package/package.json +2 -2
- package/dist/profiles-BoOK03cR.d.ts +0 -299
- package/dist/runtime/chunks/IDOMZWRY.js +0 -40
- package/dist/runtime/chunks/WKATKZXE.js +0 -1
- package/dist/util.d-w9f9t3ua.d.ts +0 -5
- package/dist/wallet-Ac7OFpOr.d.ts +0 -228
package/dist/react/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { B as Badge, b as MemberBadges, O as Offer, e as Redemption } from '../offers-
|
|
1
|
+
import { B as Badge, b as MemberBadges, O as Offer, e as Redemption } from '../offers-DAfe1O3_.js';
|
|
2
2
|
import { b as ParticipantSession, R as RelayEvent, P as ParticipantActivity, M as MemberSummary } from '../participant-activity-iciCEs_8.js';
|
|
3
|
-
import { g as RelayError, R as RelayClient, m as SubmissionDraft } from '../client-
|
|
4
|
-
import { P as Page,
|
|
3
|
+
import { g as RelayError, R as RelayClient, m as SubmissionDraft } from '../client-3b9HjSzZ.js';
|
|
4
|
+
import { P as Page, H as collectionViewSchema, l as QuestView, a as CreatorAccountProvider, i as QuestOutcomeQuery, g as QuestOutcome } from '../pages-ChDVLrgR.js';
|
|
5
|
+
export { C as CreatorAccount, b as CreatorAccounts } from '../pages-ChDVLrgR.js';
|
|
5
6
|
import * as react from 'react';
|
|
6
7
|
import { ReactNode } from 'react';
|
|
7
|
-
import
|
|
8
|
-
import { z } from 'zod';
|
|
9
|
-
import { E as Entitlement, a as AttemptStatus, f as PointEntry, e as PointBalances, j as PointLedgerReference, T as TieredRewardReference } from '../schema-
|
|
10
|
-
import { a as AuthProvider, A as AccountConnection } from '../accounts-
|
|
11
|
-
export { T as TelegramAccountConnection, b as TelegramSignInMethods } from '../accounts-
|
|
12
|
-
import { c as SignInMethods, C as CosmosChains, d as SignInOption, f as SignInUnavailable, T as TelegramSignInOption, g as SignInWallet, D as DiscoveredWallet } from '../telegram-browser-
|
|
13
|
-
export { a as EmailSignInOption, O as OAuthSignInOption, b as SignInIcon, W as WalletSignInOption, t as telegramMiniAppInitData } from '../telegram-browser-
|
|
14
|
-
import {
|
|
15
|
-
import { h as LeaderboardPlacement,
|
|
16
|
-
import
|
|
17
|
-
import '../submission-input-BbdawqVy.js';
|
|
8
|
+
import * as z from 'zod';
|
|
9
|
+
import { z as z$1 } from 'zod';
|
|
10
|
+
import { E as Entitlement, a as AttemptStatus, f as PointEntry, e as PointBalances, j as PointLedgerReference, T as TieredRewardReference } from '../schema-BA0nRRlt.js';
|
|
11
|
+
import { a as AuthProvider, A as AccountConnection } from '../accounts-CVonEkdb.js';
|
|
12
|
+
export { T as TelegramAccountConnection, b as TelegramSignInMethods } from '../accounts-CVonEkdb.js';
|
|
13
|
+
import { c as SignInMethods, C as CosmosChains, d as SignInOption, f as SignInUnavailable, T as TelegramSignInOption, g as SignInWallet, D as DiscoveredWallet } from '../telegram-browser-o3OIxGrJ.js';
|
|
14
|
+
export { a as EmailSignInOption, O as OAuthSignInOption, b as SignInIcon, W as WalletSignInOption, t as telegramMiniAppInitData } from '../telegram-browser-o3OIxGrJ.js';
|
|
15
|
+
import { m as WalletSigner, k as WalletSignInNetwork, L as LinkedWallet, g as ProfileUpdate, f as ProfileSummary, b as ProfileCompletion, e as ProfileReferral } from '../wallet-B06zvDXp.js';
|
|
16
|
+
import { h as LeaderboardPlacement, b2 as referralSummarySchema, g as LeaderboardPage } from '../groups-CFuTfFqG.js';
|
|
17
|
+
import '../submission-input-DxQ6RnKo.js';
|
|
18
18
|
import '../action-DBzILFx9.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -297,7 +297,7 @@ type MutationOptions<TData, TVariables> = {
|
|
|
297
297
|
*/
|
|
298
298
|
declare function useRelayMutation<TData = unknown, TVariables = void>(mutation: (variables: TVariables, context: MutationContext) => Promise<TData>, options?: MutationOptions<TData, TVariables>): Mutation<TData, TVariables>;
|
|
299
299
|
|
|
300
|
-
type Collection = z.infer<typeof collectionViewSchema>;
|
|
300
|
+
type Collection = z$1.infer<typeof collectionViewSchema>;
|
|
301
301
|
/** The participant's quests and collections, as `useExperience().data` holds them. */
|
|
302
302
|
type ExperienceData = {
|
|
303
303
|
entitlements: Entitlement[];
|
|
@@ -393,8 +393,8 @@ declare const relayKeys: {
|
|
|
393
393
|
*/
|
|
394
394
|
declare function useEntitlements(options?: QueryOptions): MemberQuery<{
|
|
395
395
|
items: ({
|
|
396
|
-
|
|
397
|
-
|
|
396
|
+
status: "unsupported";
|
|
397
|
+
reportedStatus: string;
|
|
398
398
|
id: string;
|
|
399
399
|
member: string;
|
|
400
400
|
reward: {
|
|
@@ -420,9 +420,7 @@ declare function useEntitlements(options?: QueryOptions): MemberQuery<{
|
|
|
420
420
|
revision: number;
|
|
421
421
|
} | {
|
|
422
422
|
[x: string]: unknown;
|
|
423
|
-
status: "
|
|
424
|
-
handover: string;
|
|
425
|
-
startedAt: number;
|
|
423
|
+
status: "available";
|
|
426
424
|
id: string;
|
|
427
425
|
member: string;
|
|
428
426
|
reward: {
|
|
@@ -446,17 +444,11 @@ declare function useEntitlements(options?: QueryOptions): MemberQuery<{
|
|
|
446
444
|
earnedTier: string;
|
|
447
445
|
tier: string;
|
|
448
446
|
revision: number;
|
|
449
|
-
allocation?: {
|
|
450
|
-
[x: string]: unknown;
|
|
451
|
-
item: string;
|
|
452
|
-
label: string;
|
|
453
|
-
} | undefined;
|
|
454
447
|
} | {
|
|
455
448
|
[x: string]: unknown;
|
|
456
|
-
status: "
|
|
449
|
+
status: "handing-over";
|
|
457
450
|
handover: string;
|
|
458
451
|
startedAt: number;
|
|
459
|
-
collectedAt: number;
|
|
460
452
|
id: string;
|
|
461
453
|
member: string;
|
|
462
454
|
reward: {
|
|
@@ -485,16 +477,12 @@ declare function useEntitlements(options?: QueryOptions): MemberQuery<{
|
|
|
485
477
|
item: string;
|
|
486
478
|
label: string;
|
|
487
479
|
} | undefined;
|
|
488
|
-
recovery?: {
|
|
489
|
-
completion: string;
|
|
490
|
-
reason: string;
|
|
491
|
-
flaggedAt: number;
|
|
492
|
-
remainingTier: string | null;
|
|
493
|
-
} | undefined;
|
|
494
480
|
} | {
|
|
495
481
|
[x: string]: unknown;
|
|
496
|
-
status: "
|
|
497
|
-
|
|
482
|
+
status: "collected";
|
|
483
|
+
handover: string;
|
|
484
|
+
startedAt: number;
|
|
485
|
+
collectedAt: number;
|
|
498
486
|
id: string;
|
|
499
487
|
member: string;
|
|
500
488
|
reward: {
|
|
@@ -518,9 +506,21 @@ declare function useEntitlements(options?: QueryOptions): MemberQuery<{
|
|
|
518
506
|
earnedTier: string;
|
|
519
507
|
tier: string;
|
|
520
508
|
revision: number;
|
|
509
|
+
allocation?: {
|
|
510
|
+
[x: string]: unknown;
|
|
511
|
+
item: string;
|
|
512
|
+
label: string;
|
|
513
|
+
} | undefined;
|
|
514
|
+
recovery?: {
|
|
515
|
+
completion: string;
|
|
516
|
+
reason: string;
|
|
517
|
+
flaggedAt: number;
|
|
518
|
+
remainingTier: string | null;
|
|
519
|
+
} | undefined;
|
|
521
520
|
} | {
|
|
522
|
-
|
|
523
|
-
|
|
521
|
+
[x: string]: unknown;
|
|
522
|
+
status: "void";
|
|
523
|
+
voidedAt: number;
|
|
524
524
|
id: string;
|
|
525
525
|
member: string;
|
|
526
526
|
reward: {
|
|
@@ -553,7 +553,15 @@ declare function useEntitlements(options?: QueryOptions): MemberQuery<{
|
|
|
553
553
|
*/
|
|
554
554
|
declare function useDeliveries(options?: QueryOptions): MemberQuery<{
|
|
555
555
|
items: ({
|
|
556
|
-
|
|
556
|
+
kind: "unknown";
|
|
557
|
+
reportedKind: string;
|
|
558
|
+
id: string;
|
|
559
|
+
status: string;
|
|
560
|
+
at: number | null;
|
|
561
|
+
quest: string | null;
|
|
562
|
+
completion: string | null;
|
|
563
|
+
} | {
|
|
564
|
+
[x: string]: z.JSONType;
|
|
557
565
|
kind: "points";
|
|
558
566
|
ledger: {
|
|
559
567
|
id: string;
|
|
@@ -571,8 +579,8 @@ declare function useDeliveries(options?: QueryOptions): MemberQuery<{
|
|
|
571
579
|
[x: string]: unknown;
|
|
572
580
|
kind: "tier";
|
|
573
581
|
entitlement: {
|
|
574
|
-
|
|
575
|
-
|
|
582
|
+
status: "unsupported";
|
|
583
|
+
reportedStatus: string;
|
|
576
584
|
id: string;
|
|
577
585
|
member: string;
|
|
578
586
|
reward: {
|
|
@@ -598,9 +606,7 @@ declare function useDeliveries(options?: QueryOptions): MemberQuery<{
|
|
|
598
606
|
revision: number;
|
|
599
607
|
} | {
|
|
600
608
|
[x: string]: unknown;
|
|
601
|
-
status: "
|
|
602
|
-
handover: string;
|
|
603
|
-
startedAt: number;
|
|
609
|
+
status: "available";
|
|
604
610
|
id: string;
|
|
605
611
|
member: string;
|
|
606
612
|
reward: {
|
|
@@ -624,17 +630,11 @@ declare function useDeliveries(options?: QueryOptions): MemberQuery<{
|
|
|
624
630
|
earnedTier: string;
|
|
625
631
|
tier: string;
|
|
626
632
|
revision: number;
|
|
627
|
-
allocation?: {
|
|
628
|
-
[x: string]: unknown;
|
|
629
|
-
item: string;
|
|
630
|
-
label: string;
|
|
631
|
-
} | undefined;
|
|
632
633
|
} | {
|
|
633
634
|
[x: string]: unknown;
|
|
634
|
-
status: "
|
|
635
|
+
status: "handing-over";
|
|
635
636
|
handover: string;
|
|
636
637
|
startedAt: number;
|
|
637
|
-
collectedAt: number;
|
|
638
638
|
id: string;
|
|
639
639
|
member: string;
|
|
640
640
|
reward: {
|
|
@@ -663,16 +663,12 @@ declare function useDeliveries(options?: QueryOptions): MemberQuery<{
|
|
|
663
663
|
item: string;
|
|
664
664
|
label: string;
|
|
665
665
|
} | undefined;
|
|
666
|
-
recovery?: {
|
|
667
|
-
completion: string;
|
|
668
|
-
reason: string;
|
|
669
|
-
flaggedAt: number;
|
|
670
|
-
remainingTier: string | null;
|
|
671
|
-
} | undefined;
|
|
672
666
|
} | {
|
|
673
667
|
[x: string]: unknown;
|
|
674
|
-
status: "
|
|
675
|
-
|
|
668
|
+
status: "collected";
|
|
669
|
+
handover: string;
|
|
670
|
+
startedAt: number;
|
|
671
|
+
collectedAt: number;
|
|
676
672
|
id: string;
|
|
677
673
|
member: string;
|
|
678
674
|
reward: {
|
|
@@ -696,9 +692,21 @@ declare function useDeliveries(options?: QueryOptions): MemberQuery<{
|
|
|
696
692
|
earnedTier: string;
|
|
697
693
|
tier: string;
|
|
698
694
|
revision: number;
|
|
695
|
+
allocation?: {
|
|
696
|
+
[x: string]: unknown;
|
|
697
|
+
item: string;
|
|
698
|
+
label: string;
|
|
699
|
+
} | undefined;
|
|
700
|
+
recovery?: {
|
|
701
|
+
completion: string;
|
|
702
|
+
reason: string;
|
|
703
|
+
flaggedAt: number;
|
|
704
|
+
remainingTier: string | null;
|
|
705
|
+
} | undefined;
|
|
699
706
|
} | {
|
|
700
|
-
|
|
701
|
-
|
|
707
|
+
[x: string]: unknown;
|
|
708
|
+
status: "void";
|
|
709
|
+
voidedAt: number;
|
|
702
710
|
id: string;
|
|
703
711
|
member: string;
|
|
704
712
|
reward: {
|
|
@@ -729,14 +737,14 @@ declare function useDeliveries(options?: QueryOptions): MemberQuery<{
|
|
|
729
737
|
quest: string | null;
|
|
730
738
|
completion: string | null;
|
|
731
739
|
} | {
|
|
732
|
-
[x: string]: JSONType | undefined;
|
|
740
|
+
[x: string]: z.JSONType | undefined;
|
|
733
741
|
kind: "integration";
|
|
734
742
|
provider: string;
|
|
735
743
|
action: string;
|
|
736
744
|
deliveredAt: number | null;
|
|
737
745
|
revokedAt: number | null;
|
|
738
746
|
reconciliation: {
|
|
739
|
-
[x: string]: JSONType;
|
|
747
|
+
[x: string]: z.JSONType;
|
|
740
748
|
status: string;
|
|
741
749
|
ownership: string;
|
|
742
750
|
at: number;
|
|
@@ -747,14 +755,6 @@ declare function useDeliveries(options?: QueryOptions): MemberQuery<{
|
|
|
747
755
|
quest: string | null;
|
|
748
756
|
completion: string | null;
|
|
749
757
|
roleId?: string | undefined;
|
|
750
|
-
} | {
|
|
751
|
-
kind: "unknown";
|
|
752
|
-
reportedKind: string;
|
|
753
|
-
id: string;
|
|
754
|
-
status: string;
|
|
755
|
-
at: number | null;
|
|
756
|
-
quest: string | null;
|
|
757
|
-
completion: string | null;
|
|
758
758
|
})[];
|
|
759
759
|
}>;
|
|
760
760
|
|
|
@@ -2078,6 +2078,83 @@ declare function useTelegramAccount(): {
|
|
|
2078
2078
|
error: RelayError | null;
|
|
2079
2079
|
refresh(): Promise<void>;
|
|
2080
2080
|
};
|
|
2081
|
+
/**
|
|
2082
|
+
* The signed-in participant's creator accounts in `data` (`{ accounts }`): the platform accounts
|
|
2083
|
+
* they publish from, such as a YouTube channel. Creator accounts are not `useAccounts()`'s
|
|
2084
|
+
* providers in SDK 1.x, so they have this hook of their own, with the same behavior: `connect()`
|
|
2085
|
+
* leaves for the provider's consent screen and comes back linked, linking another account on the
|
|
2086
|
+
* same platform replaces it, and a failure lands in `actionError`.
|
|
2087
|
+
*/
|
|
2088
|
+
declare function useCreatorAccounts(): {
|
|
2089
|
+
connect: (provider: CreatorAccountProvider) => Promise<boolean>;
|
|
2090
|
+
disconnect: (provider: CreatorAccountProvider) => Promise<boolean>;
|
|
2091
|
+
isPending: boolean;
|
|
2092
|
+
actionError: RelayError | null;
|
|
2093
|
+
resetAction: () => void;
|
|
2094
|
+
retry: () => Promise<boolean>;
|
|
2095
|
+
settle: () => boolean;
|
|
2096
|
+
/** True when the member's account on `provider` is linked and readable right now. */
|
|
2097
|
+
isConnected: (provider: CreatorAccountProvider) => boolean;
|
|
2098
|
+
status: "loading";
|
|
2099
|
+
data: undefined;
|
|
2100
|
+
error: null;
|
|
2101
|
+
refresh(): Promise<void>;
|
|
2102
|
+
} | {
|
|
2103
|
+
connect: (provider: CreatorAccountProvider) => Promise<boolean>;
|
|
2104
|
+
disconnect: (provider: CreatorAccountProvider) => Promise<boolean>;
|
|
2105
|
+
isPending: boolean;
|
|
2106
|
+
actionError: RelayError | null;
|
|
2107
|
+
resetAction: () => void;
|
|
2108
|
+
retry: () => Promise<boolean>;
|
|
2109
|
+
settle: () => boolean;
|
|
2110
|
+
/** True when the member's account on `provider` is linked and readable right now. */
|
|
2111
|
+
isConnected: (provider: CreatorAccountProvider) => boolean;
|
|
2112
|
+
status: "error";
|
|
2113
|
+
data: undefined;
|
|
2114
|
+
error: RelayError;
|
|
2115
|
+
refresh(): Promise<void>;
|
|
2116
|
+
} | {
|
|
2117
|
+
connect: (provider: CreatorAccountProvider) => Promise<boolean>;
|
|
2118
|
+
disconnect: (provider: CreatorAccountProvider) => Promise<boolean>;
|
|
2119
|
+
isPending: boolean;
|
|
2120
|
+
actionError: RelayError | null;
|
|
2121
|
+
resetAction: () => void;
|
|
2122
|
+
retry: () => Promise<boolean>;
|
|
2123
|
+
settle: () => boolean;
|
|
2124
|
+
/** True when the member's account on `provider` is linked and readable right now. */
|
|
2125
|
+
isConnected: (provider: CreatorAccountProvider) => boolean;
|
|
2126
|
+
status: "signed-out";
|
|
2127
|
+
data: undefined;
|
|
2128
|
+
error: null;
|
|
2129
|
+
refresh(): Promise<void>;
|
|
2130
|
+
} | {
|
|
2131
|
+
connect: (provider: CreatorAccountProvider) => Promise<boolean>;
|
|
2132
|
+
disconnect: (provider: CreatorAccountProvider) => Promise<boolean>;
|
|
2133
|
+
isPending: boolean;
|
|
2134
|
+
actionError: RelayError | null;
|
|
2135
|
+
resetAction: () => void;
|
|
2136
|
+
retry: () => Promise<boolean>;
|
|
2137
|
+
settle: () => boolean;
|
|
2138
|
+
/** True when the member's account on `provider` is linked and readable right now. */
|
|
2139
|
+
isConnected: (provider: CreatorAccountProvider) => boolean;
|
|
2140
|
+
status: "ready";
|
|
2141
|
+
data: {
|
|
2142
|
+
accounts: {
|
|
2143
|
+
provider: CreatorAccountProvider;
|
|
2144
|
+
configured: boolean;
|
|
2145
|
+
status: "disconnected" | "connected" | "reconnect";
|
|
2146
|
+
subject: string | null;
|
|
2147
|
+
revision: number;
|
|
2148
|
+
profile: {
|
|
2149
|
+
name?: string | undefined;
|
|
2150
|
+
username?: string | undefined;
|
|
2151
|
+
imageUrl?: string | undefined;
|
|
2152
|
+
} | null;
|
|
2153
|
+
}[];
|
|
2154
|
+
};
|
|
2155
|
+
error: RelayError | null;
|
|
2156
|
+
refresh(): Promise<void>;
|
|
2157
|
+
};
|
|
2081
2158
|
|
|
2082
2159
|
/**
|
|
2083
2160
|
* The signed-in participant's linked Solana, EVM and Cosmos wallets, in `data`.
|
|
@@ -2315,7 +2392,7 @@ declare function useProfileCompletions(profile: string, options?: {
|
|
|
2315
2392
|
limit?: number;
|
|
2316
2393
|
}): PagedQuery<ProfileCompletion>;
|
|
2317
2394
|
|
|
2318
|
-
type ReferralSummary = z.infer<typeof referralSummarySchema>;
|
|
2395
|
+
type ReferralSummary = z$1.infer<typeof referralSummarySchema>;
|
|
2319
2396
|
/**
|
|
2320
2397
|
* Keeps an invitation code from the landing URL (`?ref=CODE` by default)
|
|
2321
2398
|
* through sign-in, including the round trip to an OAuth provider.
|
|
@@ -2451,4 +2528,4 @@ declare function usePointLedgers(): Query<PointLedgerReference[]>;
|
|
|
2451
2528
|
*/
|
|
2452
2529
|
declare function useTieredRewards(): Query<TieredRewardReference[]>;
|
|
2453
2530
|
|
|
2454
|
-
export { type Collection, CosmosChains, DiscoveredWallet, type ExperienceData, type Invitation, type KnownQuestStatusCode, type KnownRoleDeliveryStatus, type MemberPagedQuery, type MemberQuery, type MemberQueryOptions, type MemberSnapshot, type Mutation, type MutationContext, type MutationOptions, type MutationStatus, type OAuthProvider, Page, type PageLoader, type PageRead, type PagedQuery, type Query, type QueryContext, type QueryKey, type QueryOptions, type QueryRead, type QuerySnapshot, type QuestActionState, type QuestInput, type QuestNotice, type QuestStatus, type QuestStatusCode, type QuestStatusText, type QuestTone, type ReferralSummary, type RelayActionResult, RelayClient, type RelayPolling, RelayProvider, type RelayQueryOptions, type RoleDelivery, type RoleDeliveryStatus, type SavedSubmission, SignInMethods, SignInOption, SignInUnavailable, SignInWallet, TelegramSignInOption, canRepeat, canSubmit, captureReferralCode, completionCountText, isAutomatic, isConnected, isCoolingDown, isFinished, progressOf, questActionState, questGroups, questStatus, questStatusText, relayKeys, roleDeliveryLabel, roleDeliveryStatus, useAccounts, useActivity, useBadgeCatalog, useBadges, useBalances, useDeliveries, useEntitlements, useExperience, useInvalidate, useInvitation, useLeaderboard, useLeaderboardHistory, useLeaderboardPlacement, useMe, useMemberPages, useMemberQuery, useMyProfile, useOffers, usePointHistory, usePointLedgers, useProfile, useProfileBadges, useProfileCompletions, useProfileReferral, useQuest, useQuestAction, useQuestOutcomes, useRedeemOffer, useReferralSummary, useRelay, useRelayAction, useRelayMutation, useRelayPages, useRelayQuery, useSession, useSetQueryData, useSignIn, useSignInMethods, useSignInOptions, useSignInWallets, useSignOut, useTelegramAccount, useTieredRewards, useWalletDiscovery, useWallets };
|
|
2531
|
+
export { type Collection, CosmosChains, CreatorAccountProvider, DiscoveredWallet, type ExperienceData, type Invitation, type KnownQuestStatusCode, type KnownRoleDeliveryStatus, type MemberPagedQuery, type MemberQuery, type MemberQueryOptions, type MemberSnapshot, type Mutation, type MutationContext, type MutationOptions, type MutationStatus, type OAuthProvider, Page, type PageLoader, type PageRead, type PagedQuery, type Query, type QueryContext, type QueryKey, type QueryOptions, type QueryRead, type QuerySnapshot, type QuestActionState, type QuestInput, type QuestNotice, type QuestStatus, type QuestStatusCode, type QuestStatusText, type QuestTone, type ReferralSummary, type RelayActionResult, RelayClient, type RelayPolling, RelayProvider, type RelayQueryOptions, type RoleDelivery, type RoleDeliveryStatus, type SavedSubmission, SignInMethods, SignInOption, SignInUnavailable, SignInWallet, TelegramSignInOption, canRepeat, canSubmit, captureReferralCode, completionCountText, isAutomatic, isConnected, isCoolingDown, isFinished, progressOf, questActionState, questGroups, questStatus, questStatusText, relayKeys, roleDeliveryLabel, roleDeliveryStatus, useAccounts, useActivity, useBadgeCatalog, useBadges, useBalances, useCreatorAccounts, useDeliveries, useEntitlements, useExperience, useInvalidate, useInvitation, useLeaderboard, useLeaderboardHistory, useLeaderboardPlacement, useMe, useMemberPages, useMemberQuery, useMyProfile, useOffers, usePointHistory, usePointLedgers, useProfile, useProfileBadges, useProfileCompletions, useProfileReferral, useQuest, useQuestAction, useQuestOutcomes, useRedeemOffer, useReferralSummary, useRelay, useRelayAction, useRelayMutation, useRelayPages, useRelayQuery, useSession, useSetQueryData, useSignIn, useSignInMethods, useSignInOptions, useSignInWallets, useSignOut, useTelegramAccount, useTieredRewards, useWalletDiscovery, useWallets };
|
package/dist/react/index.js
CHANGED
|
@@ -9,20 +9,20 @@ import {
|
|
|
9
9
|
readSignInMethods,
|
|
10
10
|
signInOptionsFrom,
|
|
11
11
|
telegramMiniAppInitData
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
12
|
+
} from "../chunk-2LKGAL63.js";
|
|
13
|
+
import "../chunk-577DG2IT.js";
|
|
14
14
|
import {
|
|
15
15
|
createRelayAction
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
16
|
+
} from "../chunk-KYUQEZZA.js";
|
|
17
|
+
import "../chunk-6U5WWH3W.js";
|
|
18
|
+
import "../chunk-UEMLYPKJ.js";
|
|
19
|
+
import "../chunk-XGXDINGM.js";
|
|
20
20
|
import "../chunk-KDR2VAJP.js";
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-R4S6BFOH.js";
|
|
22
|
+
import "../chunk-TZJT5CRF.js";
|
|
23
23
|
import {
|
|
24
24
|
sessionMember
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-EQF4ID47.js";
|
|
26
26
|
import {
|
|
27
27
|
RelayError,
|
|
28
28
|
RelayErrorCode,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
clientError,
|
|
31
31
|
isRelayError,
|
|
32
32
|
isRequestError
|
|
33
|
-
} from "../chunk-
|
|
33
|
+
} from "../chunk-AWWCEP7F.js";
|
|
34
34
|
|
|
35
35
|
// src/react/context.ts
|
|
36
36
|
import { createContext, useContext } from "react";
|
|
@@ -2777,6 +2777,60 @@ function useTelegramAccount() {
|
|
|
2777
2777
|
]
|
|
2778
2778
|
);
|
|
2779
2779
|
}
|
|
2780
|
+
function useCreatorAccounts() {
|
|
2781
|
+
const relay = useRelay();
|
|
2782
|
+
const invalidate = useInvalidate();
|
|
2783
|
+
const session = useScopeSession();
|
|
2784
|
+
const query = useMemberQuery(
|
|
2785
|
+
[...relayKeys.accounts, "creator"],
|
|
2786
|
+
(options) => relay.auth.creatorAccounts.list(options),
|
|
2787
|
+
{ refetchOnFocus: true }
|
|
2788
|
+
);
|
|
2789
|
+
const { isPending, actionError: actionError2, resetAction, run, retry, settle } = useAction();
|
|
2790
|
+
const actions = useMemo8(
|
|
2791
|
+
() => ({
|
|
2792
|
+
connect: (provider) => run(async () => {
|
|
2793
|
+
const { url } = await relay.auth.creatorAccounts.connect(provider, {
|
|
2794
|
+
session
|
|
2795
|
+
});
|
|
2796
|
+
window.location.assign(url);
|
|
2797
|
+
}),
|
|
2798
|
+
disconnect: (provider) => run(async () => {
|
|
2799
|
+
await relay.auth.creatorAccounts.disconnect(provider, { session });
|
|
2800
|
+
void invalidate([relayKeys.accounts, relayKeys.experience]);
|
|
2801
|
+
})
|
|
2802
|
+
}),
|
|
2803
|
+
[relay, invalidate, session, run]
|
|
2804
|
+
);
|
|
2805
|
+
const accounts = query.data?.accounts;
|
|
2806
|
+
return useMemo8(
|
|
2807
|
+
() => ({
|
|
2808
|
+
...query,
|
|
2809
|
+
isPending,
|
|
2810
|
+
actionError: actionError2,
|
|
2811
|
+
resetAction,
|
|
2812
|
+
retry,
|
|
2813
|
+
settle,
|
|
2814
|
+
/** True when the member's account on `provider` is linked and readable right now. */
|
|
2815
|
+
isConnected: (provider) => Boolean(
|
|
2816
|
+
accounts?.some(
|
|
2817
|
+
(account) => account.provider === provider && account.configured && account.status === "connected"
|
|
2818
|
+
)
|
|
2819
|
+
),
|
|
2820
|
+
...actions
|
|
2821
|
+
}),
|
|
2822
|
+
[
|
|
2823
|
+
query,
|
|
2824
|
+
isPending,
|
|
2825
|
+
actionError2,
|
|
2826
|
+
resetAction,
|
|
2827
|
+
retry,
|
|
2828
|
+
settle,
|
|
2829
|
+
accounts,
|
|
2830
|
+
actions
|
|
2831
|
+
]
|
|
2832
|
+
);
|
|
2833
|
+
}
|
|
2780
2834
|
|
|
2781
2835
|
// src/react/profiles.ts
|
|
2782
2836
|
import { useMemo as useMemo9 } from "react";
|
|
@@ -3103,6 +3157,7 @@ export {
|
|
|
3103
3157
|
useBadgeCatalog,
|
|
3104
3158
|
useBadges,
|
|
3105
3159
|
useBalances,
|
|
3160
|
+
useCreatorAccounts,
|
|
3106
3161
|
useDeliveries,
|
|
3107
3162
|
useEntitlements,
|
|
3108
3163
|
useExperience,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as L,B as z,C as ee,Cc as Se,D as re,Dc as qe,Df as Pe,E as te,Ec as Ee,Ef as Oe,Fc as Q,Gc as Ce,Gd as U,Hb as ke,Hh as gr,Id as j,Ig as Ue,Ka as I,Kb as we,Kc as S,La as de,Ld as Ae,Ma as P,Na as ue,Nc as sr,Qb as nr,Rb as ar,Re as Le,S as ne,T as ae,Td as G,Uc as y,Vc as Me,Vd as De,W as oe,Wc as q,X as T,Yc as cr,_ as se,_f as Be,a as R,aa as ce,be as Te,cb as me,cf as mr,da as ie,df as lr,fb as le,ff as pr,gc as or,hh as Ge,ig as Ke,jc as ve,jg as Qe,kb as pe,kc as ye,kf as Ie,kg as N,md as ir,nd as dr,ob as ge,od as ur,pd as ze,qd as je,r as F,s as H,sd as $e,t as J,tc as O,u as V,uc as x,ud as Re,v as X,vb as he,w as Y,wd as xe,xb as fe,xc as B,yc as K,zc as be}from"./chunks/WKATKZXE.js";import{Vb as D,Wb as W,hc as $,nb as C,pa as A,pc as M,td as tr,vb as _}from"./chunks/IDOMZWRY.js";function Ne(e){if(!Number.isInteger(e)||e<0||e>255)throw new Error("Token decimals must be an integer from 0 to 255")}function hr(e,t){Ne(t);let r=/^(\d+)(?:\.(\d+))?$/.exec(e.trim());if(!r)throw new Error(`Use a decimal amount such as "1.5", not "${e}"`);let[,n,s=""]=r,c=s.replace(/0+$/,"");if(c.length>t)throw new Error(`"${e}" has more than ${t} decimal places, which this token cannot hold`);return BigInt(n+c.padEnd(t,"0"))}function fr(e,t){Ne(t);let r=typeof e=="bigint"?e:BigInt(e),n=r<0n?"-":"",s=(r<0n?-r:r).toString().padStart(t+1,"0"),c=s.slice(0,s.length-t),i=s.slice(s.length-t).replace(/0+$/,"");return n+c+(i?"."+i:"")}function _e(e,t={}){let{trigger:r,completion:n,requires:s,performance:c,retryCooldownMs:i,completionCooldownMs:d}=e,a=r.kind==="automatic"?r.tracker:void 0,p=a?.content===!0;if(c&&!p)throw new Error("Performance requires a content quest");if(p){if(n.kind!=="keyed")throw new Error("Content quests complete once per content item");if(a.beneficiary!=="author"||a.on!=="new-record")throw new Error("A content quest pays each content item's author and fires on its first observation")}if(i!==void 0&&(r.kind!=="manual"||r.actor==="staff"))throw new Error("A retry cooldown applies only to quests members submit themselves");if(d!==void 0){if(r.kind!=="manual"||r.actor==="staff")throw new Error("A completion cooldown applies only to quests members submit themselves");if(n.kind==="once")throw new Error("A completion cooldown needs a quest members can complete more than once: this one completes once per member")}if(r.kind==="automatic"&&!a){if(!t.template&&s.length===0)throw new Error("Automatic quests need at least one prerequisite");if(n.kind!=="once")throw new Error("Prerequisite-only automatic quests complete once")}}var kr=["author"],wr=["author","messageAuthor"];function We(e){if(!ie(e))return[];switch(e.kind){case"x-search":return ne;case"discord-messages":return kr;case"discord-reactions":return wr;case"custom":return["author",...e.accounts??[]]}}var Ze=new Map;function vr(e){let t=e.kind==="discord-messages"&&e.text?"messages-text":e.kind,r=Ze.get(t);return r||(r=z(t==="messages-text"?V:t==="discord-messages"?J:X),Ze.set(t,r)),r}function Fe(e){switch(e.kind){case"x-search":return;case"discord-messages":case"discord-reactions":return vr(e);case"custom":return e.data}}function Ur(e){return y("badge",Be.parse(e))}function Gr(e){return y("ledger",Ie.parse(e))}function Nr(e){let{target:t,ledger:r,...n}=e,s=Ke.parse({...n,qualifiedBy:e.qualifiedBy.key,balance:q(r)}),c=$(M(e.metrics),N.shape.target);return{key:s.key,describe:()=>s,score(i){let d=Qe.parse(i);return N.parse({target:t({metrics:c.parse(d.metrics)}),baseline:t({metrics:c.parse(d.baseline)})})}}}var br=e=>{if("timeZone"in e)throw new Error("streak() no longer takes a timeZone. Set the project timezone with calendar.timeZone in relay.json or in Console settings.");return me.strict().parse({kind:"streak",...e})},Zr=e=>de.brand().parse({kind:"count",count:e}),_r=(e,t={})=>P.brand().parse({kind:"calendar",period:e,...t}),Wr=({days:e})=>P.brand().parse({kind:"rolling",durationMs:e*864e5}),Fr=e=>({kind:"quest",quest:e});function Hr(e){let{qualification:t,inviterGroup:r,milestones:n,bonuses:s,...c}=e,i=Ge.parse({...c,qualification:t.kind==="quest"?{kind:"quest",quest:t.quest.key}:t,...r?{inviterGroup:R.parse(r.key)}:{},milestones:n?.map(({key:d,...a})=>({...a,id:S({key:d,...a})})),bonuses:s?.map(({key:d,ledger:a,quests:p,...h})=>({...h,id:S({key:d,...h}),balance:q(a),quests:p?.map(o=>o.key)}))});return y("referral",i)}function Jr(e={}){return{kind:"earned",...e}}function Vr(e){let{ledger:t,group:r,score:n,settle:s,...c}=e,i=s?.pool,d=Ue.parse({...c,...s?{settle:{...s,prizes:s.prizes??[],...i?{pool:{...i,...i.ledger===void 0?{}:{ledger:q(i.ledger)}}}:{}}}:{},balance:q(t),...r?{group:R.parse(r.key)}:{},score:n?.kind==="earned"?{...n,quests:n.quests?.map(a=>a.key)}:n});return y("leaderboard",d)}var Xr={provider:"x",search:e=>oe.parse({kind:"x-search",...e})};function Sr(e,t){let{data:r,content:n,...s}=t??{};if(n!==void 0){if(r!==void 0)throw new Error(`customSource("${e}") takes data or content, not both: a content source's records carry { body, metrics }`);if(!He(n.body))throw new Error(`customSource("${e}") needs a content body schema: customSource(namespace, { content: { body: z.object({ ... }), metrics: ["likes"] } })`);let c=[...n.metrics??[]];for(let i of c)ae.parse(i);return T.parse({kind:"custom",namespace:e,...s,data:z(D({body:n.body,metrics:W(Object.fromEntries(c.map(i=>[i,C().int().safe().nonnegative().optional()]))).optional()})),content:{metrics:c}})}if(!He(r))throw new Error(`customSource("${e}") needs a data schema: customSource(namespace, { data: z.object({ ... }) }) describes each record's data`);return T.parse({kind:"custom",namespace:e,...s,data:z(r)})}function He(e){return typeof e=="object"&&e!==null&&"_zod"in e}function Yr(e){return y("tracker",ce.parse(e))}function qr(e={}){return F.parse({kind:"discord-messages",...e.text?{text:!0}:{}})}function Er(){return H.parse({kind:"discord-reactions"})}var et={provider:"discord",grantRole:e=>Y.parse({kind:"integration",provider:"discord",action:"grant-role",roleId:e}),messages:qr,reactions:Er,roles(e={}){return x.parse({provider:"discord",resource:"role",assignable:e.assignable??!1})},channels(e={}){return x.parse({provider:"discord",resource:"channel",types:e.types??["text","announcement"]})}},rt={reactions(){return Sr(Pe,{identities:["member"],accounts:["messageAuthor"],data:Oe})}},tt=()=>({provider:"domino",resource:"point-ledger"});function f(e,t){return t}var nt={pointLedger(e){let t={...e,kind:"point-ledger",default:e.default?R.parse(e.default.key):""};return f("point-ledger",Me.prefault(t.default).meta(t))},datetime(e){let t={...e,kind:"datetime",default:B.parse(e.default)};return f("datetime",B.default(t.default).meta(t))},resource(e){let t={...e,source:x.parse(e.source),kind:"resource",default:K.parse(e.default??"")};return f("resource",K.default(t.default).meta(t))},quiz(e){let t=O.parse(e.default);return f("quiz",O.default(t).meta({...e,default:t,kind:"quiz"}))},text(e){let t={...e,kind:"text",minLength:e.minLength??1,maxLength:e.maxLength??2e3,multiline:e.multiline??!1};return f("text",A().min(t.minLength).max(t.maxLength).default(t.default).meta(t))},telegramChat(e){let t={...e,kind:"text",default:e.default??"",minLength:0,maxLength:64,multiline:!1,picker:"telegram-chat"};return f("text",A().max(t.maxLength).default(t.default).meta(t))},amount(e){if(!Se(e.default))throw new Error(`settings.amount() takes a base-unit integer string as its default, not "${e.default}"`);let t={...e,kind:"text",minLength:1,maxLength:100,multiline:!1,picker:"amount"};return f("text",Q(t).default(t.default).meta(t))},chain(e){if(!qe(e.default))throw new Error(`settings.chain() takes "solana" or an EVM chain ID such as "eip155:8453" as its default, not "${e.default}"`);let t={...e,kind:"text",minLength:1,maxLength:64,multiline:!1,picker:"chain"};return f("text",Q(t).transform(r=>r).default(t.default).meta(t))},integer(e){return f("integer",C().int().min(e.min).max(e.max).default(e.default).meta({...e,kind:"integer"}))},boolean(e){return f("boolean",_().default(e.default).meta({...e,kind:"boolean"}))},choice(e){return f("choice",M(e.options).default(e.default).meta({...e,kind:"choice"}))},object(e){return D(e).strict()}},ot=e=>Re(e.key,e.name),st=e=>xe(e.key,e.title),ct=(e,t)=>ze.parse({kind:"points",balance:q(e),amount:t}),it={text:(e={})=>({input:"text",constraints:ve.parse(e)}),url:(e={})=>({input:"url",constraints:ye.parse(e)}),photo:()=>"photo",quiz:()=>"quiz"};function dt(e){if(e?.actor&&e.input!==void 0)throw new Error('manual() cannot combine actor "staff" with input: staff-captured evidence is not supported. Use manual({ actor: "staff" }) for a staff confirmation, or manual({ input }) for evidence the participant submits.');return typeof e?.input=="object"?{kind:"manual",...e.input}:{kind:"manual",input:e?.input??"none",...e?.actor?{actor:e.actor}:{}}}var Ve=new WeakMap,Xe=new WeakMap;function Ye(e,t){let{tracker:r,beneficiary:n="author",on:s,where:c,enrollment:i,since:d,historical:a,content:p}=e;if(!r?.source)throw new Error(t==="automatic"?"automatic() takes no argument, or { tracker } with a tracker handle from defineTracker":"content() takes { tracker } with a tracker handle from defineTracker");let{source:h}=r;if(!se(h))throw new Error('Tracker triggers need attributable records: declare customSource(namespace, { identities: ["wallet"] }) or other identity kinds');if(p&&!L(h))throw new Error(`content() needs a tracker whose source has content: x.search(), or customSource(namespace, { content: { body, metrics } }). Tracker "${r.key}" has none; use automatic({ tracker }) instead.`);if(d==="enrollment"&&i!=="required")throw new Error(`${t}() counts from enrollment only on a quest that requires it: add enrollment: "required"`);let o=We(h);if(!o.includes(n))throw new Error(h.kind==="custom"?`Tracker "${r.key}" has no "${n}" account: declare it in customSource(namespace, { accounts: ["${n}"] })`:`Tracker "${r.key}" pays ${o.map(l=>`"${l}"`).join(" or ")}, not "${n}"`);let u=ge.parse({tracker:r.key,source:h.kind,on:p?"new-record":s??le(h.kind),...c?{where:c}:{},beneficiary:n,...i==="required"?{enrollment:i}:{},...d&&d!=="activation"?{since:d}:{},...a&&a!==(p?"claim":"staff")?{historical:a}:{},...p?{content:p}:{}}),m=Fe(h),v=m?te(m,u.where):null;if(v)throw new Error(v);let w={kind:"automatic",tracker:u};m&&Ve.set(w,m);let g=L(h);return g&&Xe.set(w,g.metrics),w}function ut(e){return e?Ye(e,"automatic"):{kind:"automatic"}}function mt(e){if(e&&typeof e=="object"&&"source"in e&&"key"in e&&!("tracker"in e))throw new Error("content() takes { tracker }: write content({ tracker: posts }) instead of content(posts)");return Ye({...e,content:!0},"content")}var lt=e=>{let{key:t,cost:r,...n}=e;return ke.parse({...n,id:S(e),cost:typeof r=="number"?r:{balance:q(r.ledger)}})},Cr=e=>({kind:"keyed",key:e}),Mr=e=>{let{distinct:t,...r}=e;return{...ue.parse({kind:"progress",window:{kind:"lifetime"},...r}),distinct:t}},pt=()=>({kind:"untracked"}),gt=()=>({kind:"staff-handover"}),ht=()=>({kind:"automatic"});function ft(e){let{key:t,tiers:r,...n}=e,s=S(e),c=je.parse({id:s,...n,tiers:r.map(({key:i,...d})=>({...d,id:S({key:i,...d})}))});return y("tiered-reward",{key:c.id,tier:i=>$e.parse({kind:"tier",reward:c,tier:i})})}var zr=()=>({kind:"once"});function jr(e={}){return{kind:"accept",...e}}function $r(e){return{kind:"review",...e}}var E={accept:jr,defer:e=>({kind:"defer",...e}),progress:e=>({kind:"progress",...e}),reject:e=>({kind:"reject",...e}),review:$r};function Je(e){let t=e.kind==="reject"&&e.code!==void 0?fe(e.code):null;if(t)throw new Error(t)}var kt={quiz(e,t={}){let r=Te.parse(e),n=Object.keys(r),s=C().int().min(1).max(n.length).parse(t.minimumCorrect??n.length);return async({input:c})=>{let i=Object.keys(c.answers).length===n.length&&n.every(a=>Object.hasOwn(c.answers,a)),d=n.filter(a=>c.answers[a]===r[a]).length;return i&&d>=s?E.accept():E.reject({reason:"Review your answers and try again."})}},photo(e){return async t=>{let r=e(t),n=await t.review.photo({image:t.input.photo,criteria:r.criteria});return n.kind==="unclear"?r.unclear==="human-review"?E.review({reason:n.reason}):E.reject({reason:n.reason}):n.kind==="pass"?E.accept():E.reject({reason:n.reason})}}},Rr={once:zr,keyed:Cr,streak:br,progress:Mr};function er(e){return function(r){let n=S(r),s=[...new Set((r.integrations??[]).map(o=>we.parse(o.provider)))],c=r.trigger.kind==="automatic"&&r.trigger.tracker?.content===!0,i=r.trigger.kind==="automatic"&&r.trigger.tracker!==void 0,d=r.completion,a=typeof d=="function"?d(Rr):d;if(c&&a!==void 0)throw new Error("A content quest completes once per content item: remove its completion");if(!c&&a===void 0)throw new Error("A quest needs a completion, such as once(), keyed(...), streak(...) or progress(...)");if(_e({trigger:r.trigger,completion:a??{kind:"keyed"},requires:r.requires??[],performance:r.performance?I.parse({metrics:r.performance.metrics,maxAgeMs:r.performance.maxAgeMs}):void 0,...r.retryCooldownMs===void 0?{}:{retryCooldownMs:r.retryCooldownMs},...r.completionCooldownMs===void 0?{}:{completionCooldownMs:r.completionCooldownMs}},{template:e}),r.retryCooldownMs!==void 0&&!U.safeParse(r.retryCooldownMs).success)throw new Error("retryCooldownMs must be whole milliseconds from 1000 (one second) to 604800000 (seven days)");if(r.completionCooldownMs!==void 0&&!U.safeParse(r.completionCooldownMs).success)throw new Error("completionCooldownMs must be whole milliseconds from 1000 (one second) to 604800000 (seven days)");if(r.performance){let o=Xe.get(r.trigger)??[],u=r.performance.metrics.filter(m=>!o.includes(m));if(u.length)throw new Error(`The tracker's source does not measure ${u.join(", ")}`)}if(r.trigger.kind==="manual"&&r.trigger.input!=="none"&&!r.evaluate)throw new Error("Evidence quests require an evaluator");let p=Object.fromEntries(Object.entries(r.settings.shape).map(([o,u])=>{let m=be.safeParse(u.meta());if(!m.success)throw new Error(`Setting "${o}" is not a quest setting: build it with a settings builder, such as settings.integer({ label, default, min, max })`);return[o,m.data]}));for(let o of pe(r.trigger.kind==="automatic"?r.trigger.tracker?.where:void 0))if(!Ee(p[o]))throw new Error(`The tracker filter compares with setting "${o}", which is not an integer or amount setting`);function h(o){let u=r.settings.parse(o),m=Ce(p,u),v=Ae.parse(typeof r.rewards=="function"?r.rewards({settings:u}):r.rewards),w=[...v.flatMap(g=>g.kind==="integration"?[g.provider]:[]),...Object.values(p).flatMap(g=>g.kind==="resource"&&g.source.provider!=="domino"?[g.source.provider]:[])];for(let g of w)if(!s.includes(g))throw new Error(`Declare the ${g} integration on this quest`);return De.parse({quest:n,evaluatorProtocol:G,title:typeof r.title=="function"?r.title({settings:u}):r.title,presentation:r.presentation?.({settings:u})??{},fields:p,values:m,rewards:v,humanReview:r.review?.({settings:u})?.enabled??!0,trigger:r.trigger,...r.performance?{performance:I.parse({metrics:r.performance.metrics,maxAgeMs:r.performance.maxAgeMs})}:{},integrations:s,completion:a?a.kind==="progress"?{kind:a.kind,goal:a.goal,window:a.window,repeat:a.repeat}:a.kind==="streak"?a:{kind:a.kind}:{kind:"keyed"},visibility:r.visibility??"visible",profile:r.profile??{visible:!1},budgets:r.budgets??[],requires:r.requires??[],...r.campaign?{campaign:r.campaign}:{},...r.availability?{availability:r.availability}:{},...r.retryCooldownMs===void 0?{}:{retryCooldownMs:r.retryCooldownMs},...r.completionCooldownMs===void 0?{}:{completionCooldownMs:r.completionCooldownMs}})}return y("quest",{protocol:G,key:n,describe:h,async evaluate(o){let u=r.settings.parse(o.settings),m=i?he.parse(o.tracker):null,v=Ve.get(r.trigger),w=m&&v?ee(v,m.record.data):null;if(w)return j.parse({kind:"reject",reason:`The record's data does not match the data schema this quest was built with: ${w.path} ${w.reason}`});let g=m;if(o.performance){if(!r.performance)throw new Error("Quest has no performance evaluator");let b=Le.parse(o.performance),rr=$(M(r.performance.metrics),C().int().safe().nonnegative()).parse(b.metrics),k=await r.performance.evaluate({settings:u,member:o.member,tracker:g,metrics:rr,observedAt:b.observedAt});if(!k)throw new Error("Performance evaluator returned no decision");if(k.rewards!==void 0)throw new Error("A performance evaluator cannot select rewards. It gates the rewards content evaluation selected: return accept, review or reject with a reason only.");return Je(k),j.parse(k.kind==="accept"?{kind:"accept",rewards:b.rewards}:k.kind==="review"&&o.humanReview?{kind:"review",reason:k.reason,rewards:b.rewards}:{kind:"reject",reason:k.reason,...k.kind==="review"?{requestedReview:!0}:k.code===void 0?{}:{code:k.code}})}let l=r.evaluate?await r.evaluate({settings:u,member:o.member,input:o.input,tracker:g,eligibleAt:o.eligibleAt,calendar:o.calendar,now:o.now,review:o.review,trackers:re(o.trackers),wallet:o.wallet,images:o.images,...o.telegram?{telegram:o.telegram}:{},...Object.fromEntries(s.map(b=>[b,o[b]]))}):E.accept();if(!l)throw new Error("Evaluator returned no decision");if(Je(l),l.kind==="review"&&!o.humanReview)return j.parse({kind:"reject",reason:l.reason,requestedReview:!0});(l.kind==="accept"||l.kind==="review")&&l.completionKey!==void 0&&a?.kind!=="keyed"&&o.diagnose?.({code:"completion-key-ignored",message:xr(a,l.completionKey)});let Z={...o,settings:u,tracker:m};return j.parse(l.kind==="accept"||l.kind==="review"?{...l,rewards:l.rewards??o.rewards,...a?.kind==="keyed"||a?.kind==="progress"?{completionKey:a.kind==="progress"?a.distinct(Z):l.completionKey??a.key(Z)}:{}}:l)}})}}function xr(e,t){let r=`ignores completionKey ${JSON.stringify(t)}`;switch(e?.kind){case void 0:return`A content quest completes once per content item, under a key Relay sets, so it ${r}`;case"once":return`once() completes the quest once per member and ${r}: use keyed(...) to complete it once per key`;case"streak":return`streak(...) keys its own completions and ${r}`;case"progress":return`progress(...) keys each contribution with its distinct(...) and ${r}: derive the key in distinct(...)`}}var wt=er(!1),vt=er(!0);export{pr as CapabilityError,ut as automatic,ht as automaticFulfillment,ot as badge,dr as balanceAtLeast,lt as budget,_r as calendar,lr as capabilityErrorCodes,ir as completed,mt as content,ar as cosmosDenomSchema,nr as cosmosNetworkSchema,Zr as count,Sr as customSource,E as decision,Ur as defineBadge,sr as defineCampaign,mr as defineDashboard,Nr as defineEngagementReward,cr as defineGroup,Vr as defineLeaderboard,Gr as defineLedger,gr as defineOffer,wt as defineQuest,vt as defineQuestType,Hr as defineReferral,ft as defineTieredReward,Yr as defineTracker,et as discord,Jr as earned,kt as evaluators,it as evidence,fr as formatUnits,st as groupMembership,ur as inGroup,or as isEvmChainId,Cr as keyed,dt as manual,zr as once,hr as parseUnits,tt as pointLedgers,ct as points,Mr as progress,Fr as questCompleted,Wr as rolling,nt as settings,gt as staffHandover,br as streak,rt as telegram,z as trackerDataSchema,he as trackerTriggerContextSchema,pt as untracked,Xr as x,tr as z};
|
|
1
|
+
import{$b as Me,$c as U,$d as We,Ad as At,Af as Ye,B as $,Bf as et,C as re,Cc as Mt,D as ae,Dc as Re,E as ne,Ec as $t,F as oe,Fb as Se,Fc as zt,G as se,Ge as _e,H as ce,Hb as Ee,Hc as Ae,I as ie,Ig as nt,J as de,Kc as jt,Lc as Lt,Mf as It,Nc as Te,Nf as Bt,Oc as De,Pf as Ot,Rb as qe,Rd as Tt,Rh as it,Sd as Dt,Sg as ot,Td as Pt,Tg as st,Ua as B,Ub as Ce,Ud as Ue,Uf as tt,Ug as W,Va as pe,Vd as Ve,Wa as O,X as ue,Xa as ke,Xc as K,Xd as Ze,Y as le,Yb as xe,Yc as T,Zd as Qe,_b as Et,a as R,aa as me,ad as V,ba as A,bc as N,bd as Pe,ea as fe,ed as Ie,fa as I,fd as Be,ga as he,gd as Oe,hd as S,id as Ne,ja as ge,je as Z,le as z,lg as rt,mb as we,md as E,mg as at,oe as Fe,pb as ve,pd as Rt,pi as Nt,qc as $e,qh as ct,r as H,s as J,t as X,tc as ze,u as Y,ub as be,uc as qt,v as ee,vc as je,vf as He,w as te,wd as b,we as Q,xc as Ct,xd as Ke,yb as ye,yc as xt,yd as q,ye as Ge,yf as Je,zc as Le,zf as Xe}from"./chunks/BG43KQ2T.js";import{Cb as x,Ec as M,Kb as G,Pd as St,ic as P,jc as _,va as D,wc as L}from"./chunks/EWU4OKSY.js";function dt(e){if(!Number.isInteger(e)||e<0||e>255)throw new Error("Token decimals must be an integer from 0 to 255")}function Kt(e,r){dt(r);let t=/^(\d+)(?:\.(\d+))?$/.exec(e.trim());if(!t)throw new Error(`Use a decimal amount such as "1.5", not "${e}"`);let[,a,s=""]=t,c=s.replace(/0+$/,"");if(c.length>r)throw new Error(`"${e}" has more than ${r} decimal places, which this token cannot hold`);return BigInt(a+c.padEnd(r,"0"))}function Ut(e,r){dt(r);let t=typeof e=="bigint"?e:BigInt(e),a=t<0n?"-":"",s=(t<0n?-t:t).toString().padStart(r+1,"0"),c=s.slice(0,s.length-r),i=s.slice(s.length-r).replace(/0+$/,"");return a+c+(i?"."+i:"")}function lt(e,r={}){let{trigger:t,completion:a,requires:s,performance:c,retryCooldownMs:i,completionCooldownMs:d}=e,n=t.kind==="automatic"?t.tracker:void 0,f=n?.content===!0;if(c&&!f)throw new Error("Performance requires a content quest");if(f){if(a.kind!=="keyed")throw new Error("Content quests complete once per content item");if(n.beneficiary!=="author"||n.on!=="new-record")throw new Error("A content quest pays each content item's author and fires on its first observation")}if(i!==void 0&&(t.kind!=="manual"||t.actor==="staff"))throw new Error("A retry cooldown applies only to quests members submit themselves");if(d!==void 0){if(t.kind!=="manual"||t.actor==="staff")throw new Error("A completion cooldown applies only to quests members submit themselves");if(a.kind==="once")throw new Error("A completion cooldown needs a quest members can complete more than once: this one completes once per member")}if(t.kind==="automatic"&&!n){if(!r.template&&s.length===0)throw new Error("Automatic quests need at least one prerequisite");if(a.kind!=="once")throw new Error("Prerequisite-only automatic quests complete once")}}var Vt=["author"],Zt=["author","messageAuthor"];function mt(e){if(!ge(e))return[];switch(e.kind){case"x-search":return ue;case"discord-messages":return Vt;case"discord-reactions":return Zt;case"custom":return["author",...e.accounts??[]]}}var ut=new Map;function Qt(e){let r=e.kind==="discord-messages"&&e.text?"messages-text":e.kind,t=ut.get(r);return t||(t=$(r==="messages-text"?Y:r==="discord-messages"?X:ee),ut.set(r,t)),t}function ft(e){switch(e.kind){case"x-search":return;case"discord-messages":case"discord-reactions":return Qt(e);case"custom":return e.data}}function hr(e){return b("badge",nt.parse(e))}function gr(e){return b("ledger",tt.parse(e))}function pr(e){let{target:r,ledger:t,...a}=e,s=ot.parse({...a,qualifiedBy:e.qualifiedBy.key,balance:q(t)}),c=L(M(e.metrics),W.shape.target);return{key:s.key,describe:()=>s,score(i){let d=st.parse(i);return W.parse({target:r({metrics:c.parse(d.metrics)}),baseline:r({metrics:c.parse(d.baseline)})})}}}var Ft=e=>{if("timeZone"in e)throw new Error("streak() no longer takes a timeZone. Set the project timezone with calendar.timeZone in relay.json or in Console settings.");return we.strict().parse({kind:"streak",...e})},kr=e=>pe.brand().parse({kind:"count",count:e}),wr=(e,r={})=>O.brand().parse({kind:"calendar",period:e,...r}),vr=({days:e})=>O.brand().parse({kind:"rolling",durationMs:e*864e5}),br=e=>({kind:"quest",quest:e});function yr(e){let{qualification:r,inviterGroup:t,milestones:a,bonuses:s,...c}=e,i=it.parse({...c,qualification:r.kind==="quest"?{kind:"quest",quest:r.quest.key}:r,...t?{inviterGroup:R.parse(t.key)}:{},milestones:a?.map(({key:d,...n})=>({...n,id:E({key:d,...n})})),bonuses:s?.map(({key:d,ledger:n,quests:f,...p})=>({...p,id:E({key:d,...p}),balance:q(n),quests:f?.map(o=>o.key)}))});return b("referral",i)}function Sr(e={}){return{kind:"earned",...e}}function Er(e){let{ledger:r,group:t,score:a,settle:s,...c}=e,i=s?.pool,d=ct.parse({...c,...s?{settle:{...s,prizes:s.prizes??[],...i?{pool:{...i,...i.ledger===void 0?{}:{ledger:q(i.ledger)}}}:{}}}:{},balance:q(r),...t?{group:R.parse(t.key)}:{},score:a?.kind==="earned"?{...a,quests:a.quests?.map(n=>n.key)}:a});return b("leaderboard",d)}var qr={provider:"x",search:e=>me.parse({kind:"x-search",...e})};function j(e,r){let{data:t,content:a,...s}=r??{};if(a!==void 0){if(t!==void 0)throw new Error(`customSource("${e}") takes data or content, not both: a content source's records carry { body, metrics }`);if(!ht(a.body))throw new Error(`customSource("${e}") needs a content body schema: customSource(namespace, { content: { body: z.object({ ... }), metrics: ["likes"] } })`);let c=[...a.metrics??[]];for(let i of c)le.parse(i);return A.parse({kind:"custom",namespace:e,...s,data:$(P({body:a.body,metrics:_(Object.fromEntries(c.map(i=>[i,x().int().safe().nonnegative().optional()]))).optional()})),content:{metrics:c}})}if(!ht(t))throw new Error(`customSource("${e}") needs a data schema: customSource(namespace, { data: z.object({ ... }) }) describes each record's data`);return A.parse({kind:"custom",namespace:e,...s,data:$(t)})}function ht(e){return typeof e=="object"&&e!==null&&"_zod"in e}function Cr(e){return b("tracker",he.parse(e))}function Gt(e={}){return H.parse({kind:"discord-messages",...e.text?{text:!0}:{}})}function _t(){return J.parse({kind:"discord-reactions"})}var xr={provider:"discord",grantRole:e=>te.parse({kind:"integration",provider:"discord",action:"grant-role",roleId:e}),messages:Gt,reactions:_t,roles(e={}){return T.parse({provider:"discord",resource:"role",assignable:e.assignable??!1})},channels(e={}){return T.parse({provider:"discord",resource:"channel",types:e.types??["text","announcement"]})}},Mr={messages(){return j(se,{identities:["member"],data:at})},reactions(){return j(oe,{identities:["member"],accounts:["messageAuthor"],data:rt})}},$r={shorts(){return j(ce,{identities:["member"],content:{body:Je,metrics:Xe}})}},zr={videos(){return j(ie,{identities:["member"],content:{body:Ye,metrics:et}})}};function Ht(e){let{chain:r,token:t}=e,a=t===void 0?null:t;if(a!==null&&typeof a!="string")throw new Error("wallet.balances() takes the token as a string");if(r==="solana"||r===N){if(a!==null&&!xe.safeParse(a).success)throw new Error("wallet.balances() on Solana takes an SPL or Token-2022 mint address (base58)");return{chain:N,token:a}}if(typeof r=="string"&&$e(r)){if(a!==null&&!/^0x[0-9a-fA-F]{40}$/.test(a))throw new Error("wallet.balances() on an EVM chain takes an ERC-20 contract address: 0x and 40 hex digits");return{chain:r,token:a}}if(typeof r=="string"&&/^cosmos:[-_a-zA-Z0-9]{1,32}$/.test(r)){if(a===null||!Me.safeParse(a).success)throw new Error("wallet.balances() on a Cosmos chain takes a bank denomination such as uatom");return{chain:r,token:a}}throw new Error('wallet.balances() reads "solana", an EVM chain such as "eip155:8453" or a Cosmos network such as "cosmos:cosmoshub-4"')}var jr={balances(e){let r=Ht(e),t=j(de,{identities:["wallet"],data:ze});return A.parse({...t,balance:r})}},Lr=()=>({provider:"domino",resource:"point-ledger"});function g(e,r){return r}var Rr={pointLedger(e){let r={...e,kind:"point-ledger",default:e.default?R.parse(e.default.key):""};return g("point-ledger",Ke.prefault(r.default).meta(r))},datetime(e){let r={...e,kind:"datetime",default:U.parse(e.default)};return g("datetime",U.default(r.default).meta(r))},resource(e){let r={...e,source:T.parse(e.source),kind:"resource",default:V.parse(e.default??"")};return g("resource",V.default(r.default).meta(r))},quiz(e){let r=K.parse(e.default);return g("quiz",K.default(r).meta({...e,default:r,kind:"quiz"}))},text(e){let r={...e,kind:"text",minLength:e.minLength??1,maxLength:e.maxLength??2e3,multiline:e.multiline??!1};return g("text",D().min(r.minLength).max(r.maxLength).default(r.default).meta(r))},telegramChat(e){let r={...e,kind:"text",default:e.default??"",minLength:0,maxLength:64,multiline:!1,picker:"telegram-chat"};return g("text",D().max(r.maxLength).default(r.default).meta(r))},amount(e){if(!Ie(e.default))throw new Error(`settings.amount() takes a base-unit integer string as its default, not "${e.default}"`);let r={...e,kind:"text",minLength:1,maxLength:100,multiline:!1,picker:"amount"};return g("text",S(r).default(r.default).meta(r))},chain(e){if(!Be(e.default))throw new Error(`settings.chain() takes "solana" or an EVM chain ID such as "eip155:8453" as its default, not "${e.default}"`);let r={...e,kind:"text",minLength:1,maxLength:64,multiline:!1,picker:"chain"};return g("text",S(r).transform(t=>t).default(r.default).meta(r))},nft(e){if(!je(e.default))throw new Error(`settings.nft() takes an NFT collection such as "eip155:1/erc721:0x\u2026" as its default, not "${e.default}"`);let r={...e,kind:"text",minLength:1,maxLength:200,multiline:!1,picker:"nft"};return g("text",S(r).transform(t=>t).default(r.default).meta(r))},contractCall(e){if(!Le(e.default))throw new Error(`settings.contractCall() takes a contract call such as "eip155:8453:0x\u2026 function stakedOf(address) view returns (uint256)" as its default, not "${e.default}"`);let r={...e,kind:"text",minLength:1,maxLength:400,multiline:!1,picker:"contract-call"};return g("text",S(r).transform(t=>t).default(r.default).meta(r))},contractEvent(e){if(!Re(e.default))throw new Error(`settings.contractEvent() takes a contract event such as "eip155:1:0x\u2026 Transfer(address indexed from, address indexed to, uint256 value)" as its default, not "${e.default}"`);let r={...e,kind:"text",minLength:1,maxLength:1e3,multiline:!1,picker:"contract-event"};return g("text",S(r).transform(t=>t).default(r.default).meta(r))},solanaProgram(e){if(!Ae(e.default))throw new Error(`settings.solanaProgram() takes a Solana program address such as "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4" as its default, not "${e.default}"`);let r={...e,kind:"text",minLength:32,maxLength:44,multiline:!1,picker:"solana-program"};return g("text",S(r).transform(t=>t).default(r.default).meta(r))},integer(e){return g("integer",x().int().min(e.min).max(e.max).default(e.default).meta({...e,kind:"integer"}))},boolean(e){return g("boolean",G().default(e.default).meta({...e,kind:"boolean"}))},choice(e){return g("choice",M(e.options).default(e.default).meta({...e,kind:"choice"}))},object(e){return P(e).strict()}};function pt(e,r){let t=e.balanceChanges.find(a=>a.mint===r);return t?BigInt(t.delta):0n}function Tr(e,r){let t=pt(e,r);return t>0n?t.toString():"0"}function Dr(e,r){let t=pt(e,r);return t<0n?(-t).toString():"0"}function Pr(e,r={}){let t=e.balanceChanges.filter(s=>BigInt(s.delta)>0n),a=e.balanceChanges.filter(s=>BigInt(s.delta)<0n);return t.some(s=>(r.into===void 0||s.mint===r.into)&&a.some(c=>c.mint!==s.mint&&(r.from===void 0||c.mint===r.from)))}function Ir(e,r){return e.programs.includes(r)}function Br(e,r){return e.instructions?.find(t=>t.name===r)?.args??null}var Or=e=>Qe(e.key,e.name),Nr=e=>We(e.key,e.title),Kr=(e,r)=>Ue.parse({kind:"points",balance:q(e),amount:r}),Ur={text:(e={})=>({input:"text",constraints:Te.parse(e)}),url:(e={})=>({input:"url",constraints:De.parse(e)}),photo:()=>"photo",quiz:()=>"quiz"};function Vr(e){if(e?.actor&&e.input!==void 0)throw new Error('manual() cannot combine actor "staff" with input: staff-captured evidence is not supported. Use manual({ actor: "staff" }) for a staff confirmation, or manual({ input }) for evidence the participant submits.');return typeof e?.input=="object"?{kind:"manual",...e.input}:{kind:"manual",input:e?.input??"none",...e?.actor?{actor:e.actor}:{}}}var kt=new WeakMap,wt=new WeakMap;function vt(e,r){let{tracker:t,beneficiary:a="author",on:s,where:c,enrollment:i,since:d,historical:n,content:f}=e;if(!t?.source)throw new Error(r==="automatic"?"automatic() takes no argument, or { tracker } with a tracker handle from defineTracker":"content() takes { tracker } with a tracker handle from defineTracker");let{source:p}=t;if(!fe(p))throw new Error('Tracker triggers need attributable records: declare customSource(namespace, { identities: ["wallet"] }) or other identity kinds');if(f&&!I(p))throw new Error(`content() needs a tracker whose source has content: x.search(), or customSource(namespace, { content: { body, metrics } }). Tracker "${t.key}" has none; use automatic({ tracker }) instead.`);if(d==="enrollment"&&i!=="required")throw new Error(`${r}() counts from enrollment only on a quest that requires it: add enrollment: "required"`);let o=mt(p);if(!o.includes(a))throw new Error(p.kind==="custom"?`Tracker "${t.key}" has no "${a}" account: declare it in customSource(namespace, { accounts: ["${a}"] })`:`Tracker "${t.key}" pays ${o.map(m=>`"${m}"`).join(" or ")}, not "${a}"`);let u=ye.parse({tracker:t.key,source:p.kind,on:f?"new-record":s??ve(p.kind),...c?{where:c}:{},beneficiary:a,...i==="required"?{enrollment:i}:{},...d&&d!=="activation"?{since:d}:{},...n&&n!==(f?"claim":"staff")?{historical:n}:{},...f?{content:f}:{}}),l=ft(p),v=l?ne(l,u.where):null;if(v)throw new Error(v);let w={kind:"automatic",tracker:u};l&&kt.set(w,l);let h=I(p);return h&&wt.set(w,h.metrics),w}function Zr(e){return e?vt(e,"automatic"):{kind:"automatic"}}function Qr(e){if(e&&typeof e=="object"&&"source"in e&&"key"in e&&!("tracker"in e))throw new Error("content() takes { tracker }: write content({ tracker: posts }) instead of content(posts)");return vt({...e,content:!0},"content")}var Wr=e=>{let{key:r,cost:t,...a}=e;return qe.parse({...a,id:E(e),cost:typeof t=="number"?t:{balance:q(t.ledger)}})},Jt=e=>({kind:"keyed",key:e}),Xt=e=>{let{distinct:r,...t}=e;return{...ke.parse({kind:"progress",window:{kind:"lifetime"},...t}),distinct:r}},Fr=()=>({kind:"untracked"}),Gr=()=>({kind:"staff-handover"}),_r=()=>({kind:"automatic"});function Hr(e){let{key:r,tiers:t,...a}=e,s=E(e),c=Ve.parse({id:s,...a,tiers:t.map(({key:i,...d})=>({...d,id:E({key:i,...d})}))});return b("tiered-reward",{key:c.id,tier:i=>Ze.parse({kind:"tier",reward:c,tier:i})})}var Yt=()=>({kind:"once"});function er(e={}){return{kind:"accept",...e}}function tr(e){return{kind:"review",...e}}var C={accept:er,defer:e=>({kind:"defer",...e}),progress:e=>({kind:"progress",...e}),reject:e=>({kind:"reject",...e}),review:tr};function gt(e){let r=e.kind==="reject"&&e.code!==void 0?Ee(e.code):null;if(r)throw new Error(r)}var Jr={quiz(e,r={}){let t=_e.parse(e),a=Object.keys(t),s=x().int().min(1).max(a.length).parse(r.minimumCorrect??a.length);return async({input:c})=>{let i=Object.keys(c.answers).length===a.length&&a.every(n=>Object.hasOwn(c.answers,n)),d=a.filter(n=>c.answers[n]===t[n]).length;return i&&d>=s?C.accept():C.reject({reason:"Review your answers and try again."})}},photo(e){return async r=>{let t=e(r),a=await r.review.photo({image:r.input.photo,criteria:t.criteria});return a.kind==="unclear"?t.unclear==="human-review"?C.review({reason:a.reason}):C.reject({reason:a.reason}):a.kind==="pass"?C.accept():C.reject({reason:a.reason})}}},rr={once:Yt,keyed:Jt,streak:Ft,progress:Xt};function bt(e){return function(t){let a=E(t),s=[...new Set((t.integrations??[]).map(o=>Ce.parse(o.provider)))],c=t.trigger.kind==="automatic"&&t.trigger.tracker?.content===!0,i=t.trigger.kind==="automatic"&&t.trigger.tracker!==void 0,d=t.completion,n=typeof d=="function"?d(rr):d;if(c&&n!==void 0)throw new Error("A content quest completes once per content item: remove its completion");if(!c&&n===void 0)throw new Error("A quest needs a completion, such as once(), keyed(...), streak(...) or progress(...)");if(lt({trigger:t.trigger,completion:n??{kind:"keyed"},requires:t.requires??[],performance:t.performance?B.parse({metrics:t.performance.metrics,maxAgeMs:t.performance.maxAgeMs}):void 0,...t.retryCooldownMs===void 0?{}:{retryCooldownMs:t.retryCooldownMs},...t.completionCooldownMs===void 0?{}:{completionCooldownMs:t.completionCooldownMs}},{template:e}),t.retryCooldownMs!==void 0&&!Z.safeParse(t.retryCooldownMs).success)throw new Error("retryCooldownMs must be whole milliseconds from 1000 (one second) to 604800000 (seven days)");if(t.completionCooldownMs!==void 0&&!Z.safeParse(t.completionCooldownMs).success)throw new Error("completionCooldownMs must be whole milliseconds from 1000 (one second) to 604800000 (seven days)");if(t.performance){let o=wt.get(t.trigger)??[],u=t.performance.metrics.filter(l=>!o.includes(l));if(u.length)throw new Error(`The tracker's source does not measure ${u.join(", ")}`)}if(t.trigger.kind==="manual"&&t.trigger.input!=="none"&&!t.evaluate)throw new Error("Evidence quests require an evaluator");let f=Object.fromEntries(Object.entries(t.settings.shape).map(([o,u])=>{let l=Pe.safeParse(u.meta());if(!l.success)throw new Error(`Setting "${o}" is not a quest setting: build it with a settings builder, such as settings.integer({ label, default, min, max })`);return[o,l.data]}));for(let o of be(t.trigger.kind==="automatic"?t.trigger.tracker?.where:void 0))if(!Oe(f[o]))throw new Error(`The tracker filter compares with setting "${o}", which is not an integer or amount setting`);function p(o){let u=t.settings.parse(o),l=Ne(f,u),v=Fe.parse(typeof t.rewards=="function"?t.rewards({settings:u}):t.rewards),w=[...v.flatMap(h=>h.kind==="integration"?[h.provider]:[]),...Object.values(f).flatMap(h=>h.kind==="resource"&&h.source.provider!=="domino"?[h.source.provider]:[])];for(let h of w)if(!s.includes(h))throw new Error(`Declare the ${h} integration on this quest`);return Ge.parse({quest:a,evaluatorProtocol:Q,title:typeof t.title=="function"?t.title({settings:u}):t.title,presentation:t.presentation?.({settings:u})??{},fields:f,values:l,rewards:v,humanReview:t.review?.({settings:u})?.enabled??!0,trigger:t.trigger,...t.performance?{performance:B.parse({metrics:t.performance.metrics,maxAgeMs:t.performance.maxAgeMs})}:{},integrations:s,completion:n?n.kind==="progress"?{kind:n.kind,goal:n.goal,window:n.window,repeat:n.repeat}:n.kind==="streak"?n:{kind:n.kind}:{kind:"keyed"},visibility:t.visibility??"visible",profile:t.profile??{visible:!1},budgets:t.budgets??[],requires:t.requires??[],...t.campaign?{campaign:t.campaign}:{},...t.availability?{availability:t.availability}:{},...t.retryCooldownMs===void 0?{}:{retryCooldownMs:t.retryCooldownMs},...t.completionCooldownMs===void 0?{}:{completionCooldownMs:t.completionCooldownMs}})}return b("quest",{protocol:Q,key:a,describe:p,async evaluate(o){let u=t.settings.parse(o.settings),l=i?Se.parse(o.tracker):null,v=kt.get(t.trigger),w=l&&v?re(v,l.record.data):null;if(w)return z.parse({kind:"reject",reason:`The record's data does not match the data schema this quest was built with: ${w.path} ${w.reason}`});let h=l;if(o.performance){if(!t.performance)throw new Error("Quest has no performance evaluator");let y=He.parse(o.performance),yt=L(M(t.performance.metrics),x().int().safe().nonnegative()).parse(y.metrics),k=await t.performance.evaluate({settings:u,member:o.member,tracker:h,metrics:yt,observedAt:y.observedAt});if(!k)throw new Error("Performance evaluator returned no decision");if(k.rewards!==void 0)throw new Error("A performance evaluator cannot select rewards. It gates the rewards content evaluation selected: return accept, review or reject with a reason only.");return gt(k),z.parse(k.kind==="accept"?{kind:"accept",rewards:y.rewards}:k.kind==="review"&&o.humanReview?{kind:"review",reason:k.reason,rewards:y.rewards}:{kind:"reject",reason:k.reason,...k.kind==="review"?{requestedReview:!0}:k.code===void 0?{}:{code:k.code}})}let m=t.evaluate?await t.evaluate({settings:u,member:o.member,input:o.input,tracker:h,eligibleAt:o.eligibleAt,calendar:o.calendar,now:o.now,review:o.review,trackers:ae(o.trackers),wallet:o.wallet,images:o.images,...o.telegram?{telegram:o.telegram}:{},...Object.fromEntries(s.map(y=>[y,o[y]]))}):C.accept();if(!m)throw new Error("Evaluator returned no decision");if(gt(m),m.kind==="review"&&!o.humanReview)return z.parse({kind:"reject",reason:m.reason,requestedReview:!0});(m.kind==="accept"||m.kind==="review")&&m.completionKey!==void 0&&n?.kind!=="keyed"&&o.diagnose?.({code:"completion-key-ignored",message:ar(n,m.completionKey)});let F={...o,settings:u,tracker:l};return z.parse(m.kind==="accept"||m.kind==="review"?{...m,rewards:m.rewards??o.rewards,...n?.kind==="keyed"||n?.kind==="progress"?{completionKey:n.kind==="progress"?n.distinct(F):m.completionKey??n.key(F)}:{}}:m)}})}}function ar(e,r){let t=`ignores completionKey ${JSON.stringify(r)}`;switch(e?.kind){case void 0:return`A content quest completes once per content item, under a key Relay sets, so it ${t}`;case"once":return`once() completes the quest once per member and ${t}: use keyed(...) to complete it once per key`;case"streak":return`streak(...) keys its own completions and ${t}`;case"progress":return`progress(...) keys each contribution with its distinct(...) and ${t}: derive the key in distinct(...)`}}var Xr=bt(!1),Yr=bt(!0);export{Ot as CapabilityError,Zr as automatic,_r as automaticFulfillment,Or as badge,Dt as balanceAtLeast,Wr as budget,wr as calendar,Bt as capabilityErrorCodes,Tt as completed,Qr as content,Me as cosmosDenomSchema,Et as cosmosNetworkSchema,kr as count,j as customSource,C as decision,hr as defineBadge,Rt as defineCampaign,It as defineDashboard,pr as defineEngagementReward,At as defineGroup,Er as defineLeaderboard,gr as defineLedger,Nt as defineOffer,Xr as defineQuest,Yr as defineQuestType,yr as defineReferral,Hr as defineTieredReward,Cr as defineTracker,xr as discord,Sr as earned,Jr as evaluators,Ur as evidence,Ut as formatUnits,Nr as groupMembership,Pt as inGroup,Br as instruction,Ir as invoked,Le as isContractCall,Re as isContractEvent,$e as isEvmChainId,je as isNftCollection,Ae as isSolanaProgram,Jt as keyed,Vr as manual,$t as maxWalletEventLogs,zt as maxWalletEventLookback,Lt as maxWalletTransactionLookback,jt as maxWalletTransactions,Yt as once,xt as parseContractCall,Mt as parseContractEvent,Ct as parseContractFunction,qt as parseNftCollection,Kt as parseUnits,Lr as pointLedgers,Kr as points,Xt as progress,br as questCompleted,Tr as received,vr as rolling,Rr as settings,Dr as spent,Gr as staffHandover,Ft as streak,Pr as swapped,Mr as telegram,zr as tiktok,$ as trackerDataSchema,Se as trackerTriggerContextSchema,Fr as untracked,jr as wallet,qr as x,$r as youtube,St as z};
|