@vertikalx/vtx-backend-client 3.0.0-dev.8 → 3.0.1-dev-max.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.
Files changed (111) hide show
  1. package/package.json +16 -3
  2. package/src/api/api-call-headers.ts +35 -0
  3. package/src/api/backend-response.ts +14 -0
  4. package/src/api/domains.ts +6 -0
  5. package/src/api/response-builder.ts +165 -0
  6. package/src/api/types.ts +9 -0
  7. package/src/api/vtx-apikey-api.ts +23 -0
  8. package/src/api/vtx-base-api.ts +2253 -0
  9. package/src/api/vtx-mobile-api.ts +43 -0
  10. package/src/api/vtx-web-browser-api.ts +46 -0
  11. package/src/api/vtx-web-server-api.ts +41 -0
  12. package/src/client/index.ts +65 -0
  13. package/src/client/runtime/batcher.ts +275 -0
  14. package/src/client/runtime/createClient.ts +68 -0
  15. package/src/client/runtime/error.ts +29 -0
  16. package/src/client/runtime/fetcher.ts +97 -0
  17. package/src/client/runtime/generateGraphqlOperation.ts +225 -0
  18. package/src/client/runtime/index.ts +13 -0
  19. package/src/client/runtime/linkTypeMap.ts +156 -0
  20. package/src/client/runtime/typeSelection.ts +95 -0
  21. package/src/client/runtime/types.ts +69 -0
  22. package/src/client/schema.graphql +4256 -0
  23. package/src/client/schema.ts +8329 -0
  24. package/src/client/{types.js → types.ts} +6016 -2230
  25. package/src/generated/graphql.ts +12445 -0
  26. package/src/{index.d.ts → index.ts} +7 -2
  27. package/src/operations/admin.graphql +19 -0
  28. package/src/operations/ai-coach.graphql +117 -0
  29. package/src/operations/athlete.graphql +1764 -0
  30. package/src/operations/auth.graphql +301 -0
  31. package/src/operations/campaign.graphql +775 -0
  32. package/src/operations/email-campaign.graphql +160 -0
  33. package/src/operations/followers.graphql +45 -0
  34. package/src/operations/integrations.graphql +216 -0
  35. package/src/operations/leaderboard.graphql +54 -0
  36. package/src/operations/media.graphql +179 -0
  37. package/src/operations/notifications.graphql +93 -0
  38. package/src/operations/offers.graphql +368 -0
  39. package/src/operations/onboarding.graphql +29 -0
  40. package/src/operations/sponsor.graphql +368 -0
  41. package/src/operations/sport.graphql +132 -0
  42. package/src/operations/user.graphql +446 -0
  43. package/tsconfig.lib.json +10 -0
  44. package/src/api/api-call-headers.d.ts +0 -12
  45. package/src/api/api-call-headers.js +0 -16
  46. package/src/api/api-call-headers.js.map +0 -1
  47. package/src/api/backend-response.d.ts +0 -10
  48. package/src/api/backend-response.js +0 -3
  49. package/src/api/backend-response.js.map +0 -1
  50. package/src/api/domains.d.ts +0 -4
  51. package/src/api/domains.js +0 -8
  52. package/src/api/domains.js.map +0 -1
  53. package/src/api/response-builder.d.ts +0 -4
  54. package/src/api/response-builder.js +0 -123
  55. package/src/api/response-builder.js.map +0 -1
  56. package/src/api/types.d.ts +0 -2
  57. package/src/api/types.js +0 -3
  58. package/src/api/types.js.map +0 -1
  59. package/src/api/vtx-apikey-api.d.ts +0 -6
  60. package/src/api/vtx-apikey-api.js +0 -19
  61. package/src/api/vtx-apikey-api.js.map +0 -1
  62. package/src/api/vtx-base-api.d.ts +0 -134
  63. package/src/api/vtx-base-api.js +0 -8586
  64. package/src/api/vtx-base-api.js.map +0 -1
  65. package/src/api/vtx-mobile-api.d.ts +0 -9
  66. package/src/api/vtx-mobile-api.js +0 -62
  67. package/src/api/vtx-mobile-api.js.map +0 -1
  68. package/src/api/vtx-web-browser-api.d.ts +0 -7
  69. package/src/api/vtx-web-browser-api.js +0 -36
  70. package/src/api/vtx-web-browser-api.js.map +0 -1
  71. package/src/api/vtx-web-server-api.d.ts +0 -7
  72. package/src/api/vtx-web-server-api.js +0 -33
  73. package/src/api/vtx-web-server-api.js.map +0 -1
  74. package/src/client/index.d.ts +0 -25
  75. package/src/client/index.js +0 -44
  76. package/src/client/index.js.map +0 -1
  77. package/src/client/runtime/batcher.d.ts +0 -36
  78. package/src/client/runtime/batcher.js +0 -123
  79. package/src/client/runtime/batcher.js.map +0 -1
  80. package/src/client/runtime/createClient.d.ts +0 -17
  81. package/src/client/runtime/createClient.js +0 -28
  82. package/src/client/runtime/createClient.js.map +0 -1
  83. package/src/client/runtime/error.d.ts +0 -15
  84. package/src/client/runtime/error.js +0 -19
  85. package/src/client/runtime/error.js.map +0 -1
  86. package/src/client/runtime/fetcher.d.ts +0 -10
  87. package/src/client/runtime/fetcher.js +0 -68
  88. package/src/client/runtime/fetcher.js.map +0 -1
  89. package/src/client/runtime/generateGraphqlOperation.d.ts +0 -30
  90. package/src/client/runtime/generateGraphqlOperation.js +0 -134
  91. package/src/client/runtime/generateGraphqlOperation.js.map +0 -1
  92. package/src/client/runtime/index.d.ts +0 -11
  93. package/src/client/runtime/index.js +0 -17
  94. package/src/client/runtime/index.js.map +0 -1
  95. package/src/client/runtime/linkTypeMap.d.ts +0 -9
  96. package/src/client/runtime/linkTypeMap.js +0 -95
  97. package/src/client/runtime/linkTypeMap.js.map +0 -1
  98. package/src/client/runtime/typeSelection.d.ts +0 -28
  99. package/src/client/runtime/typeSelection.js +0 -3
  100. package/src/client/runtime/typeSelection.js.map +0 -1
  101. package/src/client/runtime/types.d.ts +0 -55
  102. package/src/client/runtime/types.js +0 -3
  103. package/src/client/runtime/types.js.map +0 -1
  104. package/src/client/schema.d.ts +0 -4886
  105. package/src/client/schema.js +0 -1051
  106. package/src/client/schema.js.map +0 -1
  107. package/src/client/types.d.ts +0 -2601
  108. package/src/client/types.js.map +0 -1
  109. package/src/index.js +0 -28
  110. package/src/index.js.map +0 -1
  111. package/tsconfig.lib.tsbuildinfo +0 -1
