@proofchain/sdk 2.3.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -196,6 +196,50 @@ const webhooks = await client.webhooks.list();
196
196
  await client.webhooks.delete(webhook.id);
197
197
  ```
198
198
 
199
+ ### Quests
200
+
201
+ Quests are gamified user journeys with steps that can be completed via events.
202
+
203
+ ```typescript
204
+ // List available quests for a user (with their progress)
205
+ const quests = await client.quests.listAvailable(userId);
206
+ // Returns: { quest: Quest, progress?: UserQuestProgress }[]
207
+
208
+ // Each quest has a type that determines behavior:
209
+ // - 'epic': Long-form quests - user must explicitly start
210
+ // - 'quick_hit': Short quests - auto-enrolls on matching event
211
+ // - 'challenge': Time-limited quests - auto-enrolls on matching event
212
+
213
+ for (const { quest, progress } of quests) {
214
+ console.log(`${quest.name} (${quest.quest_type})`);
215
+ if (progress) {
216
+ console.log(` Progress: ${progress.completion_percentage}%`);
217
+ }
218
+ }
219
+
220
+ // Start an Epic quest (required for epic type only)
221
+ const progress = await client.quests.startQuest(questId, userId);
222
+
223
+ // Get user's progress on a specific quest
224
+ const questProgress = await client.quests.getUserProgress(questId, userId);
225
+
226
+ // Get all quest progress for a user
227
+ const allProgress = await client.quests.getAllUserProgress(userId);
228
+
229
+ // Complete a step manually (for manual step types)
230
+ const result = await client.quests.completeStep(questId, userId, stepIndex);
231
+ console.log('Step completed:', result.step_completed);
232
+ console.log('Quest completed:', result.quest_completed);
233
+ ```
234
+
235
+ **Quest Types:**
236
+
237
+ | Type | Behavior |
238
+ |------|----------|
239
+ | `epic` | Long-form, multi-step quests. User must call `startQuest()` to begin. |
240
+ | `quick_hit` | Short, easy quests. Auto-enrolls when user triggers a matching event. |
241
+ | `challenge` | Time-limited or competitive. Auto-enrolls when user triggers a matching event. |
242
+
199
243
  ## Error Handling
200
244
 
201
245
  ```typescript
package/dist/index.d.mts CHANGED
@@ -1816,6 +1816,7 @@ interface Quest {
1816
1816
  category?: string;
1817
1817
  difficulty?: string;
1818
1818
  estimated_time?: string;
1819
+ quest_type?: 'epic' | 'quick_hit' | 'challenge';
1819
1820
  is_ordered: boolean;
1820
1821
  is_repeatable: boolean;
1821
1822
  repeat_cooldown_hours?: number;
@@ -1896,8 +1897,9 @@ interface StepCompletionResult {
1896
1897
  target_count: number;
1897
1898
  points_earned: number;
1898
1899
  }
1899
- interface QuestWithProgress extends Quest {
1900
- user_progress?: UserQuestProgress;
1900
+ interface QuestWithProgress {
1901
+ quest: Quest;
1902
+ progress?: UserQuestProgress;
1901
1903
  }
1902
1904
  interface CreateQuestRequest {
1903
1905
  name: string;
@@ -1999,10 +2001,12 @@ declare class QuestsClient {
1999
2001
  archive(questId: string): Promise<Quest>;
2000
2002
  /**
2001
2003
  * Get quest with user progress
2004
+ * Fetches the quest and user's progress separately and combines them
2002
2005
  */
2003
2006
  getWithProgress(questId: string, userId: string): Promise<QuestWithProgress>;
2004
2007
  /**
2005
2008
  * List quests with progress for a user
2009
+ * @deprecated Use listAvailable() instead - this is an alias
2006
2010
  */
2007
2011
  listWithProgress(userId: string, options?: ListQuestsOptions): Promise<QuestWithProgress[]>;
2008
2012
  /**
@@ -2451,6 +2455,157 @@ declare class DataViewsClient {
2451
2455
  getTemplates(): Promise<ViewTemplate[]>;
2452
2456
  }
2453
2457
 
2458
+ /**
2459
+ * Cohort Leaderboard API Client
2460
+ *
2461
+ * Manage cohort definitions, scoring, and filtered leaderboards with percentiles.
2462
+ */
2463
+
2464
+ interface CohortLeaderboardEntry {
2465
+ rank: number;
2466
+ user_id: string;
2467
+ score: number;
2468
+ percentile_global: number;
2469
+ percentile_filtered: number | null;
2470
+ computed_at?: string;
2471
+ }
2472
+ interface CohortGroupStats {
2473
+ filtered_avg_percentile: number | null;
2474
+ filtered_top_n_avg_percentile: number | null;
2475
+ global_count: number;
2476
+ global_avg_percentile: number;
2477
+ }
2478
+ interface CohortLeaderboardResponse {
2479
+ cohort_id: string;
2480
+ cohort_name: string;
2481
+ filter: Record<string, unknown>;
2482
+ total_users: number;
2483
+ group_stats: CohortGroupStats;
2484
+ leaderboard: CohortLeaderboardEntry[];
2485
+ }
2486
+ interface CohortDefinition {
2487
+ id: string;
2488
+ tenant_id: string;
2489
+ name: string;
2490
+ slug: string;
2491
+ description?: string;
2492
+ scoring_type: string;
2493
+ icon?: string;
2494
+ color?: string;
2495
+ status: 'active' | 'inactive' | 'draft';
2496
+ avg_score?: number;
2497
+ total_users?: number;
2498
+ created_at: string;
2499
+ updated_at: string;
2500
+ }
2501
+ interface UserCohortBreakdownEntry {
2502
+ cohort_id: string;
2503
+ cohort_slug: string;
2504
+ cohort_name: string;
2505
+ icon?: string;
2506
+ color?: string;
2507
+ user_percentile: number;
2508
+ filtered_group_avg_percentile: number | null;
2509
+ global_group_avg_percentile: number;
2510
+ }
2511
+ interface UserBreakdownResponse {
2512
+ user_id: string;
2513
+ filter: Record<string, unknown>;
2514
+ cohorts: UserCohortBreakdownEntry[];
2515
+ }
2516
+ interface CohortLeaderboardOptions {
2517
+ filters?: Record<string, string>;
2518
+ country?: string;
2519
+ limit?: number;
2520
+ top_n?: number;
2521
+ fresh?: boolean;
2522
+ }
2523
+ interface ListCohortsOptions {
2524
+ status?: 'active' | 'inactive' | 'draft';
2525
+ limit?: number;
2526
+ offset?: number;
2527
+ }
2528
+ declare class CohortLeaderboardClient {
2529
+ private http;
2530
+ constructor(http: HttpClient);
2531
+ /**
2532
+ * List all cohort definitions
2533
+ */
2534
+ list(options?: ListCohortsOptions): Promise<CohortDefinition[]>;
2535
+ /**
2536
+ * Get a cohort definition by ID
2537
+ */
2538
+ get(cohortId: string): Promise<CohortDefinition>;
2539
+ /**
2540
+ * Get filtered cohort leaderboard with both global and filtered percentiles
2541
+ */
2542
+ getLeaderboard(cohortId: string, options?: CohortLeaderboardOptions): Promise<CohortLeaderboardResponse>;
2543
+ /**
2544
+ * Get user's breakdown across all cohorts for spider charts
2545
+ */
2546
+ getUserBreakdown(userId: string, options?: {
2547
+ filters?: Record<string, string>;
2548
+ country?: string;
2549
+ }): Promise<UserBreakdownResponse>;
2550
+ }
2551
+
2552
+ /**
2553
+ * Fanpass Leaderboard API Client
2554
+ *
2555
+ * Manage fanpass composite scores and filtered leaderboards.
2556
+ */
2557
+
2558
+ interface FanpassLeaderboardEntry {
2559
+ rank: number;
2560
+ user_id: string;
2561
+ fan_score: number;
2562
+ raw_score: number;
2563
+ percentile: number;
2564
+ computed_at?: string;
2565
+ }
2566
+ interface FanpassGroupStats {
2567
+ avg_fan_score: number;
2568
+ top_n_avg_fan_score: number;
2569
+ global_count: number;
2570
+ global_avg_fan_score: number;
2571
+ }
2572
+ interface FanpassLeaderboardResponse {
2573
+ aggregation_rule_id: string | null;
2574
+ aggregation_rule_name: string | null;
2575
+ filter: Record<string, unknown>;
2576
+ total_users: number;
2577
+ group_stats: FanpassGroupStats;
2578
+ leaderboard: FanpassLeaderboardEntry[];
2579
+ }
2580
+ interface FanpassUserComparisonResponse {
2581
+ user_id: string;
2582
+ filter: Record<string, unknown>;
2583
+ cohorts: UserCohortBreakdownEntry[];
2584
+ }
2585
+ interface FanpassLeaderboardOptions {
2586
+ aggregationRuleId?: string;
2587
+ filters?: Record<string, string>;
2588
+ country?: string;
2589
+ limit?: number;
2590
+ top_n?: number;
2591
+ fresh?: boolean;
2592
+ }
2593
+ declare class FanpassLeaderboardClient {
2594
+ private http;
2595
+ constructor(http: HttpClient);
2596
+ /**
2597
+ * Get fanpass leaderboard with composite scores
2598
+ */
2599
+ getLeaderboard(options?: FanpassLeaderboardOptions): Promise<FanpassLeaderboardResponse>;
2600
+ /**
2601
+ * Get user's comparison across all cohorts (spider chart data)
2602
+ */
2603
+ getUserComparison(userId: string, options?: {
2604
+ filters?: Record<string, string>;
2605
+ country?: string;
2606
+ }): Promise<FanpassUserComparisonResponse>;
2607
+ }
2608
+
2454
2609
  /**
2455
2610
  * ProofChain Client
2456
2611
  */
@@ -2641,6 +2796,10 @@ declare class ProofChain {
2641
2796
  schemas: SchemasClient;
2642
2797
  /** Data Views client for custom data view operations */
2643
2798
  dataViews: DataViewsClient;
2799
+ /** Cohort leaderboard client for filtered leaderboards and percentiles */
2800
+ cohorts: CohortLeaderboardClient;
2801
+ /** Fanpass leaderboard client for composite score leaderboards */
2802
+ fanpassLeaderboard: FanpassLeaderboardClient;
2644
2803
  constructor(options: ProofChainOptions);
2645
2804
  /**
2646
2805
  * Create a client from environment variables.
@@ -2784,4 +2943,4 @@ declare class TimeoutError extends ProofChainError {
2784
2943
  constructor(message?: string);
2785
2944
  }
2786
2945
 
2787
- export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FieldValue, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LinkWalletRequest, type ListCertificatesRequest, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RewardAsset, type RewardDefinition, type RewardEarned, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type Settlement, type StepCompletionResult, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserQuestProgress, type UserWalletSummary, type UserWithWallets, type UsersWithWalletsResponse, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletStats, type Webhook, WebhooksResource };
2946
+ export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type CohortDefinition, type CohortGroupStats, CohortLeaderboardClient, type CohortLeaderboardEntry, type CohortLeaderboardOptions, type CohortLeaderboardResponse, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FanpassGroupStats, FanpassLeaderboardClient, type FanpassLeaderboardEntry, type FanpassLeaderboardOptions, type FanpassLeaderboardResponse, type FanpassUserComparisonResponse, type FieldValue, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LinkWalletRequest, type ListCertificatesRequest, type ListCohortsOptions, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RewardAsset, type RewardDefinition, type RewardEarned, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type Settlement, type StepCompletionResult, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserBreakdownResponse, type UserCohortBreakdownEntry, type UserQuestProgress, type UserWalletSummary, type UserWithWallets, type UsersWithWalletsResponse, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletStats, type Webhook, WebhooksResource };
package/dist/index.d.ts CHANGED
@@ -1816,6 +1816,7 @@ interface Quest {
1816
1816
  category?: string;
1817
1817
  difficulty?: string;
1818
1818
  estimated_time?: string;
1819
+ quest_type?: 'epic' | 'quick_hit' | 'challenge';
1819
1820
  is_ordered: boolean;
1820
1821
  is_repeatable: boolean;
1821
1822
  repeat_cooldown_hours?: number;
@@ -1896,8 +1897,9 @@ interface StepCompletionResult {
1896
1897
  target_count: number;
1897
1898
  points_earned: number;
1898
1899
  }
1899
- interface QuestWithProgress extends Quest {
1900
- user_progress?: UserQuestProgress;
1900
+ interface QuestWithProgress {
1901
+ quest: Quest;
1902
+ progress?: UserQuestProgress;
1901
1903
  }
1902
1904
  interface CreateQuestRequest {
1903
1905
  name: string;
@@ -1999,10 +2001,12 @@ declare class QuestsClient {
1999
2001
  archive(questId: string): Promise<Quest>;
2000
2002
  /**
2001
2003
  * Get quest with user progress
2004
+ * Fetches the quest and user's progress separately and combines them
2002
2005
  */
2003
2006
  getWithProgress(questId: string, userId: string): Promise<QuestWithProgress>;
2004
2007
  /**
2005
2008
  * List quests with progress for a user
2009
+ * @deprecated Use listAvailable() instead - this is an alias
2006
2010
  */
2007
2011
  listWithProgress(userId: string, options?: ListQuestsOptions): Promise<QuestWithProgress[]>;
2008
2012
  /**
@@ -2451,6 +2455,157 @@ declare class DataViewsClient {
2451
2455
  getTemplates(): Promise<ViewTemplate[]>;
2452
2456
  }
2453
2457
 
2458
+ /**
2459
+ * Cohort Leaderboard API Client
2460
+ *
2461
+ * Manage cohort definitions, scoring, and filtered leaderboards with percentiles.
2462
+ */
2463
+
2464
+ interface CohortLeaderboardEntry {
2465
+ rank: number;
2466
+ user_id: string;
2467
+ score: number;
2468
+ percentile_global: number;
2469
+ percentile_filtered: number | null;
2470
+ computed_at?: string;
2471
+ }
2472
+ interface CohortGroupStats {
2473
+ filtered_avg_percentile: number | null;
2474
+ filtered_top_n_avg_percentile: number | null;
2475
+ global_count: number;
2476
+ global_avg_percentile: number;
2477
+ }
2478
+ interface CohortLeaderboardResponse {
2479
+ cohort_id: string;
2480
+ cohort_name: string;
2481
+ filter: Record<string, unknown>;
2482
+ total_users: number;
2483
+ group_stats: CohortGroupStats;
2484
+ leaderboard: CohortLeaderboardEntry[];
2485
+ }
2486
+ interface CohortDefinition {
2487
+ id: string;
2488
+ tenant_id: string;
2489
+ name: string;
2490
+ slug: string;
2491
+ description?: string;
2492
+ scoring_type: string;
2493
+ icon?: string;
2494
+ color?: string;
2495
+ status: 'active' | 'inactive' | 'draft';
2496
+ avg_score?: number;
2497
+ total_users?: number;
2498
+ created_at: string;
2499
+ updated_at: string;
2500
+ }
2501
+ interface UserCohortBreakdownEntry {
2502
+ cohort_id: string;
2503
+ cohort_slug: string;
2504
+ cohort_name: string;
2505
+ icon?: string;
2506
+ color?: string;
2507
+ user_percentile: number;
2508
+ filtered_group_avg_percentile: number | null;
2509
+ global_group_avg_percentile: number;
2510
+ }
2511
+ interface UserBreakdownResponse {
2512
+ user_id: string;
2513
+ filter: Record<string, unknown>;
2514
+ cohorts: UserCohortBreakdownEntry[];
2515
+ }
2516
+ interface CohortLeaderboardOptions {
2517
+ filters?: Record<string, string>;
2518
+ country?: string;
2519
+ limit?: number;
2520
+ top_n?: number;
2521
+ fresh?: boolean;
2522
+ }
2523
+ interface ListCohortsOptions {
2524
+ status?: 'active' | 'inactive' | 'draft';
2525
+ limit?: number;
2526
+ offset?: number;
2527
+ }
2528
+ declare class CohortLeaderboardClient {
2529
+ private http;
2530
+ constructor(http: HttpClient);
2531
+ /**
2532
+ * List all cohort definitions
2533
+ */
2534
+ list(options?: ListCohortsOptions): Promise<CohortDefinition[]>;
2535
+ /**
2536
+ * Get a cohort definition by ID
2537
+ */
2538
+ get(cohortId: string): Promise<CohortDefinition>;
2539
+ /**
2540
+ * Get filtered cohort leaderboard with both global and filtered percentiles
2541
+ */
2542
+ getLeaderboard(cohortId: string, options?: CohortLeaderboardOptions): Promise<CohortLeaderboardResponse>;
2543
+ /**
2544
+ * Get user's breakdown across all cohorts for spider charts
2545
+ */
2546
+ getUserBreakdown(userId: string, options?: {
2547
+ filters?: Record<string, string>;
2548
+ country?: string;
2549
+ }): Promise<UserBreakdownResponse>;
2550
+ }
2551
+
2552
+ /**
2553
+ * Fanpass Leaderboard API Client
2554
+ *
2555
+ * Manage fanpass composite scores and filtered leaderboards.
2556
+ */
2557
+
2558
+ interface FanpassLeaderboardEntry {
2559
+ rank: number;
2560
+ user_id: string;
2561
+ fan_score: number;
2562
+ raw_score: number;
2563
+ percentile: number;
2564
+ computed_at?: string;
2565
+ }
2566
+ interface FanpassGroupStats {
2567
+ avg_fan_score: number;
2568
+ top_n_avg_fan_score: number;
2569
+ global_count: number;
2570
+ global_avg_fan_score: number;
2571
+ }
2572
+ interface FanpassLeaderboardResponse {
2573
+ aggregation_rule_id: string | null;
2574
+ aggregation_rule_name: string | null;
2575
+ filter: Record<string, unknown>;
2576
+ total_users: number;
2577
+ group_stats: FanpassGroupStats;
2578
+ leaderboard: FanpassLeaderboardEntry[];
2579
+ }
2580
+ interface FanpassUserComparisonResponse {
2581
+ user_id: string;
2582
+ filter: Record<string, unknown>;
2583
+ cohorts: UserCohortBreakdownEntry[];
2584
+ }
2585
+ interface FanpassLeaderboardOptions {
2586
+ aggregationRuleId?: string;
2587
+ filters?: Record<string, string>;
2588
+ country?: string;
2589
+ limit?: number;
2590
+ top_n?: number;
2591
+ fresh?: boolean;
2592
+ }
2593
+ declare class FanpassLeaderboardClient {
2594
+ private http;
2595
+ constructor(http: HttpClient);
2596
+ /**
2597
+ * Get fanpass leaderboard with composite scores
2598
+ */
2599
+ getLeaderboard(options?: FanpassLeaderboardOptions): Promise<FanpassLeaderboardResponse>;
2600
+ /**
2601
+ * Get user's comparison across all cohorts (spider chart data)
2602
+ */
2603
+ getUserComparison(userId: string, options?: {
2604
+ filters?: Record<string, string>;
2605
+ country?: string;
2606
+ }): Promise<FanpassUserComparisonResponse>;
2607
+ }
2608
+
2454
2609
  /**
2455
2610
  * ProofChain Client
2456
2611
  */
@@ -2641,6 +2796,10 @@ declare class ProofChain {
2641
2796
  schemas: SchemasClient;
2642
2797
  /** Data Views client for custom data view operations */
2643
2798
  dataViews: DataViewsClient;
2799
+ /** Cohort leaderboard client for filtered leaderboards and percentiles */
2800
+ cohorts: CohortLeaderboardClient;
2801
+ /** Fanpass leaderboard client for composite score leaderboards */
2802
+ fanpassLeaderboard: FanpassLeaderboardClient;
2644
2803
  constructor(options: ProofChainOptions);
2645
2804
  /**
2646
2805
  * Create a client from environment variables.
@@ -2784,4 +2943,4 @@ declare class TimeoutError extends ProofChainError {
2784
2943
  constructor(message?: string);
2785
2944
  }
2786
2945
 
2787
- export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FieldValue, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LinkWalletRequest, type ListCertificatesRequest, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RewardAsset, type RewardDefinition, type RewardEarned, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type Settlement, type StepCompletionResult, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserQuestProgress, type UserWalletSummary, type UserWithWallets, type UsersWithWalletsResponse, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletStats, type Webhook, WebhooksResource };
2946
+ export { type Achievement, type ActivitySummaryView, type AddNFTRequest, type ApiKey, type AttestRequest, type AttestationMode, type AttestationResult, AuthenticationError, AuthorizationError, type AvailableView, type Badge, type BatchIngestRequest, type BatchIngestResponse, type BatchVerifyResult, type BlockchainProof, type BlockchainStats, type Certificate, type CertificateVerifyResult, CertificatesResource, type Channel, type ChannelState, type ChannelStatus, ChannelsResource, type CohortDefinition, type CohortGroupStats, CohortLeaderboardClient, type CohortLeaderboardEntry, type CohortLeaderboardOptions, type CohortLeaderboardResponse, type ComprehensiveWalletInfo, type CreateAchievementRequest, type CreateApiKeyRequest, type CreateBadgeRequest, type CreateChannelRequest, type CreateDataViewRequest, type CreateDualWalletsRequest, type CreateEndUserRequest, type CreateEventRequest, type CreatePassportDefinitionRequest, type CreatePassportRequest, type CreateQuestRequest, type CreateQuestStepRequest, type CreateRewardDefinitionRequest, type CreateSchemaRequest, type CreateTemplateFieldRequest, type CreateTemplateRequest, type CreateWalletRequest, type CreateWebhookRequest, type DataViewColumn, type DataViewComputation, type DataViewDetail, type DataViewExecuteResult, type DataViewInfo, type DataViewListResponse, type DataViewPreviewRequest, type DataViewPreviewResult, type DataViewSummary, DataViewsClient, DocumentsResource, type DualWallets, type EarnedReward, type EndUser, type EndUserListResponse, EndUsersClient, type Event, type EventBatchProof, type EventMetadata, type EventStatus, EventsResource, type ExecuteSwapRequest, type Facet, type FacetsResponse, type FanProfileView, type FanpassGroupStats, FanpassLeaderboardClient, type FanpassLeaderboardEntry, type FanpassLeaderboardOptions, type FanpassLeaderboardResponse, type FanpassUserComparisonResponse, type FieldValue, type IngestEventRequest, type IngestEventResponse, IngestionClient, type IngestionClientOptions, type IssueCertificateRequest, type LinkWalletRequest, type ListCertificatesRequest, type ListCohortsOptions, type ListEndUsersOptions, type ListEventsRequest, type ListQuestsOptions, type ListRewardsOptions, type ListSchemasOptions, type ManualRewardRequest, type MergeUsersRequest, type Milestone, type NFT, NetworkError, NotFoundError, type Passport, PassportClient, type PassportDefinition, type PassportFieldValue, type PassportHistory, type PassportTemplate, type PassportV2Data, type PassportWithFields, ProofChain, ProofChainError, type ProofChainOptions, type ProofVerifyResult, type Quest, type QuestStep, type QuestWithProgress, QuestsClient, RateLimitError, type RewardAsset, type RewardDefinition, type RewardEarned, RewardsClient, type Schema, type SchemaDetail, type SchemaField, type SchemaListResponse, type ValidationError$1 as SchemaValidationError, SchemasClient, type SearchFilters, type SearchQueryRequest, type SearchRequest, SearchResource, type SearchResponse, type SearchResult, type SearchStats, ServerError, type Settlement, type StepCompletionResult, type StepProgress, type StreamAck, type StreamEventRequest, type SwapQuote, type SwapQuoteRequest, type SwapResult, type TemplateField, type TenantInfo, TenantResource, type TierDefinition, TimeoutError, type TokenBalance, type TransferRequest, type TransferResult, type UpdateDataViewRequest, type UpdateEndUserRequest, type UpdatePassportRequest, type UpdateWebhookRequest, type UsageStats, type UserAchievement, type UserActivity, type UserActivityResponse, type UserBadge, type UserBreakdownResponse, type UserCohortBreakdownEntry, type UserQuestProgress, type UserWalletSummary, type UserWithWallets, type UsersWithWalletsResponse, type ValidateDataRequest, ValidationError, type ValidationErrorDetail, type ValidationResult, type VaultFile, type VaultFolder, type VaultListResponse, VaultResource, type VaultStats, type VaultUploadRequest, type VerificationResult, VerifyResource, type ViewColumn, type ViewTemplate, type Wallet, type WalletBalance, WalletClient, type WalletStats, type Webhook, WebhooksResource };
package/dist/index.js CHANGED
@@ -24,10 +24,12 @@ __export(index_exports, {
24
24
  AuthorizationError: () => AuthorizationError,
25
25
  CertificatesResource: () => CertificatesResource,
26
26
  ChannelsResource: () => ChannelsResource,
27
+ CohortLeaderboardClient: () => CohortLeaderboardClient,
27
28
  DataViewsClient: () => DataViewsClient,
28
29
  DocumentsResource: () => DocumentsResource,
29
30
  EndUsersClient: () => EndUsersClient,
30
31
  EventsResource: () => EventsResource,
32
+ FanpassLeaderboardClient: () => FanpassLeaderboardClient,
31
33
  IngestionClient: () => IngestionClient,
32
34
  NetworkError: () => NetworkError,
33
35
  NotFoundError: () => NotFoundError,
@@ -1437,19 +1439,21 @@ var QuestsClient = class {
1437
1439
  // ---------------------------------------------------------------------------
1438
1440
  /**
1439
1441
  * Get quest with user progress
1442
+ * Fetches the quest and user's progress separately and combines them
1440
1443
  */
1441
1444
  async getWithProgress(questId, userId) {
1442
- return this.http.get(`/quests/${questId}/progress/${encodeURIComponent(userId)}`);
1445
+ const [quest, progress] = await Promise.all([
1446
+ this.get(questId),
1447
+ this.getUserProgress(questId, userId).catch(() => void 0)
1448
+ ]);
1449
+ return { quest, progress };
1443
1450
  }
1444
1451
  /**
1445
1452
  * List quests with progress for a user
1453
+ * @deprecated Use listAvailable() instead - this is an alias
1446
1454
  */
1447
1455
  async listWithProgress(userId, options = {}) {
1448
- const params = new URLSearchParams();
1449
- params.append("user_id", userId);
1450
- if (options.status) params.append("status", options.status);
1451
- if (options.category) params.append("category", options.category);
1452
- return this.http.get(`/quests/with-progress?${params.toString()}`);
1456
+ return this.listAvailable(userId, { category: options.category });
1453
1457
  }
1454
1458
  /**
1455
1459
  * Start a quest for a user
@@ -1768,6 +1772,99 @@ var DataViewsClient = class {
1768
1772
  }
1769
1773
  };
1770
1774
 
1775
+ // src/cohorts.ts
1776
+ var CohortLeaderboardClient = class {
1777
+ constructor(http) {
1778
+ this.http = http;
1779
+ }
1780
+ /**
1781
+ * List all cohort definitions
1782
+ */
1783
+ async list(options = {}) {
1784
+ const params = {};
1785
+ if (options.status) params.status = options.status;
1786
+ if (options.limit) params.limit = options.limit;
1787
+ if (options.offset) params.offset = options.offset;
1788
+ const response = await this.http.get(
1789
+ "/cohorts/definitions",
1790
+ params
1791
+ );
1792
+ return response.cohorts || [];
1793
+ }
1794
+ /**
1795
+ * Get a cohort definition by ID
1796
+ */
1797
+ async get(cohortId) {
1798
+ return this.http.get(
1799
+ `/cohorts/definitions/${encodeURIComponent(cohortId)}`
1800
+ );
1801
+ }
1802
+ /**
1803
+ * Get filtered cohort leaderboard with both global and filtered percentiles
1804
+ */
1805
+ async getLeaderboard(cohortId, options = {}) {
1806
+ const params = {};
1807
+ if (options.filters) params.filters = JSON.stringify(options.filters);
1808
+ if (options.country) params.country = options.country;
1809
+ if (options.limit) params.limit = options.limit;
1810
+ if (options.top_n) params.top_n = options.top_n;
1811
+ if (options.fresh) params.fresh = "true";
1812
+ return this.http.get(
1813
+ `/cohorts/definitions/${encodeURIComponent(cohortId)}/leaderboard`,
1814
+ params
1815
+ );
1816
+ }
1817
+ /**
1818
+ * Get user's breakdown across all cohorts for spider charts
1819
+ */
1820
+ async getUserBreakdown(userId, options = {}) {
1821
+ const params = {};
1822
+ if (options.filters) params.filters = JSON.stringify(options.filters);
1823
+ if (options.country) params.country = options.country;
1824
+ return this.http.get(
1825
+ `/cohorts/users/${encodeURIComponent(userId)}/breakdown`,
1826
+ params
1827
+ );
1828
+ }
1829
+ };
1830
+
1831
+ // src/fanpass_leaderboard.ts
1832
+ var FanpassLeaderboardClient = class {
1833
+ constructor(http) {
1834
+ this.http = http;
1835
+ }
1836
+ /**
1837
+ * Get fanpass leaderboard with composite scores
1838
+ */
1839
+ async getLeaderboard(options = {}) {
1840
+ const params = {};
1841
+ if (options.aggregationRuleId) {
1842
+ params.aggregation_rule_id = options.aggregationRuleId;
1843
+ }
1844
+ if (options.filters) params.filters = JSON.stringify(options.filters);
1845
+ if (options.country) params.country = options.country;
1846
+ if (options.limit) params.limit = options.limit;
1847
+ if (options.top_n) params.top_n = options.top_n;
1848
+ if (options.fresh) params.fresh = "true";
1849
+ return this.http.get(
1850
+ "/passport-v2/fanpass/leaderboard",
1851
+ params
1852
+ );
1853
+ }
1854
+ /**
1855
+ * Get user's comparison across all cohorts (spider chart data)
1856
+ */
1857
+ async getUserComparison(userId, options = {}) {
1858
+ const params = {};
1859
+ if (options.filters) params.filters = JSON.stringify(options.filters);
1860
+ if (options.country) params.country = options.country;
1861
+ return this.http.get(
1862
+ `/passport-v2/fanpass/${encodeURIComponent(userId)}/comparison`,
1863
+ params
1864
+ );
1865
+ }
1866
+ };
1867
+
1771
1868
  // src/client.ts
1772
1869
  var DocumentsResource = class {
1773
1870
  constructor(http) {
@@ -2063,6 +2160,8 @@ var ProofChain = class _ProofChain {
2063
2160
  this.quests = new QuestsClient(this.http);
2064
2161
  this.schemas = new SchemasClient(this.http);
2065
2162
  this.dataViews = new DataViewsClient(this.http);
2163
+ this.cohorts = new CohortLeaderboardClient(this.http);
2164
+ this.fanpassLeaderboard = new FanpassLeaderboardClient(this.http);
2066
2165
  }
2067
2166
  /**
2068
2167
  * Create a client from environment variables.
@@ -2250,10 +2349,12 @@ var IngestionClient = class {
2250
2349
  AuthorizationError,
2251
2350
  CertificatesResource,
2252
2351
  ChannelsResource,
2352
+ CohortLeaderboardClient,
2253
2353
  DataViewsClient,
2254
2354
  DocumentsResource,
2255
2355
  EndUsersClient,
2256
2356
  EventsResource,
2357
+ FanpassLeaderboardClient,
2257
2358
  IngestionClient,
2258
2359
  NetworkError,
2259
2360
  NotFoundError,
package/dist/index.mjs CHANGED
@@ -1385,19 +1385,21 @@ var QuestsClient = class {
1385
1385
  // ---------------------------------------------------------------------------
1386
1386
  /**
1387
1387
  * Get quest with user progress
1388
+ * Fetches the quest and user's progress separately and combines them
1388
1389
  */
1389
1390
  async getWithProgress(questId, userId) {
1390
- return this.http.get(`/quests/${questId}/progress/${encodeURIComponent(userId)}`);
1391
+ const [quest, progress] = await Promise.all([
1392
+ this.get(questId),
1393
+ this.getUserProgress(questId, userId).catch(() => void 0)
1394
+ ]);
1395
+ return { quest, progress };
1391
1396
  }
1392
1397
  /**
1393
1398
  * List quests with progress for a user
1399
+ * @deprecated Use listAvailable() instead - this is an alias
1394
1400
  */
1395
1401
  async listWithProgress(userId, options = {}) {
1396
- const params = new URLSearchParams();
1397
- params.append("user_id", userId);
1398
- if (options.status) params.append("status", options.status);
1399
- if (options.category) params.append("category", options.category);
1400
- return this.http.get(`/quests/with-progress?${params.toString()}`);
1402
+ return this.listAvailable(userId, { category: options.category });
1401
1403
  }
1402
1404
  /**
1403
1405
  * Start a quest for a user
@@ -1716,6 +1718,99 @@ var DataViewsClient = class {
1716
1718
  }
1717
1719
  };
1718
1720
 
1721
+ // src/cohorts.ts
1722
+ var CohortLeaderboardClient = class {
1723
+ constructor(http) {
1724
+ this.http = http;
1725
+ }
1726
+ /**
1727
+ * List all cohort definitions
1728
+ */
1729
+ async list(options = {}) {
1730
+ const params = {};
1731
+ if (options.status) params.status = options.status;
1732
+ if (options.limit) params.limit = options.limit;
1733
+ if (options.offset) params.offset = options.offset;
1734
+ const response = await this.http.get(
1735
+ "/cohorts/definitions",
1736
+ params
1737
+ );
1738
+ return response.cohorts || [];
1739
+ }
1740
+ /**
1741
+ * Get a cohort definition by ID
1742
+ */
1743
+ async get(cohortId) {
1744
+ return this.http.get(
1745
+ `/cohorts/definitions/${encodeURIComponent(cohortId)}`
1746
+ );
1747
+ }
1748
+ /**
1749
+ * Get filtered cohort leaderboard with both global and filtered percentiles
1750
+ */
1751
+ async getLeaderboard(cohortId, options = {}) {
1752
+ const params = {};
1753
+ if (options.filters) params.filters = JSON.stringify(options.filters);
1754
+ if (options.country) params.country = options.country;
1755
+ if (options.limit) params.limit = options.limit;
1756
+ if (options.top_n) params.top_n = options.top_n;
1757
+ if (options.fresh) params.fresh = "true";
1758
+ return this.http.get(
1759
+ `/cohorts/definitions/${encodeURIComponent(cohortId)}/leaderboard`,
1760
+ params
1761
+ );
1762
+ }
1763
+ /**
1764
+ * Get user's breakdown across all cohorts for spider charts
1765
+ */
1766
+ async getUserBreakdown(userId, options = {}) {
1767
+ const params = {};
1768
+ if (options.filters) params.filters = JSON.stringify(options.filters);
1769
+ if (options.country) params.country = options.country;
1770
+ return this.http.get(
1771
+ `/cohorts/users/${encodeURIComponent(userId)}/breakdown`,
1772
+ params
1773
+ );
1774
+ }
1775
+ };
1776
+
1777
+ // src/fanpass_leaderboard.ts
1778
+ var FanpassLeaderboardClient = class {
1779
+ constructor(http) {
1780
+ this.http = http;
1781
+ }
1782
+ /**
1783
+ * Get fanpass leaderboard with composite scores
1784
+ */
1785
+ async getLeaderboard(options = {}) {
1786
+ const params = {};
1787
+ if (options.aggregationRuleId) {
1788
+ params.aggregation_rule_id = options.aggregationRuleId;
1789
+ }
1790
+ if (options.filters) params.filters = JSON.stringify(options.filters);
1791
+ if (options.country) params.country = options.country;
1792
+ if (options.limit) params.limit = options.limit;
1793
+ if (options.top_n) params.top_n = options.top_n;
1794
+ if (options.fresh) params.fresh = "true";
1795
+ return this.http.get(
1796
+ "/passport-v2/fanpass/leaderboard",
1797
+ params
1798
+ );
1799
+ }
1800
+ /**
1801
+ * Get user's comparison across all cohorts (spider chart data)
1802
+ */
1803
+ async getUserComparison(userId, options = {}) {
1804
+ const params = {};
1805
+ if (options.filters) params.filters = JSON.stringify(options.filters);
1806
+ if (options.country) params.country = options.country;
1807
+ return this.http.get(
1808
+ `/passport-v2/fanpass/${encodeURIComponent(userId)}/comparison`,
1809
+ params
1810
+ );
1811
+ }
1812
+ };
1813
+
1719
1814
  // src/client.ts
1720
1815
  var DocumentsResource = class {
1721
1816
  constructor(http) {
@@ -2011,6 +2106,8 @@ var ProofChain = class _ProofChain {
2011
2106
  this.quests = new QuestsClient(this.http);
2012
2107
  this.schemas = new SchemasClient(this.http);
2013
2108
  this.dataViews = new DataViewsClient(this.http);
2109
+ this.cohorts = new CohortLeaderboardClient(this.http);
2110
+ this.fanpassLeaderboard = new FanpassLeaderboardClient(this.http);
2014
2111
  }
2015
2112
  /**
2016
2113
  * Create a client from environment variables.
@@ -2197,10 +2294,12 @@ export {
2197
2294
  AuthorizationError,
2198
2295
  CertificatesResource,
2199
2296
  ChannelsResource,
2297
+ CohortLeaderboardClient,
2200
2298
  DataViewsClient,
2201
2299
  DocumentsResource,
2202
2300
  EndUsersClient,
2203
2301
  EventsResource,
2302
+ FanpassLeaderboardClient,
2204
2303
  IngestionClient,
2205
2304
  NetworkError,
2206
2305
  NotFoundError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proofchain/sdk",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "description": "Official JavaScript/TypeScript SDK for ProofChain - blockchain-anchored document attestation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",