@@ -0,0 +1,2253 @@
1
+ import pjson from '../../package.json';
2
+ import { GraphQLClient } from 'graphql-request';
3
+ import { getSdk, Sdk } from '../generated/graphql';
4
+ import {
5
+ CreateActiveUserInput, User, AddValuesResponse, UserToken, UserWithToken, Athlete, RegisterAthleteDto, Brand, CreateBrandDto,
6
+ AWSS3UploadUrl, AWSS3GetUploadDto, RefreshTokenInput, CreateTenantInput, Tenant,
7
+ TenantWithUserLogin, RegisterUserToDomainFromEmailInput,
8
+ DecodedToken, Sponsorship, DomainCredential, CreateSponsorshipDto, SponsorAthleteInvitation, InviteAthletesDto,
9
+ RegisterUserDto, VerificationCode, FindSponsorAthleteInvitationDto, FindVtxUserDto, City,
10
+ SportLevel, Sport, EditValueResponse, EditValueDto, CreateAthleteCompetitionDto, AthleteCompetition,
11
+ GetSportEventsDto, SportsEvent, CreateSportEventDto, UpdateSportEventDto, GetAthleteCompetitionsDto,
12
+ AthleteMembership, MembershipOrganizationReference, CreateMembershipOrganizationDto, CreateAthleteMembershipDto,
13
+ DeleteSingleValueDto, DeleteSingleValueResponse, FundRaisingCampaign, CreateFundingCampaignDto,
14
+ AthleteQueryDto, AthleteQueryResponse, CreateStripeAccountDto, StripeAccount, StripeSession,
15
+ StripeAccountReference, StripeCheckoutSession, DonationCheckoutDto, GetDatabaseFileDto, TextDatabaseFile,
16
+ StripeQueryDto, StripeObject, SetFundingStatusDto, EditPictureResponse, UploadAlbumsPicturesDto,
17
+ AWSS3DeleteUseTypeFileDto, UpdateUserSuspendedStatusDto, EditPictureDto, Album, State, Country,
18
+ AWSS3DeleteUseTypeKeyDto, AthleteIntegrationReference, AWSS3CallResult, SetCompetitionResultDto,
19
+ AthleteCompetitionResult, CreateVerificationCodeDto, CodeVerificationResponse, resetPasswordDto,
20
+ DeleteValuesDto, DeleteValuesResponse, ExistValueResponse, Receipt, ReceiptUrl, GetReceiptDto,
21
+ BudgetData, AddCompetitionBudgetDto, EditCompetitionBudgetDto, EditCampaignBudgetDto,
22
+ SetCurrentCampaignDto, GetAthleteCampaignsDto, BrowseCampaignsDto, BrowseCampaignsResult,
23
+ UpdateFundingCampaignDto, EditDisplayIndexDto, MergeEventsResponse, MergeSportsEventsDto,
24
+ BudgetConcept, BudgetItemUnit, CompetitionDeleteVerificationResponse,
25
+ RegisterMemberDto, Member, Donation, GetHistoricalScoresDto, HistoricalScore,
26
+ GetMyHistoricalScoresDto, HistoricalScoresPeriod, GetTransactionDetailsDto, TransactionDetails,
27
+ AdminUserView, AdminTransactionView, PaginatedTransactions, TransactionQueryDto,
28
+ PaginatedUsers, UserQueryDto, EventQueryDto, PaginatedSports, SportQueryDto,
29
+ StripeBalance, DeleteVtxUserDto, DeleteVtxUserResponse, ForceScoreRefreshResponse,
30
+ Offer, CreateOfferDto, Sponsor, CreateSponsorDto, PaginatedBrands, BrandQueryDto,
31
+ PaginatedEvents, SponsorQueryDto, PaginatedSponsors, OfferQueryDto, PaginatedOffers,
32
+ PaginatedOffersWithEligibility, UploadResult, OfferClaim, OfferClaimQueryDto,
33
+ LeaderboardResponse, UserRank, LeaderboardQueryDto, UserRankQueryDto,
34
+ DashboardSummary, ScoreHistoryEntry, RankHistoryEntry, RankContext,
35
+ ActivitiesResponse, ActivityDetail, ComponentSummary,
36
+ ScoreHistoryQueryDto, RankHistoryQueryDto, RankContextQueryDto,
37
+ ActivitiesQueryDto, ActivityDetailQueryDto, ComponentSummaryQueryDto,
38
+ ActivityDatesResponse, ActivityDatesQueryDto, Platform, PeriodType, ContentType, PostSortOption,
39
+ Notification, NotificationListResponse, UnreadCountResponse, NotificationPreference,
40
+ NotificationQueryDto, MarkNotificationReadDto, DismissNotificationDto, UpdateNotificationPreferenceDto,
41
+ DeviceTokenType, RegisterDeviceTokenDto, UnregisterDeviceTokenDto,
42
+ FollowedAthletesListResponse, IsFollowingResponse, FollowAthleteInput, UnfollowAthleteInput,
43
+ IsFollowingAthleteInput, FollowedAthletesQueryInput,
44
+ DonationDates, PaginatedDonations, DonationQueryDto,
45
+ existValueDto, VerifyCodeDto,
46
+ } from '../client';
47
+
48
+ import { ITypedBackendResponse } from './backend-response';
49
+ import { APICallHeaders, DEFAULT_HEADERS } from './api-call-headers';
50
+ import { buildErrorResponse, buildResponse } from './response-builder';
51
+ import { DOMAIN_SPONSOR } from './domains';
52
+ import { VTX_ERRORS } from '@vertikalx/vtx-core-common';
53
+ import { CodeVerificationResponseType, VerificationCodeType } from '@vertikalx/common-types';
54
+ import { Campaign } from '@vertikalx/vtx-core-models';
55
+
56
+
57
+ export class VTXBaseAPI {
58
+ protected headers: APICallHeaders;
59
+ protected backendUrl: string;
60
+ protected gqlClient: GraphQLClient;
61
+ protected sdk: Sdk;
62
+
63
+ protected static Logger = {
64
+ debug: (str: any) => {
65
+ //console.debug(str);
66
+ },
67
+ log: (str: any) => {
68
+ console.log(str);
69
+ },
70
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
71
+ warn: (str: any) => {
72
+ //console.warn(str);
73
+ },
74
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
75
+ error: (str: any) => {
76
+ //console.error(str);
77
+ },
78
+ }
79
+
80
+ constructor(backendUrl: string, headers?: APICallHeaders, requestConfig?: { fetch?: typeof fetch }) {
81
+ this.headers = headers ?? DEFAULT_HEADERS;
82
+ this.backendUrl = backendUrl;
83
+ this.gqlClient = new GraphQLClient(backendUrl + '/graphql', {
84
+ headers: this.headers as Record<string, string>,
85
+ ...(requestConfig?.fetch ? { fetch: requestConfig.fetch } : {}),
86
+ });
87
+ this.sdk = getSdk(this.gqlClient);
88
+ }
89
+
90
+ public getHeaders(): APICallHeaders {
91
+ return this.headers;
92
+ }
93
+
94
+ public setHeader(key: string, value: string) {
95
+ this.headers[key] = value;
96
+ this.gqlClient.setHeaders(this.headers as Record<string, string>);
97
+ }
98
+
99
+ public static getVersion(): string {
100
+ return pjson?.version ?? '0.0.0';
101
+ }
102
+
103
+ public static isBrowser(): boolean {
104
+ if (typeof process === 'object' && typeof require === 'function') {
105
+ return false;
106
+ }
107
+ if (typeof importScripts === 'function') {
108
+ return false;
109
+ }
110
+ if (typeof window === 'object') {
111
+ return true;
112
+ }
113
+ return false;
114
+ }
115
+
116
+ // Generic execute wrapper for SDK calls
117
+ protected async execute<T>(
118
+ sdkCall: () => Promise<any>,
119
+ rootProperty: string,
120
+ checker: (response: any) => boolean,
121
+ logPrefix: string
122
+ ): Promise<ITypedBackendResponse<T>> {
123
+ let retValue: ITypedBackendResponse<T> = {};
124
+ try {
125
+ const response = await sdkCall();
126
+ VTXBaseAPI.Logger.debug(`${logPrefix} Response:`);
127
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
128
+ retValue = buildResponse<T>(response, rootProperty, checker);
129
+ } catch (err1: any) {
130
+ VTXBaseAPI.Logger.error(`${logPrefix} err1:`);
131
+ VTXBaseAPI.Logger.error(err1);
132
+ retValue = buildErrorResponse<T>(err1);
133
+ }
134
+ return retValue;
135
+ }
136
+
137
+ // ============= AUTH / USER METHODS =============
138
+
139
+ public async findUserByEmail(email: string): Promise<ITypedBackendResponse<User>> {
140
+ const curatedEmail = email.trim().toLocaleLowerCase();
141
+ return this.execute<User>(
142
+ () => this.sdk.FindUserByEmail({ email: curatedEmail }),
143
+ 'findUserByEmail',
144
+ (r) => !!r?.findUserByEmail?._id,
145
+ 'findUserByEmail'
146
+ );
147
+ }
148
+
149
+ public async loginUserFromEmail(loginEmail: string, loginMethod: string = ""): Promise<ITypedBackendResponse<UserToken>> {
150
+ const curatedEmail = loginEmail.trim().toLocaleLowerCase();
151
+ return this.execute<UserToken>(
152
+ () => this.sdk.LoginUserFromEmail({ email: curatedEmail, loginMethod }),
153
+ 'loginUserFromEmail',
154
+ (r) => !!r?.loginUserFromEmail?.actualToken,
155
+ 'loginUserFromEmail'
156
+ );
157
+ }
158
+
159
+ public async createUserAndLogin(loginEmail: string): Promise<ITypedBackendResponse<UserWithToken>> {
160
+ const curatedEmail = loginEmail.trim().toLowerCase();
161
+ const payload: CreateActiveUserInput = { loginEmail: curatedEmail };
162
+ return this.execute<UserWithToken>(
163
+ () => this.sdk.CreateUserAndLogin({ user: payload }),
164
+ 'createUserAndLogin',
165
+ (r) => !!r?.createUserAndLogin?._id,
166
+ 'createUserAndLogin'
167
+ );
168
+ }
169
+
170
+ public async registerMember(dto: RegisterMemberDto): Promise<ITypedBackendResponse<Member>> {
171
+ return this.execute<Member>(
172
+ () => this.sdk.RegisterMember({ input: dto }),
173
+ 'registerMember',
174
+ (r) => !!r?.registerMember?._id,
175
+ 'registerMember'
176
+ );
177
+ }
178
+
179
+ public async registerAthlete(payload: RegisterAthleteDto): Promise<ITypedBackendResponse<Athlete>> {
180
+ return this.execute<Athlete>(
181
+ () => this.sdk.RegisterAthlete({ input: payload }),
182
+ 'registerAthlete',
183
+ (r) => !!r?.registerAthlete?._id,
184
+ 'registerAthlete'
185
+ );
186
+ }
187
+
188
+ public async findBrandByName(name: string, translations: boolean = false): Promise<ITypedBackendResponse<Brand>> {
189
+ return this.execute<Brand>(
190
+ () => this.sdk.FindBrandByName({ name, translations }),
191
+ 'getBrandByName',
192
+ (r) => !!r?.getBrandByName?._id,
193
+ 'getBrandByName'
194
+ );
195
+ }
196
+
197
+ public async createBrand(dto: CreateBrandDto): Promise<ITypedBackendResponse<Brand>> {
198
+ return this.execute<Brand>(
199
+ () => this.sdk.CreateBrand({ input: dto }),
200
+ 'createBrand',
201
+ (r) => !!r?.createBrand?._id,
202
+ 'createBrand'
203
+ );
204
+ }
205
+
206
+ public async createSponsorship(dto: CreateSponsorshipDto, _desiredFields?: any): Promise<ITypedBackendResponse<Sponsorship>> {
207
+ return this.execute<Sponsorship>(
208
+ () => this.sdk.CreateSponsorship({ input: dto }),
209
+ 'createSponsorship',
210
+ (r) => !!r?.createSponsorship?._id,
211
+ 'createSponsorship'
212
+ );
213
+ }
214
+
215
+ public async getS3UploadUrl(dto: AWSS3GetUploadDto): Promise<ITypedBackendResponse<AWSS3UploadUrl>> {
216
+ return this.execute<AWSS3UploadUrl>(
217
+ () => this.sdk.GetS3UploadUrl({ input: dto }),
218
+ 'getUploadUrl',
219
+ (r) => r?.getUploadUrl?.uploadUrl !== undefined && r?.getUploadUrl?.uploadUrl !== null,
220
+ 'getUploadUrl'
221
+ );
222
+ }
223
+
224
+ public async getVtxS3UploadUrl(dto: AWSS3GetUploadDto): Promise<ITypedBackendResponse<AWSS3UploadUrl>> {
225
+ return this.execute<AWSS3UploadUrl>(
226
+ () => this.sdk.GetVtxS3UploadUrl({ input: dto }),
227
+ 'getS3UploadUrl',
228
+ (r) => r?.getS3UploadUrl?.uploadUrl !== undefined && r?.getS3UploadUrl?.uploadUrl !== null,
229
+ 'getVtxS3UploadUrl'
230
+ );
231
+ }
232
+
233
+ public async refreshToken(currentToken: string, refreshToken: string): Promise<ITypedBackendResponse<UserToken>> {
234
+ const dto: RefreshTokenInput = { refreshToken };
235
+ return this.execute<UserToken>(
236
+ () => this.sdk.RefreshToken({ dto }),
237
+ 'refreshToken',
238
+ (r) => !!r?.refreshToken?.refreshToken,
239
+ 'refreshToken'
240
+ );
241
+ }
242
+
243
+ public async registerNewDomainTenant(input: CreateTenantInput): Promise<ITypedBackendResponse<Tenant>> {
244
+ return this.execute<Tenant>(
245
+ () => this.sdk.RegisterNewDomainTenant({ tenant: input }),
246
+ 'registerNewDomainTenant',
247
+ (r) => !!r?.registerNewDomainTenant?._id,
248
+ 'registerNewDomainTenant'
249
+ );
250
+ }
251
+
252
+ public async registerNewDomainTenantWithLogin(input: CreateTenantInput): Promise<ITypedBackendResponse<TenantWithUserLogin>> {
253
+ return this.execute<TenantWithUserLogin>(
254
+ () => this.sdk.RegisterNewDomainTenantWithLogin({ tenant: input }),
255
+ 'TenantWithUserLogin',
256
+ (r) => !!r?.TenantWithUserLogin?._id,
257
+ 'registerNewDomainTenantWithLogin'
258
+ );
259
+ }
260
+
261
+ public async registerUserToDomainFromEmail(input: RegisterUserToDomainFromEmailInput): Promise<ITypedBackendResponse<User>> {
262
+ return this.execute<User>(
263
+ () => this.sdk.RegisterUserToDomainFromEmail({ input }),
264
+ 'registerUserToDomainFromEmail',
265
+ (r) => !!r?.registerUserToDomainFromEmail?.loginEmail,
266
+ 'registerUserToDomainFromEmail'
267
+ );
268
+ }
269
+
270
+ public async getPublicSponsorships(): Promise<ITypedBackendResponse<Sponsorship[]>> {
271
+ return this.execute<Sponsorship[]>(
272
+ () => this.sdk.GetPublicSponsorships(),
273
+ 'getPublicSponsorships',
274
+ (r) => Array.isArray(r?.getPublicSponsorships),
275
+ 'getPublicSponsorships'
276
+ );
277
+ }
278
+
279
+ public async getTenantSponsorshipsFromUri(tenantUri: string, token: DecodedToken): Promise<ITypedBackendResponse<Sponsorship[]>> {
280
+ if ((!tenantUri) || (tenantUri.trim() === "")) {
281
+ return {
282
+ error: {
283
+ httpStatus: 400,
284
+ code: VTX_ERRORS.INVALID_TENANT_URI.code,
285
+ message: VTX_ERRORS.INVALID_TENANT_URI.description
286
+ }
287
+ };
288
+ }
289
+ const credential: DomainCredential | undefined = token.domains.find(c => {
290
+ if (c.tenant) {
291
+ if ((c.tenant.tenant_uri == tenantUri) && (c._id == DOMAIN_SPONSOR)) {
292
+ return true;
293
+ }
294
+ }
295
+ return false;
296
+ });
297
+ if (!credential) {
298
+ return {
299
+ error: {
300
+ httpStatus: 400,
301
+ code: VTX_ERRORS.INVALID_TENANT_URI_FOR_SPONSOR.code,
302
+ message: "Tenant in domain SPONSOR not found in domains with URI " + tenantUri
303
+ }
304
+ };
305
+ }
306
+ const tenantId: string | null = credential.tenant?._id ?? null;
307
+ if ((!tenantId) || (tenantId == "ALL")) {
308
+ return {
309
+ error: {
310
+ httpStatus: 400,
311
+ code: VTX_ERRORS.INVALID_TENANT_ID.code,
312
+ message: VTX_ERRORS.INVALID_TENANT_ID.description
313
+ }
314
+ };
315
+ }
316
+ return this.getTenantSponsorships(tenantId);
317
+ }
318
+
319
+ public async isUserSuspended(loginEmail: string): Promise<ITypedBackendResponse<boolean>> {
320
+ return this.execute<boolean>(
321
+ () => this.sdk.IsUserSuspended({ loginEmail }),
322
+ 'isUserSuspended',
323
+ (r) => r?.isUserSuspended !== undefined,
324
+ 'isUserSuspended'
325
+ );
326
+ }
327
+
328
+ public async getTenantSponsorships(tenantId: string): Promise<ITypedBackendResponse<Sponsorship[]>> {
329
+ return this.execute<Sponsorship[]>(
330
+ () => this.sdk.GetTenantSponsorships(),
331
+ 'getTenantSponsorships',
332
+ (r) => Array.isArray(r?.getTenantSponsorships),
333
+ 'getTenantSponsorships'
334
+ );
335
+ }
336
+
337
+ public async sendAthleteInvitations(input: InviteAthletesDto): Promise<ITypedBackendResponse<SponsorAthleteInvitation[]>> {
338
+ return this.execute<SponsorAthleteInvitation[]>(
339
+ () => this.sdk.SendAthleteInvitations({ input }),
340
+ 'sendAthleteInvitations',
341
+ (r) => Array.isArray(r?.sendAthleteInvitations),
342
+ 'sendAthleteInvitations'
343
+ );
344
+ }
345
+
346
+ public async registerSponsorUser(input: RegisterUserDto): Promise<ITypedBackendResponse<User>> {
347
+ return this.execute<User>(
348
+ () => this.sdk.RegisterSponsorUser({ input }),
349
+ 'registerSponsorUser',
350
+ (r) => !!r?.registerSponsorUser?._id,
351
+ 'registerSponsorUser'
352
+ );
353
+ }
354
+
355
+ public async registerAthleteUser(input: RegisterUserDto): Promise<ITypedBackendResponse<User>> {
356
+ return this.execute<User>(
357
+ () => this.sdk.RegisterAthleteUser({ input }),
358
+ 'registerAthleteUser',
359
+ (r) => !!r?.registerAthleteUser?._id,
360
+ 'registerAthleteUser'
361
+ );
362
+ }
363
+
364
+ public async preRegisterAthleteUser(input: RegisterUserDto): Promise<ITypedBackendResponse<VerificationCode>> {
365
+ return this.execute<VerificationCode>(
366
+ () => this.sdk.PreRegisterAthleteUser({ input }),
367
+ 'preRegisterAthleteUser',
368
+ (r) => !!r?.preRegisterAthleteUser?._id,
369
+ 'preRegisterAthleteUser'
370
+ );
371
+ }
372
+
373
+ public async confirmAthleteUserRegistrationAndLogin(input: VerifyCodeDto): Promise<ITypedBackendResponse<UserWithToken>> {
374
+ return this.execute<UserWithToken>(
375
+ () => this.sdk.ConfirmAthleteUserRegistrationAndLogin({ input }),
376
+ 'confirmAthleteUserRegistrationAndLogin',
377
+ (r) => !!r?.confirmAthleteUserRegistrationAndLogin?._id,
378
+ 'confirmAthleteUserRegistrationAndLogin'
379
+ );
380
+ }
381
+
382
+ public async confirmAthleteUserRegistration(input: VerifyCodeDto): Promise<ITypedBackendResponse<User>> {
383
+ return this.execute<User>(
384
+ () => this.sdk.ConfirmAthleteUserRegistration({ input }),
385
+ 'confirmAthleteUserRegistration',
386
+ (r) => !!r?.confirmAthleteUserRegistration?._id,
387
+ 'confirmAthleteUserRegistration'
388
+ );
389
+ }
390
+
391
+ public async findSponsorAthleteInvitation(dto: FindSponsorAthleteInvitationDto): Promise<ITypedBackendResponse<SponsorAthleteInvitation>> {
392
+ return this.execute<SponsorAthleteInvitation>(
393
+ () => this.sdk.FindSponsorAthleteInvitation({ input: dto }),
394
+ 'findSponsorAthleteInvitation',
395
+ (r) => !!r?.findSponsorAthleteInvitation?._id,
396
+ 'findSponsorAthleteInvitation'
397
+ );
398
+ }
399
+
400
+ public async findVtxUser(dto: FindVtxUserDto): Promise<ITypedBackendResponse<User>> {
401
+ return this.execute<User>(
402
+ () => this.sdk.FindVtxUser({ input: dto }),
403
+ 'findVtxUser',
404
+ (r) => !!r?.findVtxUser?._id,
405
+ 'findVtxUser'
406
+ );
407
+ }
408
+
409
+ public async findCitiesStartingWith(pattern: string): Promise<ITypedBackendResponse<City[]>> {
410
+ return this.execute<City[]>(
411
+ () => this.sdk.FindCitiesStartingWith({ text: pattern }),
412
+ 'findCitiesStartingWith',
413
+ (r) => Array.isArray(r?.findCitiesStartingWith),
414
+ 'findCitiesStartingWith'
415
+ );
416
+ }
417
+
418
+ public async findCityById(cityId: string): Promise<ITypedBackendResponse<City>> {
419
+ return this.execute<City>(
420
+ () => this.sdk.FindCityById({ cityId }),
421
+ 'findCityById',
422
+ (r) => !!r?.findCityById?._id,
423
+ 'findCityById'
424
+ );
425
+ }
426
+
427
+ public async getSportLevels(): Promise<ITypedBackendResponse<SportLevel[]>> {
428
+ return this.execute<SportLevel[]>(
429
+ () => this.sdk.GetSportLevels(),
430
+ 'getSportLevels',
431
+ (r) => Array.isArray(r?.getSportLevels),
432
+ 'getSportLevels'
433
+ );
434
+ }
435
+
436
+ public async getSports(): Promise<ITypedBackendResponse<Sport[]>> {
437
+ return this.execute<Sport[]>(
438
+ () => this.sdk.GetSports(),
439
+ 'getSports',
440
+ (r) => Array.isArray(r?.getSports),
441
+ 'getSports'
442
+ );
443
+ }
444
+
445
+ public async getSportsPaginated(args: { query: SportQueryDto }): Promise<ITypedBackendResponse<PaginatedSports>> {
446
+ return this.execute<PaginatedSports>(
447
+ () => this.sdk.GetSportsPaginated({ query: args.query }),
448
+ 'getSportsPaginated',
449
+ (r) => true,
450
+ 'getSportsPaginated'
451
+ );
452
+ }
453
+
454
+ public async getStates(): Promise<ITypedBackendResponse<State[]>> {
455
+ return this.execute<State[]>(
456
+ () => this.sdk.GetStates(),
457
+ 'getStates',
458
+ (r) => Array.isArray(r?.getStates),
459
+ 'getStates'
460
+ );
461
+ }
462
+
463
+ public async getCountries(): Promise<ITypedBackendResponse<Country[]>> {
464
+ return this.execute<Country[]>(
465
+ () => this.sdk.GetCountries(),
466
+ 'getCountries',
467
+ (r) => Array.isArray(r?.getCountries),
468
+ 'getCountries'
469
+ );
470
+ }
471
+
472
+ public async loginUserFromCredentialsVtx(username: string, password: string): Promise<ITypedBackendResponse<UserWithToken>> {
473
+ const curatedEmail = username.trim().toLocaleLowerCase();
474
+ return this.execute<UserWithToken>(
475
+ () => this.sdk.LoginUserFromCredentialsVtx({ username: curatedEmail, password }),
476
+ 'loginUserFromCredentialsVtx',
477
+ (r) => !!r?.loginUserFromCredentialsVtx?.actualToken,
478
+ 'loginUserFromCredentialsVtx'
479
+ );
480
+ }
481
+
482
+ public async validateUserCredentialsVtx(username: string, password: string): Promise<ITypedBackendResponse<User>> {
483
+ const curatedEmail = username.trim().toLocaleLowerCase();
484
+ return this.execute<User>(
485
+ () => this.sdk.ValidateUserCredentialsVtx({ username: curatedEmail, password }),
486
+ 'validateUserCredentials',
487
+ (r) => !!r?.validateUserCredentials?._id,
488
+ 'validateUserCredentials'
489
+ );
490
+ }
491
+
492
+ public async findAthleteForUser(loginEmail: string): Promise<ITypedBackendResponse<Athlete>> {
493
+ return this.execute<Athlete>(
494
+ () => this.sdk.FindAthleteForUser({ loginEmail }),
495
+ 'findAthleteForUser',
496
+ (r) => !!r?.findAthleteForUser?._id,
497
+ 'findAthleteForUser'
498
+ );
499
+ }
500
+
501
+ // ============= BRAND / ATHLETE LISTING METHODS =============
502
+
503
+ public async getBrands(): Promise<ITypedBackendResponse<Brand[]>> {
504
+ return this.execute<Brand[]>(
505
+ () => this.sdk.GetBrands(),
506
+ 'brands',
507
+ (r) => Array.isArray(r?.brands),
508
+ 'brands'
509
+ );
510
+ }
511
+
512
+ public async getBrandsPaginated(args: { query: BrandQueryDto }): Promise<ITypedBackendResponse<PaginatedBrands>> {
513
+ return this.execute<PaginatedBrands>(
514
+ () => this.sdk.GetBrandsPaginated({ query: args.query }),
515
+ 'getBrandsPaginated',
516
+ (r) => true,
517
+ 'getBrandsPaginated'
518
+ );
519
+ }
520
+
521
+ public async getAthletes(): Promise<ITypedBackendResponse<Athlete[]>> {
522
+ return this.execute<Athlete[]>(
523
+ () => this.sdk.GetAthletes(),
524
+ 'athletes',
525
+ (r) => Array.isArray(r?.athletes),
526
+ 'athletes'
527
+ );
528
+ }
529
+
530
+ public async searchAthletes(searchString: string): Promise<ITypedBackendResponse<Athlete[]>> {
531
+ return this.execute<Athlete[]>(
532
+ () => this.sdk.SearchAthletes({ searchString }),
533
+ 'searchAthletes',
534
+ (r) => Array.isArray(r?.searchAthletes),
535
+ 'searchAthletes'
536
+ );
537
+ }
538
+
539
+ public async getRecommendedAthletes(loginEmail: string): Promise<ITypedBackendResponse<Athlete[]>> {
540
+ return this.execute<Athlete[]>(
541
+ () => this.sdk.GetRecommendedAthletes({ loginEmail }),
542
+ 'getRecommendedAthletes',
543
+ (r) => Array.isArray(r?.getRecommendedAthletes),
544
+ 'getRecommendedAthletes'
545
+ );
546
+ }
547
+
548
+ public async getSponsorAthletesForTenant(): Promise<ITypedBackendResponse<Athlete[]>> {
549
+ return this.execute<Athlete[]>(
550
+ () => this.sdk.GetSponsorAthletesForTenant(),
551
+ 'getSponsorAthletesForTenant',
552
+ (r) => Array.isArray(r?.getSponsorAthletesForTenant),
553
+ 'getSponsorAthletesForTenant'
554
+ );
555
+ }
556
+
557
+ public async getUserImagesFromEmail(loginEmail: string): Promise<ITypedBackendResponse<UserImages>> {
558
+ return this.execute<UserImages>(
559
+ () => this.sdk.GetUserImagesFromEmail({ loginEmail }),
560
+ 'getUserImagesFromEmail',
561
+ (r) => !!r?.getUserImagesFromEmail,
562
+ 'getUserImagesFromEmail'
563
+ );
564
+ }
565
+
566
+ // ============= PROFILE EDIT METHODS =============
567
+
568
+ public async editAboutMe(newValue: string): Promise<ITypedBackendResponse<EditValueResponse>> {
569
+ const dto: EditValueDto = { field: 'aboutMe', newValue };
570
+ return this.execute<EditValueResponse>(
571
+ () => this.sdk.EditAboutMe({ input: dto }),
572
+ 'editProfileValue',
573
+ (r) => !!r?.editProfileValue?.field,
574
+ 'editProfileValue'
575
+ );
576
+ }
577
+
578
+ public async editProfileValue(newValue: string, field: string): Promise<ITypedBackendResponse<EditValueResponse>> {
579
+ const dto: EditValueDto = { field, newValue };
580
+ return this.execute<EditValueResponse>(
581
+ () => this.sdk.EditProfileValue({ input: dto }),
582
+ 'editProfileValue',
583
+ (r) => !!r?.editProfileValue?.field,
584
+ 'editProfileValue'
585
+ );
586
+ }
587
+
588
+ // ============= COMPETITION METHODS =============
589
+
590
+ public async addAthleteCompetition(dto: CreateAthleteCompetitionDto): Promise<ITypedBackendResponse<AthleteCompetition>> {
591
+ return this.execute<AthleteCompetition>(
592
+ () => this.sdk.AddAthleteCompetition({ input: dto }),
593
+ 'addAthleteCompetition',
594
+ (r) => !!r?.addAthleteCompetition?._id,
595
+ 'addAthleteCompetition'
596
+ );
597
+ }
598
+
599
+ public async getSportsEvents(dto: GetSportEventsDto): Promise<ITypedBackendResponse<SportsEvent[]>> {
600
+ return this.execute<SportsEvent[]>(
601
+ () => this.sdk.GetSportsEvents({ input: dto }),
602
+ 'getSportsEvents',
603
+ (r) => Array.isArray(r?.getSportsEvents),
604
+ 'getSportsEvents'
605
+ );
606
+ }
607
+
608
+ public async getSportsEventsPaginated(dto: { query: EventQueryDto }): Promise<ITypedBackendResponse<PaginatedEvents>> {
609
+ return this.execute<PaginatedEvents>(
610
+ () => this.sdk.GetSportsEventsPaginated({ query: dto.query }),
611
+ 'getSportsEventsPaginated',
612
+ (r) => true,
613
+ 'getSportsEventsPaginated'
614
+ );
615
+ }
616
+
617
+ public async createSportsEvent(dto: CreateSportEventDto): Promise<ITypedBackendResponse<SportsEvent>> {
618
+ return this.execute<SportsEvent>(
619
+ () => this.sdk.CreateSportsEvent({ input: dto }),
620
+ 'createSportsEvent',
621
+ (r) => !!r?.createSportsEvent?._id,
622
+ 'createSportsEvent'
623
+ );
624
+ }
625
+
626
+ public async updateSportsEvent(dto: { input: UpdateSportEventDto }): Promise<ITypedBackendResponse<SportsEvent>> {
627
+ return this.execute<SportsEvent>(
628
+ () => this.sdk.UpdateSportsEvent({ input: dto.input }),
629
+ 'updateSportsEvent',
630
+ (r) => !!r?.updateSportsEvent?._id,
631
+ 'updateSportsEvent'
632
+ );
633
+ }
634
+
635
+ public async deleteSportsEvent(dto: { eventId: string }): Promise<ITypedBackendResponse<DeleteSingleValueResponse>> {
636
+ return this.execute<DeleteSingleValueResponse>(
637
+ () => this.sdk.DeleteSportsEvent({ eventId: dto.eventId }),
638
+ 'deleteSportsEvent',
639
+ (r) => !!r?.deleteSportsEvent?.idToDelete,
640
+ 'deleteSportsEvent'
641
+ );
642
+ }
643
+
644
+ public async mergeSportsEvents(dto: MergeSportsEventsDto): Promise<ITypedBackendResponse<MergeEventsResponse>> {
645
+ return this.execute<MergeEventsResponse>(
646
+ () => this.sdk.MergeSportsEvents({ input: dto }),
647
+ 'mergeSportsEvents',
648
+ (r) => !!r?.mergeSportsEvents,
649
+ 'mergeSportsEvents'
650
+ );
651
+ }
652
+
653
+ public async getAthleteCompetitions(dto: GetAthleteCompetitionsDto): Promise<ITypedBackendResponse<AthleteCompetition[]>> {
654
+ return this.execute<AthleteCompetition[]>(
655
+ () => this.sdk.GetAthleteCompetitions({ input: dto }),
656
+ 'getAthleteCompetitions',
657
+ (r) => Array.isArray(r?.getAthleteCompetitions),
658
+ 'getAthleteCompetitions'
659
+ );
660
+ }
661
+
662
+ public async getAthleteMemberships(athleteId: string): Promise<ITypedBackendResponse<AthleteMembership[]>> {
663
+ return this.execute<AthleteMembership[]>(
664
+ () => this.sdk.GetAthleteMemberships({ athleteId }),
665
+ 'getAthleteMemberships',
666
+ (r) => Array.isArray(r?.getAthleteMemberships),
667
+ 'getAthleteMemberships'
668
+ );
669
+ }
670
+
671
+ public async deleteAthleteCompetition(dto: DeleteSingleValueDto): Promise<ITypedBackendResponse<DeleteSingleValueResponse>> {
672
+ return this.execute<DeleteSingleValueResponse>(
673
+ () => this.sdk.DeleteAthleteCompetition({ input: dto }),
674
+ 'deleteAthleteCompetition',
675
+ (r) => !!r?.deleteAthleteCompetition?.idToDelete,
676
+ 'deleteAthleteCompetition'
677
+ );
678
+ }
679
+
680
+ // ============= CAMPAIGN METHODS =============
681
+
682
+ public async createFundingCampaign(dto: CreateFundingCampaignDto): Promise<ITypedBackendResponse<FundRaisingCampaign>> {
683
+ return this.execute<FundRaisingCampaign>(
684
+ () => this.sdk.CreateFundingCampaign({ input: dto }),
685
+ 'createFundingCampaign',
686
+ (r) => !!r?.createFundingCampaign?._id,
687
+ 'createFundingCampaign'
688
+ );
689
+ }
690
+
691
+ public async createMembershipOrganization(dto: CreateMembershipOrganizationDto): Promise<ITypedBackendResponse<MembershipOrganizationReference>> {
692
+ return this.execute<MembershipOrganizationReference>(
693
+ () => this.sdk.CreateMembershipOrganization({ input: dto }),
694
+ 'createMembershipOrganization',
695
+ (r) => !!r?.createMembershipOrganization?._id,
696
+ 'createMembershipOrganization'
697
+ );
698
+ }
699
+
700
+ public async getMembershipOrganizations(): Promise<ITypedBackendResponse<MembershipOrganizationReference[]>> {
701
+ return this.execute<MembershipOrganizationReference[]>(
702
+ () => this.sdk.GetMembershipOrganizations(),
703
+ 'getMembershipOrganizations',
704
+ (r) => Array.isArray(r?.getMembershipOrganizations),
705
+ 'getMembershipOrganizations'
706
+ );
707
+ }
708
+
709
+ public async createAthleteMembershipAffilation(dto: CreateAthleteMembershipDto): Promise<ITypedBackendResponse<AthleteMembership>> {
710
+ return this.execute<AthleteMembership>(
711
+ () => this.sdk.CreateAthleteMembershipAffilation({ input: dto }),
712
+ 'createAthleteMembershipAffilation',
713
+ (r) => !!r?.createAthleteMembershipAffilation?._id,
714
+ 'createAthleteMembershipAffilation'
715
+ );
716
+ }
717
+
718
+ public async deleteMembershipAffiliation(dto: DeleteSingleValueDto): Promise<ITypedBackendResponse<DeleteSingleValueResponse>> {
719
+ return this.execute<DeleteSingleValueResponse>(
720
+ () => this.sdk.DeleteMembershipAffiliation({ input: dto }),
721
+ 'deleteMembershipAffiliation',
722
+ (r) => !!r?.deleteMembershipAffiliation?.idToDelete,
723
+ 'deleteMembershipAffiliation'
724
+ );
725
+ }
726
+
727
+ public async queryAthleteFundingCampaigns(dto: AthleteQueryDto): Promise<ITypedBackendResponse<AthleteQueryResponse>> {
728
+ return this.execute<AthleteQueryResponse>(
729
+ () => this.sdk.QueryAthleteFundingCampaigns({ input: dto }),
730
+ 'queryAthleteFundingCampaigns',
731
+ (r) => !!r?.queryAthleteFundingCampaigns,
732
+ 'queryAthleteFundingCampaigns'
733
+ );
734
+ }
735
+
736
+ // ============= STRIPE METHODS =============
737
+
738
+ public async createStripeAccount(dto: CreateStripeAccountDto): Promise<ITypedBackendResponse<StripeAccountReference>> {
739
+ return this.execute<StripeAccountReference>(
740
+ () => this.sdk.CreateStripeAccount({ input: dto }),
741
+ 'createStripeAccount',
742
+ (r) => !!r?.createStripeAccount?._id,
743
+ 'createStripeAccount'
744
+ );
745
+ }
746
+
747
+ public async createAthleteStripeSession(): Promise<ITypedBackendResponse<StripeSession>> {
748
+ return this.execute<StripeSession>(
749
+ () => this.sdk.CreateAthleteStripeSession(),
750
+ 'createAthleteStripeSession',
751
+ (r) => !!r?.createAthleteStripeSession?.client_secret,
752
+ 'createAthleteStripeSession'
753
+ );
754
+ }
755
+
756
+ public async createStripeCheckoutSession(dto: DonationCheckoutDto, _desiredFields?: any): Promise<ITypedBackendResponse<StripeCheckoutSession>> {
757
+ return this.execute<StripeCheckoutSession>(
758
+ () => this.sdk.CreateStripeCheckoutSession({ input: dto }),
759
+ 'createStripeCheckoutSession',
760
+ (r) => !!r?.createStripeCheckoutSession?.client_secret,
761
+ 'createStripeCheckoutSession'
762
+ );
763
+ }
764
+
765
+ public async createStripeLoginLink(): Promise<ITypedBackendResponse<string>> {
766
+ return this.execute<string>(
767
+ () => this.sdk.CreateStripeLoginLink(),
768
+ 'createStripeLoginLink',
769
+ (r) => !!r?.createStripeLoginLink,
770
+ 'createStripeLoginLink'
771
+ );
772
+ }
773
+
774
+ public async createStripeAccountLink(): Promise<ITypedBackendResponse<string>> {
775
+ return this.execute<string>(
776
+ () => this.sdk.CreateStripeAccountLink(),
777
+ 'createStripeAccountLink',
778
+ (r) => !!r?.createStripeAccountLink,
779
+ 'createStripeAccountLink'
780
+ );
781
+ }
782
+
783
+ public async getStripeBalance(): Promise<ITypedBackendResponse<StripeBalance>> {
784
+ return this.execute<StripeBalance>(
785
+ () => this.sdk.GetStripeBalance(),
786
+ 'getStripeBalance',
787
+ (r) => r?.getStripeBalance?.availableUSD !== undefined,
788
+ 'getStripeBalance'
789
+ );
790
+ }
791
+
792
+ public async getDatabaseTextFile(dto: GetDatabaseFileDto): Promise<ITypedBackendResponse<TextDatabaseFile>> {
793
+ return this.execute<TextDatabaseFile>(
794
+ () => this.sdk.GetDatabaseTextFile({ input: dto }),
795
+ 'getDatabaseTextFile',
796
+ (r) => !!r?.getDatabaseTextFile?._id,
797
+ 'getDatabaseTextFile'
798
+ );
799
+ }
800
+
801
+ public async getReceiptUrl(dto: GetReceiptDto): Promise<ITypedBackendResponse<ReceiptUrl>> {
802
+ return this.execute<ReceiptUrl>(
803
+ () => this.sdk.GetReceiptUrl({ input: dto }),
804
+ 'getReceiptUrl',
805
+ (r) => !!r?.getReceiptUrl?.receiptId,
806
+ 'getReceiptUrl'
807
+ );
808
+ }
809
+
810
+ public async stripeQuery(dto: StripeQueryDto): Promise<ITypedBackendResponse<StripeObject>> {
811
+ return this.execute<StripeObject>(
812
+ () => this.sdk.StripeQuery({ input: dto }),
813
+ 'stripeQuery',
814
+ (r) => !!r?.stripeQuery,
815
+ 'stripeQuery'
816
+ );
817
+ }
818
+
819
+ public async setFundingStatus(dto: SetFundingStatusDto, _desiredFields?: any): Promise<ITypedBackendResponse<FundRaisingCampaign>> {
820
+ return this.execute<FundRaisingCampaign>(
821
+ () => this.sdk.SetFundingStatus({ input: dto }),
822
+ 'setFundingStatus',
823
+ (r) => !!r?.setFundingStatus?._id,
824
+ 'setFundingStatus'
825
+ );
826
+ }
827
+
828
+ // ============= ATHLETE PUBLIC PROFILE =============
829
+
830
+ public async findAthleteForIdPublic(id: string): Promise<ITypedBackendResponse<Athlete>> {
831
+ return this.execute<Athlete>(
832
+ () => this.sdk.FindAthleteForIdPublic({ athleteId: id }),
833
+ 'findAthletebyIdpublic',
834
+ (r) => !!r?.findAthletebyIdpublic?._id,
835
+ 'findAthletebyIdpublic'
836
+ );
837
+ }
838
+
839
+ // ============= PICTURE / ALBUM METHODS =============
840
+
841
+ public async editPicture(newPicDto: EditPictureDto): Promise<ITypedBackendResponse<EditPictureResponse>> {
842
+ console.log('HEADERS:');
843
+ console.log(JSON.stringify(this.headers, null, 2));
844
+ return this.execute<EditPictureResponse>(
845
+ () => this.sdk.EditPicture({ input: newPicDto }),
846
+ 'editPicture',
847
+ (r) => !!r?.editPicture?.field,
848
+ 'editPicture'
849
+ );
850
+ }
851
+
852
+ public async addAlbumsPictures(dto: UploadAlbumsPicturesDto): Promise<ITypedBackendResponse<AddValuesResponse>> {
853
+ console.log('HEADERS:');
854
+ console.log(JSON.stringify(this.headers, null, 2));
855
+ let retValue: ITypedBackendResponse<AddValuesResponse> = {};
856
+ try {
857
+ const response: any = await this.sdk.AddAlbumPictures({ input: dto });
858
+ console.log('AddAlbumsPictures Response:');
859
+ console.log(JSON.stringify(response, null, 2));
860
+ retValue = buildResponse<AddValuesResponse>(response, 'AddAlbumPictures',
861
+ (r: any) => {
862
+ return r?.AddAlbumPictures?.result === 'success' || r?.AddAlbumPictures?.result === 'partial';
863
+ }
864
+ );
865
+ } catch (err1: any) {
866
+ console.error('addPictures err1:');
867
+ console.error(err1);
868
+ retValue = buildErrorResponse<AddValuesResponse>(err1);
869
+ }
870
+ console.log('retValue:');
871
+ console.log(JSON.stringify(retValue, null, 2));
872
+ return retValue;
873
+ }
874
+
875
+ public async editAlbumsPictures(dto: UploadAlbumsPicturesDto): Promise<ITypedBackendResponse<Album>> {
876
+ console.log('HEADERS:');
877
+ console.log(JSON.stringify(this.headers, null, 2));
878
+ let retValue: ITypedBackendResponse<Album> = {};
879
+ try {
880
+ const response: any = await this.sdk.EditAlbumsPictures({ input: dto });
881
+ console.log('editAlbum Response:');
882
+ console.log(JSON.stringify(response, null, 2));
883
+ retValue = buildResponse<Album>(response, 'editAlbum',
884
+ (r: any) => !!r?.editAlbum?.label
885
+ );
886
+ } catch (err1: any) {
887
+ console.error('editAlbum err1:');
888
+ console.error(err1);
889
+ retValue = buildErrorResponse<Album>(err1);
890
+ }
891
+ console.log('retValue:');
892
+ console.log(JSON.stringify(retValue, null, 2));
893
+ return retValue;
894
+ }
895
+
896
+ public async createAthleteAlbum(dto: UploadAlbumsPicturesDto): Promise<ITypedBackendResponse<Album>> {
897
+ console.log('HEADERS:');
898
+ console.log(JSON.stringify(this.headers, null, 2));
899
+ let retValue: ITypedBackendResponse<Album> = {};
900
+ try {
901
+ const response: any = await this.sdk.CreateAthleteAlbum({ input: dto });
902
+ console.log('createAthleteAlbum Response:');
903
+ console.log(JSON.stringify(response, null, 2));
904
+ retValue = buildResponse<Album>(response, 'createAthleteAlbum',
905
+ (r: any) => !!r?.createAthleteAlbum?.label
906
+ );
907
+ } catch (err1: any) {
908
+ console.error('createAthleteAlbum err1:');
909
+ console.error(err1);
910
+ retValue = buildErrorResponse<Album>(err1);
911
+ }
912
+ console.log('retValue:');
913
+ console.log(JSON.stringify(retValue, null, 2));
914
+ return retValue;
915
+ }
916
+
917
+ public async deleteFundingCampaign(dto: DeleteSingleValueDto): Promise<ITypedBackendResponse<DeleteSingleValueResponse>> {
918
+ return this.execute<DeleteSingleValueResponse>(
919
+ () => this.sdk.DeleteFundingCampaign({ input: dto }),
920
+ 'deleteFundingCampaign',
921
+ (r) => !!r?.deleteFundingCampaign?.deleted,
922
+ 'deleteFundingCampaign'
923
+ );
924
+ }
925
+
926
+ public async deleteFundingCampaigns(dto: DeleteValuesDto): Promise<ITypedBackendResponse<DeleteValuesResponse>> {
927
+ return this.execute<DeleteValuesResponse>(
928
+ () => this.sdk.DeleteFundingCampaigns({ input: dto }),
929
+ 'deleteFundingCampaigns',
930
+ (r) => !!r?.deleteFundingCampaigns,
931
+ 'deleteFundingCampaigns'
932
+ );
933
+ }
934
+
935
+ public async updateFundingCampaign(dto: UpdateFundingCampaignDto): Promise<ITypedBackendResponse<FundRaisingCampaign>> {
936
+ return this.execute<FundRaisingCampaign>(
937
+ () => this.sdk.UpdateFundingCampaign({ input: dto }),
938
+ 'updateFundingCampaign',
939
+ (r) => !!r?.updateFundingCampaign?._id,
940
+ 'updateFundingCampaign'
941
+ );
942
+ }
943
+
944
+ public async setCurrentCampaign(dto: SetCurrentCampaignDto): Promise<ITypedBackendResponse<FundRaisingCampaign>> {
945
+ return this.execute<FundRaisingCampaign>(
946
+ () => this.sdk.SetCurrentCampaign({ input: dto }),
947
+ 'setCurrentCampaign',
948
+ (r) => !!r?.setCurrentCampaign?._id,
949
+ 'setCurrentCampaign'
950
+ );
951
+ }
952
+
953
+ public async deleteAthleteAlbum(dto: DeleteSingleValueDto): Promise<ITypedBackendResponse<DeleteSingleValueResponse>> {
954
+ return this.execute<DeleteSingleValueResponse>(
955
+ () => this.sdk.DeleteAthleteAlbum({ input: dto }),
956
+ 'deleteAthleteAlbum',
957
+ (r) => !!r?.deleteAthleteAlbum?.deleted,
958
+ 'deleteAthleteAlbum'
959
+ );
960
+ }
961
+
962
+ public async getAthleteAlbums(): Promise<ITypedBackendResponse<Album[]>> {
963
+ return this.execute<Album[]>(
964
+ () => this.sdk.GetAthleteAlbums(),
965
+ 'getAthleteAlbums',
966
+ (r) => Array.isArray(r?.getAthleteAlbums),
967
+ 'getAthleteAlbums'
968
+ );
969
+ }
970
+
971
+ public async reorderAlbums(dto: EditDisplayIndexDto): Promise<ITypedBackendResponse<Album[]>> {
972
+ return this.execute<Album[]>(
973
+ () => this.sdk.ReorderAlbums({ input: dto }),
974
+ 'reorderAlbumIndex',
975
+ (r) => r?.reorderAlbumIndex?.length > 0,
976
+ 'reorderAlbumIndex'
977
+ );
978
+ }
979
+
980
+ public async getPublicAthleteAlbums(athleteId: string): Promise<ITypedBackendResponse<Album[]>> {
981
+ return this.execute<Album[]>(
982
+ () => this.sdk.GetPublicAthleteAlbums({ athleteId }),
983
+ 'getPublicAthleteAlbums',
984
+ (r) => r?.getPublicAthleteAlbums?.length > 0,
985
+ 'getPublicAthleteAlbums'
986
+ );
987
+ }
988
+
989
+ public async getAthleteAlbumsById(albumId: string): Promise<ITypedBackendResponse<Album>> {
990
+ return this.execute<Album>(
991
+ () => this.sdk.GetAthleteAlbumsById({ input: albumId }),
992
+ 'getAthleteAlbumId',
993
+ (r) => !!r?.getAthleteAlbumId?._id,
994
+ 'getAthleteAlbumId'
995
+ );
996
+ }
997
+
998
+ public async getAndSetAlbumById(albumId: string): Promise<ITypedBackendResponse<Album>> {
999
+ return this.execute<Album>(
1000
+ () => this.sdk.GetAndSetAlbumById({ input: albumId }),
1001
+ 'getAndSetAlbumById',
1002
+ (r) => !!r?.getAndSetAlbumById?._id,
1003
+ 'getAndSetAlbumById'
1004
+ );
1005
+ }
1006
+
1007
+ public async queryAthletesWithFilters(dto: AthleteQueryDto): Promise<ITypedBackendResponse<AthleteQueryResponse>> {
1008
+ return this.execute<AthleteQueryResponse>(
1009
+ () => this.sdk.QueryAthletesWithFilters({ input: dto }),
1010
+ 'queryAthletesWithFilters',
1011
+ (r) => !!r?.queryAthletesWithFilters,
1012
+ 'queryAthletesWithFilters'
1013
+ );
1014
+ }
1015
+
1016
+ // ============= INTEGRATION METHODS =============
1017
+
1018
+ public async getAthleteIntegrationsByAthlete(): Promise<ITypedBackendResponse<AthleteIntegrationReference>> {
1019
+ return this.execute<AthleteIntegrationReference>(
1020
+ () => this.sdk.GetAthleteIntegrationsByAthlete(),
1021
+ 'getAthleteIntegrationsByAthlete',
1022
+ (r) => !!r?.getAthleteIntegrationsByAthlete,
1023
+ 'getAthleteIntegrationsByAthlete'
1024
+ );
1025
+ }
1026
+
1027
+ public async deleteAthleteIntegration(): Promise<ITypedBackendResponse<boolean>> {
1028
+ // NOTE: This method is commented out in the old vtx-base-api.ts and excluded from integrations.graphql
1029
+ return { error: { httpStatus: 501, code: 0, message: 'deleteAthleteIntegration not implemented' } };
1030
+ }
1031
+
1032
+ public async getAthleteStravaIntegration(): Promise<ITypedBackendResponse<AthleteIntegrationReference>> {
1033
+ return this.execute<AthleteIntegrationReference>(
1034
+ () => this.sdk.GetAthleteStravaIntegration(),
1035
+ 'getAthleteStravaIntegration',
1036
+ (r) => !!r?.getAthleteStravaIntegration,
1037
+ 'getAthleteStravaIntegration'
1038
+ );
1039
+ }
1040
+
1041
+ public async getAthleteInstagramIntegration(): Promise<ITypedBackendResponse<AthleteIntegrationReference>> {
1042
+ return this.execute<AthleteIntegrationReference>(
1043
+ () => this.sdk.GetAthleteInstagramIntegration(),
1044
+ 'getAthleteInstagramIntegration',
1045
+ (r) => !!r?.getAthleteInstagramIntegration,
1046
+ 'getAthleteInstagramIntegration'
1047
+ );
1048
+ }
1049
+
1050
+ public async getReceipt(dto: GetReceiptDto): Promise<ITypedBackendResponse<Receipt>> {
1051
+ return this.execute<Receipt>(
1052
+ () => this.sdk.GetReceipt({ input: dto }),
1053
+ 'getReceipt',
1054
+ (r) => !!r?.getReceipt?._id,
1055
+ 'getReceipt'
1056
+ );
1057
+ }
1058
+
1059
+ public async getAthleteIntegrations(): Promise<ITypedBackendResponse<AthleteIntegrationReference>> {
1060
+ return this.execute<AthleteIntegrationReference>(
1061
+ () => this.sdk.GetAthleteIntegrations(),
1062
+ 'getAthleteIntegrations',
1063
+ (r) => !!r?.getAthleteIntegrations,
1064
+ 'getAthleteIntegrations'
1065
+ );
1066
+ }
1067
+
1068
+ public async getAthleteCampaigns(dto: GetAthleteCampaignsDto): Promise<ITypedBackendResponse<FundRaisingCampaign[]>> {
1069
+ return this.execute<FundRaisingCampaign[]>(
1070
+ () => this.sdk.GetAthleteCampaigns({ input: dto }),
1071
+ 'getAthleteCampaigns',
1072
+ (r) => Array.isArray(r?.getAthleteCampaigns),
1073
+ 'getAthleteCampaigns'
1074
+ );
1075
+ }
1076
+
1077
+ public async browseCampaigns(dto: BrowseCampaignsDto): Promise<ITypedBackendResponse<BrowseCampaignsResult>> {
1078
+ return this.execute<BrowseCampaignsResult>(
1079
+ () => this.sdk.BrowseCampaigns({ input: dto }),
1080
+ 'browseCampaigns',
1081
+ (r) => !!r?.browseCampaigns,
1082
+ 'browseCampaigns'
1083
+ );
1084
+ }
1085
+
1086
+ public async updateAthleteIntegration(type: string): Promise<ITypedBackendResponse<boolean>> {
1087
+ return this.execute<boolean>(
1088
+ () => this.sdk.UpdateAthleteIntegration({ type }),
1089
+ 'updateAthleteIntegration',
1090
+ (r) => r?.updateAthleteIntegration === true,
1091
+ 'updateAthleteIntegration'
1092
+ );
1093
+ }
1094
+
1095
+ public async deleteUploadedTypeKeyFile(dto: AWSS3DeleteUseTypeKeyDto): Promise<ITypedBackendResponse<AWSS3CallResult>> {
1096
+ return this.execute<AWSS3CallResult>(
1097
+ () => this.sdk.DeleteUploadedTypeKeyFile({ input: dto }),
1098
+ 'deleteUploadedTypeKeyFile',
1099
+ (r) => !!r?.deleteUploadedTypeKeyFile?.httpStatus,
1100
+ 'deleteUploadedTypeKeyFile'
1101
+ );
1102
+ }
1103
+
1104
+ public async saveAthleteCompetitionResult(dto: SetCompetitionResultDto): Promise<ITypedBackendResponse<AthleteCompetitionResult>> {
1105
+ return this.execute<AthleteCompetitionResult>(
1106
+ () => this.sdk.SaveAthleteCompetitionResult({ input: dto }),
1107
+ 'saveAthleteCompetitionResult',
1108
+ (r) => !!r?.saveAthleteCompetitionResult?._id,
1109
+ 'saveAthleteCompetitionResult'
1110
+ );
1111
+ }
1112
+
1113
+ // ============= SCORE METHODS =============
1114
+
1115
+ public async updateAthleteScores(): Promise<ITypedBackendResponse<Athlete>> {
1116
+ return this.execute<Athlete>(
1117
+ () => this.sdk.UpdateAthleteScores(),
1118
+ 'updateAthleteScores',
1119
+ (r) => !!r?.updateAthleteScores?._id,
1120
+ 'updateAthleteScores'
1121
+ );
1122
+ }
1123
+
1124
+ public async updateAthleteCompetitionScores(): Promise<ITypedBackendResponse<Athlete>> {
1125
+ return this.execute<Athlete>(
1126
+ () => this.sdk.UpdateAthleteCompetitionScores(),
1127
+ 'updateAthleteCompetitionScores',
1128
+ (r) => !!r?.updateAthleteCompetitionScores?._id,
1129
+ 'updateAthleteCompetitionScores'
1130
+ );
1131
+ }
1132
+
1133
+ public async forceRefreshAthleteScores(
1134
+ athleteIds: string[],
1135
+ options?: { rebuildHistorical?: boolean; historicalDays?: number }
1136
+ ): Promise<ITypedBackendResponse<ForceScoreRefreshResponse>> {
1137
+ return this.execute<ForceScoreRefreshResponse>(
1138
+ () => this.sdk.ForceRefreshAthleteScores({ input: { athleteIds } }),
1139
+ 'forceRefreshAthleteScores',
1140
+ (r) => !!r?.forceRefreshAthleteScores,
1141
+ 'forceRefreshAthleteScores'
1142
+ );
1143
+ }
1144
+
1145
+ public async checkScoreRefreshCapabilities(input: { athleteIds: string[] }): Promise<ITypedBackendResponse<any>> {
1146
+ return this.execute<any>(
1147
+ () => this.sdk.CheckScoreRefreshCapabilities({ input }),
1148
+ 'checkScoreRefreshCapabilities',
1149
+ (r) => !!r?.checkScoreRefreshCapabilities,
1150
+ 'checkScoreRefreshCapabilities'
1151
+ );
1152
+ }
1153
+
1154
+ // ============= PASSWORD / VERIFICATION METHODS =============
1155
+
1156
+ public async createResetPasswordCode(email: string): Promise<ITypedBackendResponse<EditValueResponse>> {
1157
+ return this.execute<EditValueResponse>(
1158
+ () => this.sdk.CreateResetPasswordCode({ input: email }),
1159
+ 'createResetPasswordCode',
1160
+ (r) => r?.createResetPasswordCode?.field !== null,
1161
+ 'createResetPasswordCode'
1162
+ );
1163
+ }
1164
+
1165
+ public async getResetVerificationCode(id: string): Promise<ITypedBackendResponse<VerificationCodeType>> {
1166
+ return this.execute<VerificationCodeType>(
1167
+ () => this.sdk.GetResetVerificationCode({ input: id }),
1168
+ 'getResetVerificationCode',
1169
+ (r) => !!r?.getResetVerificationCode?.changed,
1170
+ 'getResetVerificationCode'
1171
+ );
1172
+ }
1173
+
1174
+ public async verifyCode(input: VerifyCodeDto): Promise<ITypedBackendResponse<CodeVerificationResponse>> {
1175
+ return this.execute<CodeVerificationResponse>(
1176
+ () => this.sdk.VerifyCode({ input }),
1177
+ 'verifyCode',
1178
+ (r) => r?.verifyCode?.result === 'success' || r?.verifyCode?.result === 'error',
1179
+ 'verifyCode'
1180
+ );
1181
+ }
1182
+
1183
+ public async resetUserPassword(input: resetPasswordDto): Promise<ITypedBackendResponse<EditValueResponse>> {
1184
+ return this.execute<EditValueResponse>(
1185
+ () => this.sdk.ResetUserPassword({ input }),
1186
+ 'resetUserPassword',
1187
+ (r) => r?.resetUserPassword?.field !== null,
1188
+ 'resetUserPassword'
1189
+ );
1190
+ }
1191
+
1192
+ public async deleteAlbumFotos(dto: DeleteValuesDto): Promise<ITypedBackendResponse<DeleteSingleValueResponse>> {
1193
+ return this.execute<DeleteSingleValueResponse>(
1194
+ () => this.sdk.DeleteAlbumFotos({ input: dto }),
1195
+ 'deleteAlbumFotos',
1196
+ (r) => !!r?.deleteAlbumFotos?.deleted,
1197
+ 'deleteAlbumFotos'
1198
+ );
1199
+ }
1200
+
1201
+ public async screenNameAviability(dto: existValueDto): Promise<ITypedBackendResponse<ExistValueResponse>> {
1202
+ return this.execute<ExistValueResponse>(
1203
+ () => this.sdk.ScreenNameAvailability({ input: dto }),
1204
+ 'screenNameAviability',
1205
+ (r) => r?.screenNameAviability !== undefined,
1206
+ 'screenNameAviability'
1207
+ );
1208
+ }
1209
+
1210
+ // ============= BUDGET METHODS =============
1211
+
1212
+ public async getBudgetsByAthlete(): Promise<ITypedBackendResponse<BudgetData>> {
1213
+ return this.execute<BudgetData>(
1214
+ () => this.sdk.GetBudgetsByAthlete(),
1215
+ 'getBudgetsByAthlete',
1216
+ (r) => !!r?.getBudgetsByAthlete,
1217
+ 'getBudgetsByAthlete'
1218
+ );
1219
+ }
1220
+
1221
+ public async deleteCompetitionBudget(competitionId: string): Promise<ITypedBackendResponse<Boolean>> {
1222
+ return this.execute<Boolean>(
1223
+ () => this.sdk.DeleteCompetitionBudget({ competitionId }),
1224
+ 'deleteCompetitionBudget',
1225
+ (r) => r?.deleteCompetitionBudget !== undefined,
1226
+ 'deleteCompetitionBudget'
1227
+ );
1228
+ }
1229
+
1230
+ public async addCompetitionBudget(input: AddCompetitionBudgetDto): Promise<ITypedBackendResponse<Boolean>> {
1231
+ return this.execute<Boolean>(
1232
+ () => this.sdk.AddCompetitionBudget({ input }),
1233
+ 'addCompetitionBudget',
1234
+ (r) => r?.addCompetitionBudget !== undefined,
1235
+ 'addCompetitionBudget'
1236
+ );
1237
+ }
1238
+
1239
+ public async editCompetitionBudget(input: EditCompetitionBudgetDto): Promise<ITypedBackendResponse<Boolean>> {
1240
+ return this.execute<Boolean>(
1241
+ () => this.sdk.EditCompetitionBudget({ input }),
1242
+ 'editCompetitionBudget',
1243
+ (r) => r?.editCompetitionBudget !== undefined,
1244
+ 'editCompetitionBudget'
1245
+ );
1246
+ }
1247
+
1248
+ public async editCampaignBudget(input: EditCampaignBudgetDto): Promise<ITypedBackendResponse<Boolean>> {
1249
+ return this.execute<Boolean>(
1250
+ () => this.sdk.EditCampaignBudget({ input }),
1251
+ 'editCampaignBudget',
1252
+ (r) => r?.editCampaignBudget !== undefined,
1253
+ 'editCampaignBudget'
1254
+ );
1255
+ }
1256
+
1257
+ public async editCompetitionBudgetForCampaign(input: EditCampaignBudgetDto): Promise<ITypedBackendResponse<Boolean>> {
1258
+ return this.execute<Boolean>(
1259
+ () => this.sdk.EditCompetitionBudgetForCampaign({ input }),
1260
+ 'editCompetitionBudgetForCampaign',
1261
+ (r) => r?.editCompetitionBudgetForCampaign !== undefined,
1262
+ 'editCompetitionBudgetForCampaign'
1263
+ );
1264
+ }
1265
+
1266
+ // ============= DONATION METHODS =============
1267
+
1268
+ public async getDonationsByAthlete(): Promise<ITypedBackendResponse<Receipt[]>> {
1269
+ return this.execute<Receipt[]>(
1270
+ () => this.sdk.GetDonationsByAthlete(),
1271
+ 'getDonationsByAthlete',
1272
+ (r) => Array.isArray(r?.getDonationsByAthlete),
1273
+ 'getDonationsByAthlete'
1274
+ );
1275
+ }
1276
+
1277
+ public async getDonationsByMember(): Promise<ITypedBackendResponse<Donation[]>> {
1278
+ return this.execute<Donation[]>(
1279
+ () => this.sdk.GetDonationsByMember(),
1280
+ 'getDonationsByMember',
1281
+ (r) => Array.isArray(r?.getDonationsByMember),
1282
+ 'getDonationsByMember'
1283
+ );
1284
+ }
1285
+
1286
+ public async findMemberForUser(loginEmail: string): Promise<ITypedBackendResponse<Member>> {
1287
+ return this.execute<Member>(
1288
+ () => this.sdk.FindMemberForUser({ loginEmail }),
1289
+ 'findMemberForUser',
1290
+ (r) => !!r?.findMemberForUser?._id,
1291
+ 'findMemberForUser'
1292
+ );
1293
+ }
1294
+
1295
+ public async getBudgetConcepts(): Promise<ITypedBackendResponse<BudgetConcept[]>> {
1296
+ return this.execute<BudgetConcept[]>(
1297
+ () => this.sdk.GetBudgetConcepts(),
1298
+ 'getBudgetConcepts',
1299
+ (r) => Array.isArray(r?.getBudgetConcepts),
1300
+ 'getBudgetConcepts'
1301
+ );
1302
+ }
1303
+
1304
+ public async getBudgetItemsUnits(): Promise<ITypedBackendResponse<BudgetItemUnit[]>> {
1305
+ return this.execute<BudgetItemUnit[]>(
1306
+ () => this.sdk.GetBudgetItemsUnits(),
1307
+ 'getBudgetItemsUnits',
1308
+ (r) => Array.isArray(r?.getBudgetItemsUnits),
1309
+ 'getBudgetItemsUnits'
1310
+ );
1311
+ }
1312
+
1313
+ public async verifyAthleteCompetitionLinkedForDelete(dto: existValueDto): Promise<ITypedBackendResponse<CompetitionDeleteVerificationResponse>> {
1314
+ return this.execute<CompetitionDeleteVerificationResponse>(
1315
+ () => this.sdk.VerifyAthleteCompetitionLinkedForDelete({ input: dto }),
1316
+ 'verifyAthleteCompetitionLinkedForDelete',
1317
+ (r) => r?.verifyAthleteCompetitionLinkedForDelete !== undefined,
1318
+ 'verifyAthleteCompetitionLinkedForDelete'
1319
+ );
1320
+ }
1321
+
1322
+ public async forceDeleteAthleteCompetition(dto: DeleteSingleValueDto): Promise<ITypedBackendResponse<DeleteSingleValueResponse>> {
1323
+ return this.execute<DeleteSingleValueResponse>(
1324
+ () => this.sdk.ForceDeleteAthleteCompetition({ input: dto }),
1325
+ 'forceDeleteAthleteCompetition',
1326
+ (r) => !!r?.forceDeleteAthleteCompetition?.idToDelete,
1327
+ 'forceDeleteAthleteCompetition'
1328
+ );
1329
+ }
1330
+
1331
+ public async registerUser(input: RegisterUserDto): Promise<ITypedBackendResponse<User>> {
1332
+ return this.execute<User>(
1333
+ () => this.sdk.RegisterUser({ input }),
1334
+ 'registerUser',
1335
+ (r) => !!r?.registerUser?._id,
1336
+ 'registerUser'
1337
+ );
1338
+ }
1339
+
1340
+ public async getDonationsToAthlete(athleteId: string): Promise<ITypedBackendResponse<Donation[]>> {
1341
+ return this.execute<Donation[]>(
1342
+ () => this.sdk.GetDonationsToAthlete({ athleteId }),
1343
+ 'getDonationsToAthlete',
1344
+ (r) => Array.isArray(r?.getDonationsToAthlete),
1345
+ 'getDonationsToAthlete'
1346
+ );
1347
+ }
1348
+
1349
+ public async getDonationsToMe(): Promise<ITypedBackendResponse<Donation[]>> {
1350
+ return this.execute<Donation[]>(
1351
+ () => this.sdk.GetDonationsToMe(),
1352
+ 'getDonationsToMe',
1353
+ (r) => Array.isArray(r?.getDonationsToMe),
1354
+ 'getDonationsToMe'
1355
+ );
1356
+ }
1357
+
1358
+ public async getDonationDatesForCalendar(campaignId?: string): Promise<ITypedBackendResponse<DonationDates>> {
1359
+ return this.execute<DonationDates>(
1360
+ () => this.sdk.GetDonationDatesForCalendar({ campaignId }),
1361
+ 'getDonationDatesForCalendar',
1362
+ (r) => !!r?.getDonationDatesForCalendar,
1363
+ 'getDonationDatesForCalendar'
1364
+ );
1365
+ }
1366
+
1367
+ public async getDonationsPaginated(query?: DonationQueryDto): Promise<ITypedBackendResponse<PaginatedDonations>> {
1368
+ return this.execute<PaginatedDonations>(
1369
+ () => this.sdk.GetDonationsPaginated({ query }),
1370
+ 'getDonationsPaginated',
1371
+ (r) => !!r?.getDonationsPaginated,
1372
+ 'getDonationsPaginated'
1373
+ );
1374
+ }
1375
+
1376
+ // ============= HISTORICAL SCORE METHODS =============
1377
+
1378
+ public async getAthleteHistoricalScores(dto: GetHistoricalScoresDto): Promise<ITypedBackendResponse<HistoricalScore[]>> {
1379
+ return this.execute<HistoricalScore[]>(
1380
+ () => this.sdk.GetAthleteHistoricalScores({ input: dto }),
1381
+ 'getAthleteHistoricalScores',
1382
+ (r) => Array.isArray(r?.getAthleteHistoricalScores),
1383
+ 'getAthleteHistoricalScores'
1384
+ );
1385
+ }
1386
+
1387
+ public async getMyHistoricalScores(dto: GetMyHistoricalScoresDto): Promise<ITypedBackendResponse<HistoricalScore[]>> {
1388
+ return this.execute<HistoricalScore[]>(
1389
+ () => this.sdk.GetMyHistoricalScores({ input: dto }),
1390
+ 'getMyHistoricalScores',
1391
+ (r) => Array.isArray(r?.getMyHistoricalScores),
1392
+ 'getMyHistoricalScores'
1393
+ );
1394
+ }
1395
+
1396
+ public async getAthleteHistoricalScoresPeriod(dto: GetHistoricalScoresDto): Promise<ITypedBackendResponse<HistoricalScoresPeriod>> {
1397
+ return this.execute<HistoricalScoresPeriod>(
1398
+ () => this.sdk.GetAthleteHistoricalScoresPeriod({ input: dto }),
1399
+ 'getAthleteHistoricalScoresPeriod',
1400
+ (r) => !!r?.getAthleteHistoricalScoresPeriod,
1401
+ 'getAthleteHistoricalScoresPeriod'
1402
+ );
1403
+ }
1404
+
1405
+ public async getMyHistoricalScoresPeriod(dto: GetMyHistoricalScoresDto): Promise<ITypedBackendResponse<HistoricalScoresPeriod>> {
1406
+ return this.execute<HistoricalScoresPeriod>(
1407
+ () => this.sdk.GetMyHistoricalScoresPeriod({ input: dto }),
1408
+ 'getMyHistoricalScoresPeriod',
1409
+ (r) => !!r?.getMyHistoricalScoresPeriod,
1410
+ 'getMyHistoricalScoresPeriod'
1411
+ );
1412
+ }
1413
+
1414
+ // ============= ADMIN METHODS =============
1415
+
1416
+ public async getTransactionDetails(dto: GetTransactionDetailsDto): Promise<ITypedBackendResponse<TransactionDetails>> {
1417
+ return this.execute<TransactionDetails>(
1418
+ () => this.sdk.GetTransactionDetails({ input: dto }),
1419
+ 'getTransactionDetails',
1420
+ (r) => !!r?.getTransactionDetails,
1421
+ 'getTransactionDetails'
1422
+ );
1423
+ }
1424
+
1425
+ public async getAllUsers(): Promise<ITypedBackendResponse<AdminUserView[]>> {
1426
+ return this.execute<AdminUserView[]>(
1427
+ () => this.sdk.GetAllUsers(),
1428
+ 'getAllUsers',
1429
+ (r) => Array.isArray(r?.getAllUsers),
1430
+ 'getAllUsers'
1431
+ );
1432
+ }
1433
+
1434
+ public async getAllTransactions(): Promise<ITypedBackendResponse<AdminTransactionView[]>> {
1435
+ return this.execute<AdminTransactionView[]>(
1436
+ () => this.sdk.GetAllTransactions(),
1437
+ 'getAllTransactions',
1438
+ (r) => Array.isArray(r?.getAllTransactions),
1439
+ 'getAllTransactions'
1440
+ );
1441
+ }
1442
+
1443
+ public async getTransactionsPaginated(args: { query?: TransactionQueryDto } = {}): Promise<ITypedBackendResponse<PaginatedTransactions>> {
1444
+ return this.execute<PaginatedTransactions>(
1445
+ () => this.sdk.GetTransactionsPaginated({ query: args.query }),
1446
+ 'getTransactionsPaginated',
1447
+ (r) => true,
1448
+ 'getTransactionsPaginated'
1449
+ );
1450
+ }
1451
+
1452
+ public async getUsersPaginated(args: { query: UserQueryDto }): Promise<ITypedBackendResponse<PaginatedUsers>> {
1453
+ return this.execute<PaginatedUsers>(
1454
+ () => this.sdk.GetUsersPaginated({ query: args.query }),
1455
+ 'getUsersPaginated',
1456
+ (r) => true,
1457
+ 'getUsersPaginated'
1458
+ );
1459
+ }
1460
+
1461
+ public async updateUserSuspendedStatus(dto: UpdateUserSuspendedStatusDto): Promise<ITypedBackendResponse<EditValueResponse>> {
1462
+ return this.execute<EditValueResponse>(
1463
+ () => this.sdk.UpdateUserSuspendedStatus({ input: dto }),
1464
+ 'updateUserSuspendedStatus',
1465
+ (r) => r?.updateUserSuspendedStatus?.field !== null,
1466
+ 'updateUserSuspendedStatus'
1467
+ );
1468
+ }
1469
+
1470
+ public async deleteVtxUser(dto: DeleteVtxUserDto): Promise<ITypedBackendResponse<DeleteVtxUserResponse>> {
1471
+ return this.execute<DeleteVtxUserResponse>(
1472
+ () => this.sdk.DeleteVtxUser({ input: dto }),
1473
+ 'deleteVtxUser',
1474
+ (r) => r?.deleteVtxUser?.success !== undefined,
1475
+ 'deleteVtxUser'
1476
+ );
1477
+ }
1478
+
1479
+ public async deleteMyAccount(): Promise<ITypedBackendResponse<DeleteVtxUserResponse>> {
1480
+ return this.execute<DeleteVtxUserResponse>(
1481
+ () => this.sdk.DeleteMyAccount(),
1482
+ 'deleteMyAccount',
1483
+ (r) => r?.deleteMyAccount?.success !== undefined,
1484
+ 'deleteMyAccount'
1485
+ );
1486
+ }
1487
+
1488
+ // ============= OFFER METHODS =============
1489
+
1490
+ public async createOffer(dto: CreateOfferDto): Promise<ITypedBackendResponse<Offer>> {
1491
+ return this.execute<Offer>(
1492
+ () => this.sdk.CreateOffer({ input: dto }),
1493
+ 'createOffer',
1494
+ (r) => !!r?.createOffer?._id,
1495
+ 'createOffer'
1496
+ );
1497
+ }
1498
+
1499
+ public async getOffers(): Promise<ITypedBackendResponse<Offer[]>> {
1500
+ return this.execute<Offer[]>(
1501
+ () => this.sdk.GetOffers(),
1502
+ 'getOffers',
1503
+ (r) => Array.isArray(r?.getOffers),
1504
+ 'getOffers'
1505
+ );
1506
+ }
1507
+
1508
+ public async getOffersPaginated(args: { query: OfferQueryDto }): Promise<ITypedBackendResponse<PaginatedOffers>> {
1509
+ return this.execute<PaginatedOffers>(
1510
+ () => this.sdk.GetOffersPaginated({ query: args.query }),
1511
+ 'getOffersPaginated',
1512
+ (r) => true,
1513
+ 'getOffersPaginated'
1514
+ );
1515
+ }
1516
+
1517
+ public async getOffersWithEligibility(args: { query?: OfferQueryDto }): Promise<ITypedBackendResponse<PaginatedOffersWithEligibility>> {
1518
+ return this.execute<PaginatedOffersWithEligibility>(
1519
+ () => this.sdk.OffersWithEligibility({ query: args.query }),
1520
+ 'offersWithEligibility',
1521
+ (r) => true,
1522
+ 'offersWithEligibility'
1523
+ );
1524
+ }
1525
+
1526
+ public async getOfferById(id: string): Promise<ITypedBackendResponse<Offer>> {
1527
+ return this.execute<Offer>(
1528
+ () => this.sdk.GetOfferById({ id }),
1529
+ 'getOfferById',
1530
+ (r) => !!r?.getOfferById?._id,
1531
+ 'getOfferById'
1532
+ );
1533
+ }
1534
+
1535
+ public async getOffersForAthlete(athleteId: string | null): Promise<ITypedBackendResponse<Offer[]>> {
1536
+ return this.execute<Offer[]>(
1537
+ () => this.sdk.GetOffersForAthlete({ athleteId }),
1538
+ 'getOffersForAthlete',
1539
+ (r) => Array.isArray(r?.getOffersForAthlete),
1540
+ 'getOffersForAthlete'
1541
+ );
1542
+ }
1543
+
1544
+ public async updateOffer(id: string, dto: CreateOfferDto): Promise<ITypedBackendResponse<Offer>> {
1545
+ return this.execute<Offer>(
1546
+ () => this.sdk.UpdateOffer({ id, input: dto }),
1547
+ 'updateOffer',
1548
+ (r) => !!r?.updateOffer?._id,
1549
+ 'updateOffer'
1550
+ );
1551
+ }
1552
+
1553
+ public async deleteOffer(id: string): Promise<ITypedBackendResponse<boolean>> {
1554
+ return this.execute<boolean>(
1555
+ () => this.sdk.DeleteOffer({ id }),
1556
+ 'deleteOffer',
1557
+ (r) => r?.deleteOffer === true,
1558
+ 'deleteOffer'
1559
+ );
1560
+ }
1561
+
1562
+ public async setOfferStatus(id: string, status: string): Promise<ITypedBackendResponse<Offer>> {
1563
+ return this.execute<Offer>(
1564
+ () => this.sdk.SetOfferStatus({ id, status }),
1565
+ 'setOfferStatus',
1566
+ (r) => !!r?.setOfferStatus?._id,
1567
+ 'setOfferStatus'
1568
+ );
1569
+ }
1570
+
1571
+ public async activateOffer(id: string): Promise<ITypedBackendResponse<Offer>> {
1572
+ return this.execute<Offer>(
1573
+ () => this.sdk.ActivateOffer({ id }),
1574
+ 'activateOffer',
1575
+ (r) => !!r?.activateOffer?._id,
1576
+ 'activateOffer'
1577
+ );
1578
+ }
1579
+
1580
+ public async deactivateOffer(id: string): Promise<ITypedBackendResponse<Offer>> {
1581
+ return this.execute<Offer>(
1582
+ () => this.sdk.DeactivateOffer({ id }),
1583
+ 'deactivateOffer',
1584
+ (r) => !!r?.deactivateOffer?._id,
1585
+ 'deactivateOffer'
1586
+ );
1587
+ }
1588
+
1589
+ public async uploadCouponCodes(offerId: string, csvContent: string): Promise<ITypedBackendResponse<UploadResult>> {
1590
+ return this.execute<UploadResult>(
1591
+ () => this.sdk.UploadCouponCodes({ offerId, csvContent }),
1592
+ 'uploadCouponCodes',
1593
+ (r) => !!r?.uploadCouponCodes,
1594
+ 'uploadCouponCodes'
1595
+ );
1596
+ }
1597
+
1598
+ public async claimOffer(offerId: string, athleteId: string): Promise<ITypedBackendResponse<OfferClaim>> {
1599
+ return this.execute<OfferClaim>(
1600
+ () => this.sdk.ClaimOffer({ offerId, athleteId }),
1601
+ 'claimOffer',
1602
+ (r) => !!r?.claimOffer?._id,
1603
+ 'claimOffer'
1604
+ );
1605
+ }
1606
+
1607
+ public async getMyOfferClaims(args: { athleteId: string, query?: OfferClaimQueryDto }): Promise<ITypedBackendResponse<OfferClaim[]>> {
1608
+ return this.execute<OfferClaim[]>(
1609
+ () => this.sdk.GetMyOfferClaims({ athleteId: args.athleteId, query: args.query }),
1610
+ 'getMyOfferClaims',
1611
+ (r) => Array.isArray(r?.getMyOfferClaims),
1612
+ 'getMyOfferClaims'
1613
+ );
1614
+ }
1615
+
1616
+ public async removeOfferClaim(claimId: string, athleteId: string): Promise<ITypedBackendResponse<boolean>> {
1617
+ return this.execute<boolean>(
1618
+ () => this.sdk.RemoveOfferClaim({ claimId, athleteId }),
1619
+ 'removeOfferClaim',
1620
+ (r) => r?.removeOfferClaim === true,
1621
+ 'removeOfferClaim'
1622
+ );
1623
+ }
1624
+
1625
+ public async updateBrand(id: string, dto: CreateBrandDto): Promise<ITypedBackendResponse<Brand>> {
1626
+ return this.execute<Brand>(
1627
+ () => this.sdk.UpdateBrand({ id, input: dto }),
1628
+ 'updateBrand',
1629
+ (r) => !!r?.updateBrand?._id,
1630
+ 'updateBrand'
1631
+ );
1632
+ }
1633
+
1634
+ public async deleteBrand(id: string): Promise<ITypedBackendResponse<boolean>> {
1635
+ return this.execute<boolean>(
1636
+ () => this.sdk.DeleteBrand({ id }),
1637
+ 'deleteBrand',
1638
+ (r) => r?.deleteBrand === true,
1639
+ 'deleteBrand'
1640
+ );
1641
+ }
1642
+
1643
+ public async linkBrandToSponsor(brandId: string, sponsorId: string): Promise<ITypedBackendResponse<Brand>> {
1644
+ return this.execute<Brand>(
1645
+ () => this.sdk.LinkBrandToSponsor({ brandId, sponsorId }),
1646
+ 'linkBrandToSponsor',
1647
+ (r) => !!r?.linkBrandToSponsor?._id,
1648
+ 'linkBrandToSponsor'
1649
+ );
1650
+ }
1651
+
1652
+ public async unlinkBrandFromSponsor(brandId: string, sponsorId: string): Promise<ITypedBackendResponse<Brand>> {
1653
+ return this.execute<Brand>(
1654
+ () => this.sdk.UnlinkBrandFromSponsor({ brandId, sponsorId }),
1655
+ 'unlinkBrandFromSponsor',
1656
+ (r) => !!r?.unlinkBrandFromSponsor?._id,
1657
+ 'unlinkBrandFromSponsor'
1658
+ );
1659
+ }
1660
+
1661
+ // ============= SPONSOR METHODS =============
1662
+
1663
+ public async getSponsors(): Promise<ITypedBackendResponse<Sponsor[]>> {
1664
+ return this.execute<Sponsor[]>(
1665
+ () => this.sdk.GetSponsors(),
1666
+ 'getSponsors',
1667
+ (r) => Array.isArray(r?.getSponsors),
1668
+ 'getSponsors'
1669
+ );
1670
+ }
1671
+
1672
+ public async getSponsorsPaginated(args: { query: SponsorQueryDto }): Promise<ITypedBackendResponse<PaginatedSponsors>> {
1673
+ return this.execute<PaginatedSponsors>(
1674
+ () => this.sdk.GetSponsorsPaginated({ query: args.query }),
1675
+ 'getSponsorsPaginated',
1676
+ (r) => true,
1677
+ 'getSponsorsPaginated'
1678
+ );
1679
+ }
1680
+
1681
+ public async createSponsor(dto: CreateSponsorDto): Promise<ITypedBackendResponse<Sponsor>> {
1682
+ return this.execute<Sponsor>(
1683
+ () => this.sdk.CreateSponsor({ input: dto }),
1684
+ 'createSponsor',
1685
+ (r) => !!r?.createSponsor?._id,
1686
+ 'createSponsor'
1687
+ );
1688
+ }
1689
+
1690
+ public async updateSponsor(id: string, dto: CreateSponsorDto): Promise<ITypedBackendResponse<Sponsor>> {
1691
+ return this.execute<Sponsor>(
1692
+ () => this.sdk.UpdateSponsor({ id, input: dto as any }),
1693
+ 'updateSponsor',
1694
+ (r) => !!r?.updateSponsor?._id,
1695
+ 'updateSponsor'
1696
+ );
1697
+ }
1698
+
1699
+ public async deleteSponsor(id: string): Promise<ITypedBackendResponse<boolean>> {
1700
+ return this.execute<boolean>(
1701
+ () => this.sdk.DeleteSponsor({ id }),
1702
+ 'deleteSponsor',
1703
+ (r) => r?.deleteSponsor === true,
1704
+ 'deleteSponsor'
1705
+ );
1706
+ }
1707
+
1708
+ // ============= LEADERBOARD METHODS =============
1709
+
1710
+ public async getLeaderboard(args?: { input?: LeaderboardQueryDto }): Promise<ITypedBackendResponse<LeaderboardResponse>> {
1711
+ return this.execute<LeaderboardResponse>(
1712
+ () => this.sdk.GetLeaderboard({ input: args?.input }),
1713
+ 'getLeaderboard',
1714
+ (r) => !!r?.getLeaderboard,
1715
+ 'getLeaderboard'
1716
+ );
1717
+ }
1718
+
1719
+ public async getUserRank(args: { input: UserRankQueryDto }): Promise<ITypedBackendResponse<UserRank>> {
1720
+ return this.execute<UserRank>(
1721
+ () => this.sdk.GetUserRank({ input: args.input }),
1722
+ 'getUserRank',
1723
+ (r) => !!r?.getUserRank,
1724
+ 'getUserRank'
1725
+ );
1726
+ }
1727
+
1728
+ public async rebuildLeaderboardCache(): Promise<ITypedBackendResponse<boolean>> {
1729
+ return this.execute<boolean>(
1730
+ () => this.sdk.RebuildLeaderboardCache(),
1731
+ 'rebuildLeaderboardCache',
1732
+ (r) => r?.rebuildLeaderboardCache !== undefined,
1733
+ 'rebuildLeaderboardCache'
1734
+ );
1735
+ }
1736
+
1737
+ // ============= DASHBOARD / ANALYTICS METHODS =============
1738
+
1739
+ public async getAthleteDashboard(athleteId: string): Promise<ITypedBackendResponse<DashboardSummary>> {
1740
+ return this.execute<DashboardSummary>(
1741
+ () => this.sdk.GetAthleteDashboard({ athleteId }),
1742
+ 'athleteDashboard',
1743
+ (r) => !!r?.athleteDashboard,
1744
+ 'getAthleteDashboard'
1745
+ );
1746
+ }
1747
+
1748
+ public async getAthleteScoreHistory(args: { input: ScoreHistoryQueryDto }): Promise<ITypedBackendResponse<ScoreHistoryEntry[]>> {
1749
+ return this.execute<ScoreHistoryEntry[]>(
1750
+ () => this.sdk.GetAthleteScoreHistory({ input: args.input }),
1751
+ 'athleteScoreHistory',
1752
+ (r) => Array.isArray(r?.athleteScoreHistory),
1753
+ 'getAthleteScoreHistory'
1754
+ );
1755
+ }
1756
+
1757
+ public async getAthleteRankHistory(args: { input: RankHistoryQueryDto }): Promise<ITypedBackendResponse<RankHistoryEntry[]>> {
1758
+ return this.execute<RankHistoryEntry[]>(
1759
+ () => this.sdk.GetAthleteRankHistory({ input: args.input }),
1760
+ 'athleteRankHistory',
1761
+ (r) => Array.isArray(r?.athleteRankHistory),
1762
+ 'getAthleteRankHistory'
1763
+ );
1764
+ }
1765
+
1766
+ public async getAthleteRankContext(args: { input: RankContextQueryDto }): Promise<ITypedBackendResponse<RankContext>> {
1767
+ return this.execute<RankContext>(
1768
+ () => this.sdk.GetAthleteRankContext({ input: args.input }),
1769
+ 'athleteRankContext',
1770
+ (r) => !!r?.athleteRankContext,
1771
+ 'getAthleteRankContext'
1772
+ );
1773
+ }
1774
+
1775
+ public async getAthleteActivities(args: { input: ActivitiesQueryDto }): Promise<ITypedBackendResponse<ActivitiesResponse>> {
1776
+ return this.execute<ActivitiesResponse>(
1777
+ () => this.sdk.GetAthleteActivities({ input: args.input }),
1778
+ 'athleteActivities',
1779
+ (r) => !!r?.athleteActivities,
1780
+ 'getAthleteActivities'
1781
+ );
1782
+ }
1783
+
1784
+ public async getAthleteActivityDetail(args: { input: ActivityDetailQueryDto }): Promise<ITypedBackendResponse<ActivityDetail>> {
1785
+ return this.execute<ActivityDetail>(
1786
+ () => this.sdk.GetAthleteActivityDetail({ input: args.input }),
1787
+ 'athleteActivityDetail',
1788
+ (r) => !!r?.athleteActivityDetail,
1789
+ 'getAthleteActivityDetail'
1790
+ );
1791
+ }
1792
+
1793
+ public async getAthleteComponentSummary(args: { input: ComponentSummaryQueryDto }): Promise<ITypedBackendResponse<ComponentSummary>> {
1794
+ return this.execute<ComponentSummary>(
1795
+ () => this.sdk.GetAthleteComponentSummary({ input: args.input }),
1796
+ 'athleteComponentSummary',
1797
+ (r) => !!r?.athleteComponentSummary,
1798
+ 'getAthleteComponentSummary'
1799
+ );
1800
+ }
1801
+
1802
+ // ============= SOCIAL METHODS =============
1803
+
1804
+ public async getSocialAggregates(args: {
1805
+ input: { athleteId: string; platform: Platform; startDate: string; endDate: string; periodType?: PeriodType; };
1806
+ }): Promise<ITypedBackendResponse<any[]>> {
1807
+ return this.execute<any[]>(
1808
+ () => this.sdk.GetSocialAggregates({
1809
+ athleteId: args.input.athleteId,
1810
+ platform: args.input.platform as any,
1811
+ range: { start: args.input.startDate, end: args.input.endDate },
1812
+ periodType: args.input.periodType as any,
1813
+ }),
1814
+ 'socialAggregates',
1815
+ (r) => r?.socialAggregates !== undefined,
1816
+ 'getSocialAggregates'
1817
+ );
1818
+ }
1819
+
1820
+ public async getPostsWithComparison(args: {
1821
+ input: { athleteId: string; platform: Platform; sortBy?: PostSortOption; contentType?: ContentType; limit?: number; offset?: number; comparisonWindowDays?: number; };
1822
+ }): Promise<ITypedBackendResponse<any>> {
1823
+ return this.execute<any>(
1824
+ () => this.sdk.GetPostsWithComparison({
1825
+ athleteId: args.input.athleteId,
1826
+ platform: args.input.platform as any,
1827
+ options: {
1828
+ sortBy: args.input.sortBy as any,
1829
+ contentType: args.input.contentType as any,
1830
+ limit: args.input.limit,
1831
+ offset: args.input.offset,
1832
+ comparisonWindowDays: args.input.comparisonWindowDays,
1833
+ },
1834
+ }),
1835
+ 'postsWithComparison',
1836
+ (r) => r?.postsWithComparison !== undefined,
1837
+ 'getPostsWithComparison'
1838
+ );
1839
+ }
1840
+
1841
+ public async getAthleteActivityDates(athleteId: string): Promise<ITypedBackendResponse<ActivityDatesResponse>> {
1842
+ return this.execute<ActivityDatesResponse>(
1843
+ () => this.sdk.GetAthleteActivityDates({ input: { athleteId } as any }),
1844
+ 'athleteActivityDates',
1845
+ (r) => r?.athleteActivityDates?.dates !== undefined,
1846
+ 'getAthleteActivityDates'
1847
+ );
1848
+ }
1849
+
1850
+ // ============= NOTIFICATION METHODS =============
1851
+
1852
+ public async getMyNotifications(options?: {
1853
+ limit?: number; offset?: number; includeRead?: boolean; includeDismissed?: boolean; types?: string[];
1854
+ }): Promise<ITypedBackendResponse<NotificationListResponse>> {
1855
+ return this.execute<NotificationListResponse>(
1856
+ () => this.sdk.MyNotifications({ input: (options || {}) as any }),
1857
+ 'myNotifications',
1858
+ (r) => r?.myNotifications?.notifications !== undefined,
1859
+ 'getMyNotifications'
1860
+ );
1861
+ }
1862
+
1863
+ public async getNotificationUnreadCount(): Promise<ITypedBackendResponse<UnreadCountResponse>> {
1864
+ return this.execute<UnreadCountResponse>(
1865
+ () => this.sdk.NotificationUnreadCount(),
1866
+ 'notificationUnreadCount',
1867
+ (r) => r?.notificationUnreadCount?.count !== undefined,
1868
+ 'getNotificationUnreadCount'
1869
+ );
1870
+ }
1871
+
1872
+ public async getMyNotificationPreferences(): Promise<ITypedBackendResponse<NotificationPreference>> {
1873
+ return this.execute<NotificationPreference>(
1874
+ () => this.sdk.MyNotificationPreferences(),
1875
+ 'myNotificationPreferences',
1876
+ (r) => r?.myNotificationPreferences?.id !== undefined,
1877
+ 'getMyNotificationPreferences'
1878
+ );
1879
+ }
1880
+
1881
+ public async markNotificationAsRead(notificationId: string): Promise<ITypedBackendResponse<Notification>> {
1882
+ return this.execute<Notification>(
1883
+ () => this.sdk.MarkNotificationAsRead({ input: { notificationId } as any }),
1884
+ 'markNotificationAsRead',
1885
+ (r) => r?.markNotificationAsRead?.id !== undefined,
1886
+ 'markNotificationAsRead'
1887
+ );
1888
+ }
1889
+
1890
+ public async markAllNotificationsAsRead(): Promise<ITypedBackendResponse<number>> {
1891
+ return this.execute<number>(
1892
+ () => this.sdk.MarkAllNotificationsAsRead(),
1893
+ 'markAllNotificationsAsRead',
1894
+ (r) => r?.markAllNotificationsAsRead !== undefined,
1895
+ 'markAllNotificationsAsRead'
1896
+ );
1897
+ }
1898
+
1899
+ public async dismissNotification(notificationId: string): Promise<ITypedBackendResponse<boolean>> {
1900
+ return this.execute<boolean>(
1901
+ () => this.sdk.DismissNotification({ input: { notificationId } as any }),
1902
+ 'dismissNotification',
1903
+ (r) => r?.dismissNotification !== undefined,
1904
+ 'dismissNotification'
1905
+ );
1906
+ }
1907
+
1908
+ public async registerDeviceToken(token: string, platform: string, deviceName?: string): Promise<ITypedBackendResponse<DeviceTokenType>> {
1909
+ const input: RegisterDeviceTokenDto = { token, platform, deviceName };
1910
+ return this.execute<DeviceTokenType>(
1911
+ () => this.sdk.RegisterDeviceToken({ input }),
1912
+ 'registerDeviceToken',
1913
+ (r) => r?.registerDeviceToken?.id !== undefined,
1914
+ 'registerDeviceToken'
1915
+ );
1916
+ }
1917
+
1918
+ public async unregisterDeviceToken(token: string): Promise<ITypedBackendResponse<boolean>> {
1919
+ const input: UnregisterDeviceTokenDto = { token };
1920
+ return this.execute<boolean>(
1921
+ () => this.sdk.UnregisterDeviceToken({ input }),
1922
+ 'unregisterDeviceToken',
1923
+ (r) => r?.unregisterDeviceToken !== undefined,
1924
+ 'unregisterDeviceToken'
1925
+ );
1926
+ }
1927
+
1928
+ public async updateNotificationPreferences(input: {
1929
+ emailEnabled?: boolean; inAppEnabled?: boolean; pushEnabled?: boolean; mutedTypes?: string[];
1930
+ }): Promise<ITypedBackendResponse<NotificationPreference>> {
1931
+ return this.execute<NotificationPreference>(
1932
+ () => this.sdk.UpdateNotificationPreferences({ input: input as any }),
1933
+ 'updateNotificationPreferences',
1934
+ (r) => r?.updateNotificationPreferences?.id !== undefined,
1935
+ 'updateNotificationPreferences'
1936
+ );
1937
+ }
1938
+
1939
+ // ============= FOLLOW METHODS =============
1940
+
1941
+ public async followAthlete(athleteId: string): Promise<ITypedBackendResponse<boolean>> {
1942
+ return this.execute<boolean>(
1943
+ () => this.sdk.FollowAthlete({ input: { athleteId } }),
1944
+ 'followAthlete',
1945
+ (r) => r?.followAthlete !== undefined,
1946
+ 'followAthlete'
1947
+ );
1948
+ }
1949
+
1950
+ public async unfollowAthlete(athleteId: string): Promise<ITypedBackendResponse<boolean>> {
1951
+ return this.execute<boolean>(
1952
+ () => this.sdk.UnfollowAthlete({ input: { athleteId } }),
1953
+ 'unfollowAthlete',
1954
+ (r) => r?.unfollowAthlete !== undefined,
1955
+ 'unfollowAthlete'
1956
+ );
1957
+ }
1958
+
1959
+ public async isFollowingAthlete(athleteId: string): Promise<ITypedBackendResponse<IsFollowingResponse>> {
1960
+ return this.execute<IsFollowingResponse>(
1961
+ () => this.sdk.IsFollowingAthlete({ input: { athleteId } }),
1962
+ 'isFollowingAthlete',
1963
+ (r) => r?.isFollowingAthlete?.isFollowing !== undefined,
1964
+ 'isFollowingAthlete'
1965
+ );
1966
+ }
1967
+
1968
+ public async getMyFollowedAthletes(options?: { limit?: number; offset?: number; }): Promise<ITypedBackendResponse<FollowedAthletesListResponse>> {
1969
+ return this.execute<FollowedAthletesListResponse>(
1970
+ () => this.sdk.MyFollowedAthletes({ input: (options || null) as any }),
1971
+ 'myFollowedAthletes',
1972
+ (r) => r?.myFollowedAthletes?.athletes !== undefined,
1973
+ 'getMyFollowedAthletes'
1974
+ );
1975
+ }
1976
+
1977
+ // ============= ONBOARDING METHODS =============
1978
+
1979
+ public async deleteOnboardingAthlete(): Promise<ITypedBackendResponse<{ success: boolean; athleteId?: string; error?: string }>> {
1980
+ return this.execute<{ success: boolean; athleteId?: string; error?: string }>(
1981
+ () => this.sdk.DeleteOnboardingAthlete(),
1982
+ 'deleteOnboardingAthlete',
1983
+ (r) => r?.deleteOnboardingAthlete?.success === true,
1984
+ 'deleteOnboardingAthlete'
1985
+ );
1986
+ }
1987
+
1988
+ public async updateOnboardingProgress(
1989
+ step: number,
1990
+ complete?: boolean
1991
+ ): Promise<ITypedBackendResponse<{ success: boolean; step?: number; complete?: boolean; error?: string }>> {
1992
+ return this.execute<{ success: boolean; step?: number; complete?: boolean; error?: string }>(
1993
+ () => this.sdk.UpdateOnboardingProgress({ input: { step, complete } as any }),
1994
+ 'updateOnboardingProgress',
1995
+ (r) => r?.updateOnboardingProgress?.success === true,
1996
+ 'updateOnboardingProgress'
1997
+ );
1998
+ }
1999
+
2000
+ public async getOnboardingProgress(): Promise<ITypedBackendResponse<{ success: boolean; step?: number; complete?: boolean; athleteId?: string; error?: string }>> {
2001
+ return this.execute<{ success: boolean; step?: number; complete?: boolean; athleteId?: string; error?: string }>(
2002
+ () => this.sdk.GetOnboardingProgress(),
2003
+ 'getOnboardingProgress',
2004
+ (r) => r?.getOnboardingProgress?.success === true,
2005
+ 'getOnboardingProgress'
2006
+ );
2007
+ }
2008
+
2009
+ public async getPublicAthleteIntegrationStatus(athleteId: string): Promise<ITypedBackendResponse<any>> {
2010
+ return this.execute<any>(
2011
+ () => this.sdk.GetPublicAthleteIntegrationStatus({ athleteId }),
2012
+ 'getPublicAthleteIntegrationStatus',
2013
+ (r) => r?.getPublicAthleteIntegrationStatus != null,
2014
+ 'getPublicAthleteIntegrationStatus'
2015
+ );
2016
+ }
2017
+
2018
+ // ============= EMAIL CAMPAIGN METHODS =============
2019
+
2020
+ public async getEmailCampaigns(args: {
2021
+ status: string; search?: string; page?: number; limit?: number;
2022
+ }): Promise<ITypedBackendResponse<any>> {
2023
+ return this.execute<any>(
2024
+ () => this.sdk.GetEmailCampaigns({ ...args }),
2025
+ 'getEmailCampaigns',
2026
+ (r) => r?.getEmailCampaigns?.campaigns != null,
2027
+ 'getEmailCampaigns'
2028
+ );
2029
+ }
2030
+
2031
+ public async createEmailCampaign(input: any): Promise<ITypedBackendResponse<any>> {
2032
+ return this.execute<any>(
2033
+ () => this.sdk.CreateEmailCampaign({ input }),
2034
+ 'createEmailCampaign',
2035
+ (r) => !!r?.createEmailCampaign?._id,
2036
+ 'createEmailCampaign'
2037
+ );
2038
+ }
2039
+
2040
+ public async updateEmailCampaign(id: string, input: any): Promise<ITypedBackendResponse<any>> {
2041
+ return this.execute<any>(
2042
+ () => this.sdk.UpdateEmailCampaign({ id, input }),
2043
+ 'updateEmailCampaign',
2044
+ (r) => !!r?.updateEmailCampaign?._id,
2045
+ 'updateEmailCampaign'
2046
+ );
2047
+ }
2048
+
2049
+ public async deleteEmailCampaign(id: string): Promise<ITypedBackendResponse<boolean>> {
2050
+ return this.execute<boolean>(
2051
+ () => this.sdk.DeleteEmailCampaign({ id }),
2052
+ 'deleteEmailCampaign',
2053
+ (r) => r?.deleteEmailCampaign === true,
2054
+ 'deleteEmailCampaign'
2055
+ );
2056
+ }
2057
+
2058
+ public async cloneEmailCampaign(id: string): Promise<ITypedBackendResponse<any>> {
2059
+ return this.execute<any>(
2060
+ () => this.sdk.CloneEmailCampaign({ id }),
2061
+ 'cloneEmailCampaign',
2062
+ (r) => !!r?.cloneEmailCampaign?._id,
2063
+ 'cloneEmailCampaign'
2064
+ );
2065
+ }
2066
+
2067
+ public async sendTestEmail(campaignId: string, email: string): Promise<ITypedBackendResponse<any>> {
2068
+ return this.execute<any>(
2069
+ () => this.sdk.SendTestEmail({ campaignId, adminEmail: email }),
2070
+ 'sendTestEmail',
2071
+ (r) => !!r?.sendTestEmail,
2072
+ 'sendTestEmail'
2073
+ );
2074
+ }
2075
+
2076
+ public async sendBulkEmail(campaignId: string): Promise<ITypedBackendResponse<any>> {
2077
+ return this.execute<any>(
2078
+ () => this.sdk.SendBulkEmail({ campaignId }),
2079
+ 'sendBulkEmail',
2080
+ (r) => !!r?.sendBulkEmail,
2081
+ 'sendBulkEmail'
2082
+ );
2083
+ }
2084
+
2085
+ public async scheduleEmailCampaign(campaignId: string, scheduledFor: string): Promise<ITypedBackendResponse<any>> {
2086
+ return this.execute<any>(
2087
+ () => this.sdk.ScheduleEmailCampaign({ campaignId, scheduledFor }),
2088
+ 'scheduleEmailCampaign',
2089
+ (r) => !!r?.scheduleEmailCampaign?._id,
2090
+ 'scheduleEmailCampaign'
2091
+ );
2092
+ }
2093
+
2094
+ public async cancelScheduledEmail(campaignId: string): Promise<ITypedBackendResponse<any>> {
2095
+ return this.execute<any>(
2096
+ () => this.sdk.CancelScheduledEmail({ campaignId }),
2097
+ 'cancelScheduledEmail',
2098
+ (r) => !!r?.cancelScheduledEmail?._id,
2099
+ 'cancelScheduledEmail'
2100
+ );
2101
+ }
2102
+
2103
+ public async getAudiencePreview(filters: any): Promise<ITypedBackendResponse<any>> {
2104
+ return this.execute<any>(
2105
+ () => this.sdk.GetAudiencePreview({ filters }),
2106
+ 'getAudiencePreview',
2107
+ (r) => r?.getAudiencePreview?.total != null,
2108
+ 'getAudiencePreview'
2109
+ );
2110
+ }
2111
+
2112
+ public async getSendGridTemplates(): Promise<ITypedBackendResponse<any[]>> {
2113
+ return this.execute<any[]>(
2114
+ () => this.sdk.GetSendGridTemplates(),
2115
+ 'getSendGridTemplates',
2116
+ (r) => r?.getSendGridTemplates != null,
2117
+ 'getSendGridTemplates'
2118
+ );
2119
+ }
2120
+
2121
+ public async getSendGridTemplatePreview(templateId: string): Promise<ITypedBackendResponse<string>> {
2122
+ return this.execute<string>(
2123
+ () => this.sdk.GetSendGridTemplatePreview({ templateId }),
2124
+ 'getSendGridTemplatePreview',
2125
+ (r) => r?.getSendGridTemplatePreview != null,
2126
+ 'getSendGridTemplatePreview'
2127
+ );
2128
+ }
2129
+
2130
+ public async getEmailSegments(): Promise<ITypedBackendResponse<any[]>> {
2131
+ return this.execute<any[]>(
2132
+ () => this.sdk.GetEmailSegments(),
2133
+ 'getEmailSegments',
2134
+ (r) => r?.getEmailSegments != null,
2135
+ 'getEmailSegments'
2136
+ );
2137
+ }
2138
+
2139
+ public async createEmailSegment(input: any): Promise<ITypedBackendResponse<any>> {
2140
+ return this.execute<any>(
2141
+ () => this.sdk.CreateEmailSegment({ input }),
2142
+ 'createEmailSegment',
2143
+ (r) => !!r?.createEmailSegment?._id,
2144
+ 'createEmailSegment'
2145
+ );
2146
+ }
2147
+
2148
+ public async updateEmailSegment(id: string, input: any): Promise<ITypedBackendResponse<any>> {
2149
+ return this.execute<any>(
2150
+ () => this.sdk.UpdateEmailSegment({ id, input }),
2151
+ 'updateEmailSegment',
2152
+ (r) => !!r?.updateEmailSegment?._id,
2153
+ 'updateEmailSegment'
2154
+ );
2155
+ }
2156
+
2157
+ public async deleteEmailSegment(id: string): Promise<ITypedBackendResponse<boolean>> {
2158
+ return this.execute<boolean>(
2159
+ () => this.sdk.DeleteEmailSegment({ id }),
2160
+ 'deleteEmailSegment',
2161
+ (r) => r?.deleteEmailSegment === true,
2162
+ 'deleteEmailSegment'
2163
+ );
2164
+ }
2165
+
2166
+ // ============= AI COACH METHODS =============
2167
+
2168
+ public async getAiCoachThread(): Promise<ITypedBackendResponse<any>> {
2169
+ return this.execute<any>(
2170
+ () => this.sdk.GetAiCoachThread(),
2171
+ 'getAiCoachThread',
2172
+ (r) => r?.getAiCoachThread !== undefined,
2173
+ 'getAiCoachThread'
2174
+ );
2175
+ }
2176
+
2177
+ public async getAiCoachThreadHistory(limit?: number): Promise<ITypedBackendResponse<any[]>> {
2178
+ return this.execute<any[]>(
2179
+ () => this.sdk.GetAiCoachThreadHistory({ limit: limit ?? 10 }),
2180
+ 'getAiCoachThreadHistory',
2181
+ (r) => Array.isArray(r?.getAiCoachThreadHistory),
2182
+ 'getAiCoachThreadHistory'
2183
+ );
2184
+ }
2185
+
2186
+ public async getAiCoachThreadMessages(threadId: string): Promise<ITypedBackendResponse<any[]>> {
2187
+ return this.execute<any[]>(
2188
+ () => this.sdk.GetAiCoachThreadMessages({ threadId }),
2189
+ 'getAiCoachThreadMessages',
2190
+ (r) => Array.isArray(r?.getAiCoachThreadMessages),
2191
+ 'getAiCoachThreadMessages'
2192
+ );
2193
+ }
2194
+
2195
+ public async getAiCoachConfig(): Promise<ITypedBackendResponse<any>> {
2196
+ return this.execute<any>(
2197
+ () => this.sdk.GetAiCoachConfig(),
2198
+ 'getAiCoachConfig',
2199
+ (r) => r?.getAiCoachConfig?.athleteId !== undefined,
2200
+ 'getAiCoachConfig'
2201
+ );
2202
+ }
2203
+
2204
+ public async sendAiCoachMessage(input: { threadId: string; message: string }): Promise<ITypedBackendResponse<any>> {
2205
+ return this.execute<any>(
2206
+ () => this.sdk.SendAiCoachMessage({ input: input as any }),
2207
+ 'sendAiCoachMessage',
2208
+ (r) => !!r?.sendAiCoachMessage?._id,
2209
+ 'sendAiCoachMessage'
2210
+ );
2211
+ }
2212
+
2213
+ public async updateAiCoachConfig(input: { enabled?: boolean; nudgesEnabled?: boolean; preferredFocus?: string }): Promise<ITypedBackendResponse<any>> {
2214
+ return this.execute<any>(
2215
+ () => this.sdk.UpdateAiCoachConfig({ input: input as any }),
2216
+ 'updateAiCoachConfig',
2217
+ (r) => r?.updateAiCoachConfig?.athleteId !== undefined,
2218
+ 'updateAiCoachConfig'
2219
+ );
2220
+ }
2221
+
2222
+ // ============= AI COACH NUDGE METHODS =============
2223
+
2224
+ public async getAiCoachNudges(input?: { unreadOnly?: boolean }): Promise<ITypedBackendResponse<any>> {
2225
+ return this.execute<any>(
2226
+ () => this.sdk.GetAiCoachNudges({ input: input as any }),
2227
+ 'getAiCoachNudges',
2228
+ (r) => r?.getAiCoachNudges !== undefined,
2229
+ 'getAiCoachNudges'
2230
+ );
2231
+ }
2232
+
2233
+ public async getAiCoachUnreadNudgeCount(): Promise<ITypedBackendResponse<any>> {
2234
+ return this.execute<any>(
2235
+ () => this.sdk.GetAiCoachUnreadNudgeCount(),
2236
+ 'getAiCoachUnreadNudgeCount',
2237
+ (r) => r?.getAiCoachUnreadNudgeCount !== undefined,
2238
+ 'getAiCoachUnreadNudgeCount'
2239
+ );
2240
+ }
2241
+
2242
+ public async markAiCoachNudgeRead(nudgeId: string): Promise<ITypedBackendResponse<any>> {
2243
+ return this.execute<any>(
2244
+ () => this.sdk.MarkAiCoachNudgeRead({ nudgeId }),
2245
+ 'markAiCoachNudgeRead',
2246
+ (r) => r?.markAiCoachNudgeRead !== undefined,
2247
+ 'markAiCoachNudgeRead'
2248
+ );
2249
+ }
2250
+ }
2251
+
2252
+ // Re-export UserImages type for consumers
2253
+ import { UserImages } from '../client';