@goodparty_org/sdk 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +25 -297
- package/dist/index.d.ts +25 -297
- package/dist/index.js +40 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,230 +1,7 @@
|
|
|
1
|
+
import { ReadCampaignOutput, ListCampaignsPagination, PaginatedList, UpdateCampaignM2MInput, PaginationOptions, ListUsersPagination, ReadUserOutput, UpdateUserInput, UpdatePasswordInput, CampaignTier as CampaignTier$1, UserRole as UserRole$1, WhyBrowsing as WhyBrowsing$1 } from '@goodparty_org/contracts';
|
|
2
|
+
export { AiChatMessage, AiContentData, AiContentGenerationStatus, AiContentInputValues, BALLOT_READY_POSITION_LEVEL_VALUES, BallotReadyPositionLevel, CAMPAIGN_CREATED_BY_VALUES, CAMPAIGN_LAUNCH_STATUS_VALUES, CAMPAIGN_STATUS_VALUES, CAMPAIGN_TIER_VALUES, ReadCampaignOutput as Campaign, CampaignAiContent, CampaignCreatedBy, CampaignData, CampaignDetails, CampaignFinance, CampaignLaunchStatus, CampaignPlan, CampaignPlanStatus, CampaignStatus, CustomIssue, CustomVoterFile, ELECTION_LEVEL_VALUES, ElectionLevel, GENERATION_STATUS_VALUES, GenerationStatus, GeoLocation, HubSpotUpdates, ListCampaignsPagination, ListUsersPagination, ONBOARDING_STEP_VALUES, OnboardingStep, Opponent, PaginatedList, PaginationMeta, PaginationOptions, ReadCampaignOutput, ReadUserOutput, USER_ROLE_VALUES, UpdateCampaignM2MInput, UpdatePasswordInput, UpdateUserInput, ReadUserOutput as User, UserMetaData, VoterGoals, WHY_BROWSING_VALUES } from '@goodparty_org/contracts';
|
|
1
3
|
import { FetchOptions } from 'ofetch';
|
|
2
4
|
|
|
3
|
-
declare class SdkError extends Error {
|
|
4
|
-
readonly status: number;
|
|
5
|
-
readonly response?: Response;
|
|
6
|
-
constructor(status: number, message: string, response?: Response);
|
|
7
|
-
}
|
|
8
|
-
type PaginationOptions = {
|
|
9
|
-
offset?: number;
|
|
10
|
-
limit?: number;
|
|
11
|
-
sortBy?: string;
|
|
12
|
-
sortOrder?: 'asc' | 'desc';
|
|
13
|
-
};
|
|
14
|
-
type PaginationMeta = {
|
|
15
|
-
total: number;
|
|
16
|
-
offset: number;
|
|
17
|
-
limit: number;
|
|
18
|
-
};
|
|
19
|
-
type PaginatedList<T> = {
|
|
20
|
-
data: T[];
|
|
21
|
-
meta: PaginationMeta;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
declare enum CampaignTier {
|
|
25
|
-
WIN = "WIN",
|
|
26
|
-
LOSE = "LOSE",
|
|
27
|
-
TOSSUP = "TOSSUP"
|
|
28
|
-
}
|
|
29
|
-
declare enum BallotReadyPositionLevel {
|
|
30
|
-
CITY = "CITY",
|
|
31
|
-
COUNTY = "COUNTY",
|
|
32
|
-
FEDERAL = "FEDERAL",
|
|
33
|
-
LOCAL = "LOCAL",
|
|
34
|
-
REGIONAL = "REGIONAL",
|
|
35
|
-
STATE = "STATE",
|
|
36
|
-
TOWNSHIP = "TOWNSHIP"
|
|
37
|
-
}
|
|
38
|
-
declare enum ElectionLevel {
|
|
39
|
-
state = "state",
|
|
40
|
-
county = "county",
|
|
41
|
-
federal = "federal",
|
|
42
|
-
city = "city"
|
|
43
|
-
}
|
|
44
|
-
declare enum CampaignCreatedBy {
|
|
45
|
-
ADMIN = "admin"
|
|
46
|
-
}
|
|
47
|
-
declare enum CampaignLaunchStatus {
|
|
48
|
-
launched = "launched"
|
|
49
|
-
}
|
|
50
|
-
declare enum OnboardingStep {
|
|
51
|
-
complete = "onboarding-complete",
|
|
52
|
-
registration = "registration"
|
|
53
|
-
}
|
|
54
|
-
declare enum GenerationStatus {
|
|
55
|
-
processing = "processing",
|
|
56
|
-
completed = "completed"
|
|
57
|
-
}
|
|
58
|
-
type VoterGoals = {
|
|
59
|
-
doorKnocking?: number;
|
|
60
|
-
calls?: number;
|
|
61
|
-
digital?: number;
|
|
62
|
-
directMail?: number;
|
|
63
|
-
digitalAds?: number;
|
|
64
|
-
text?: number;
|
|
65
|
-
events?: number;
|
|
66
|
-
yardSigns?: number;
|
|
67
|
-
robocall?: number;
|
|
68
|
-
phoneBanking?: number;
|
|
69
|
-
socialMedia?: number;
|
|
70
|
-
};
|
|
71
|
-
type CustomVoterFile = {
|
|
72
|
-
name: string;
|
|
73
|
-
channel?: string;
|
|
74
|
-
purpose?: string;
|
|
75
|
-
filters: string[];
|
|
76
|
-
createdAt: string;
|
|
77
|
-
};
|
|
78
|
-
type AiChatMessage = {
|
|
79
|
-
role: 'user' | 'system' | 'assistant';
|
|
80
|
-
content: string;
|
|
81
|
-
createdAt?: number;
|
|
82
|
-
id?: string;
|
|
83
|
-
usage?: number;
|
|
84
|
-
};
|
|
85
|
-
type AiContentInputValues = Record<string, string | boolean | number | undefined>;
|
|
86
|
-
type AiContentGenerationStatus = {
|
|
87
|
-
status: GenerationStatus;
|
|
88
|
-
createdAt: number;
|
|
89
|
-
prompt?: string;
|
|
90
|
-
existingChat?: AiChatMessage[];
|
|
91
|
-
inputValues?: AiContentInputValues;
|
|
92
|
-
};
|
|
93
|
-
type AiContentData = {
|
|
94
|
-
name: string;
|
|
95
|
-
content: string;
|
|
96
|
-
updatedAt: number;
|
|
97
|
-
inputValues?: AiContentInputValues;
|
|
98
|
-
};
|
|
99
|
-
type GeoLocation = {
|
|
100
|
-
geoHash?: string;
|
|
101
|
-
lng?: number;
|
|
102
|
-
lat?: number;
|
|
103
|
-
};
|
|
104
|
-
type CustomIssue = {
|
|
105
|
-
title: string;
|
|
106
|
-
position: string;
|
|
107
|
-
};
|
|
108
|
-
type Opponent = {
|
|
109
|
-
name: string;
|
|
110
|
-
party: string;
|
|
111
|
-
description: string;
|
|
112
|
-
};
|
|
113
|
-
type HubSpotUpdates = Partial<Record<string, string>>;
|
|
114
|
-
type CampaignDetails = {
|
|
115
|
-
state?: string;
|
|
116
|
-
ballotLevel?: BallotReadyPositionLevel;
|
|
117
|
-
electionDate?: string;
|
|
118
|
-
primaryElectionDate?: string;
|
|
119
|
-
zip?: string | null;
|
|
120
|
-
knowRun?: 'yes' | null;
|
|
121
|
-
runForOffice?: 'yes' | 'no' | null;
|
|
122
|
-
pledged?: boolean;
|
|
123
|
-
isProUpdatedAt?: number;
|
|
124
|
-
customIssues?: CustomIssue[];
|
|
125
|
-
runningAgainst?: Opponent[];
|
|
126
|
-
geoLocation?: GeoLocation;
|
|
127
|
-
geoLocationFailed?: boolean;
|
|
128
|
-
city?: string | null;
|
|
129
|
-
county?: string | null;
|
|
130
|
-
normalizedOffice?: string | null;
|
|
131
|
-
otherOffice?: string;
|
|
132
|
-
office?: string;
|
|
133
|
-
party?: string;
|
|
134
|
-
otherParty?: string;
|
|
135
|
-
district?: string;
|
|
136
|
-
raceId?: string;
|
|
137
|
-
level?: ElectionLevel | null;
|
|
138
|
-
noNormalizedOffice?: boolean;
|
|
139
|
-
website?: string;
|
|
140
|
-
pastExperience?: string | Record<string, string>;
|
|
141
|
-
occupation?: string;
|
|
142
|
-
funFact?: string;
|
|
143
|
-
campaignCommittee?: string;
|
|
144
|
-
statementName?: string;
|
|
145
|
-
subscriptionId?: string | null;
|
|
146
|
-
endOfElectionSubscriptionCanceled?: boolean;
|
|
147
|
-
subscriptionCanceledAt?: number | null;
|
|
148
|
-
subscriptionCancelAt?: number | null;
|
|
149
|
-
filingPeriodsStart?: string | null;
|
|
150
|
-
filingPeriodsEnd?: string | null;
|
|
151
|
-
officeTermLength?: string;
|
|
152
|
-
partisanType?: string;
|
|
153
|
-
priorElectionDates?: string[];
|
|
154
|
-
positionId?: string | null;
|
|
155
|
-
electionId?: string | null;
|
|
156
|
-
tier?: string;
|
|
157
|
-
einNumber?: string | null;
|
|
158
|
-
einSupportingDocument?: string | null;
|
|
159
|
-
wonGeneral?: boolean;
|
|
160
|
-
};
|
|
161
|
-
type CampaignData = {
|
|
162
|
-
createdBy?: CampaignCreatedBy;
|
|
163
|
-
slug?: string;
|
|
164
|
-
hubSpotUpdates?: HubSpotUpdates;
|
|
165
|
-
currentStep?: OnboardingStep;
|
|
166
|
-
launchStatus?: CampaignLaunchStatus;
|
|
167
|
-
lastVisited?: number;
|
|
168
|
-
claimProfile?: string;
|
|
169
|
-
customVoterFiles?: CustomVoterFile[];
|
|
170
|
-
reportedVoterGoals?: VoterGoals;
|
|
171
|
-
textCampaignCount?: number;
|
|
172
|
-
lastStepDate?: string;
|
|
173
|
-
adminUserEmail?: string;
|
|
174
|
-
hubspotId?: string;
|
|
175
|
-
name?: string;
|
|
176
|
-
};
|
|
177
|
-
type CampaignAiContent = {
|
|
178
|
-
generationStatus?: Record<string, AiContentGenerationStatus>;
|
|
179
|
-
campaignPlanAttempts?: Record<string, number>;
|
|
180
|
-
} & Record<string, AiContentData>;
|
|
181
|
-
type Campaign = {
|
|
182
|
-
id: number;
|
|
183
|
-
createdAt: string;
|
|
184
|
-
updatedAt: string;
|
|
185
|
-
slug: string;
|
|
186
|
-
isActive: boolean;
|
|
187
|
-
isVerified?: boolean | null;
|
|
188
|
-
isPro?: boolean | null;
|
|
189
|
-
isDemo: boolean;
|
|
190
|
-
didWin?: boolean | null;
|
|
191
|
-
dateVerified?: string | null;
|
|
192
|
-
tier?: CampaignTier | null;
|
|
193
|
-
formattedAddress?: string | null;
|
|
194
|
-
placeId?: string | null;
|
|
195
|
-
data: CampaignData;
|
|
196
|
-
details: CampaignDetails;
|
|
197
|
-
aiContent: CampaignAiContent;
|
|
198
|
-
userId: number;
|
|
199
|
-
canDownloadFederal: boolean;
|
|
200
|
-
completedTaskIds: string[];
|
|
201
|
-
hasFreeTextsOffer: boolean;
|
|
202
|
-
freeTextsOfferRedeemedAt?: string | null;
|
|
203
|
-
};
|
|
204
|
-
type ListCampaignsOptions = PaginationOptions & {
|
|
205
|
-
userId?: number;
|
|
206
|
-
slug?: string;
|
|
207
|
-
};
|
|
208
|
-
type UpdateCampaignInput = {
|
|
209
|
-
slug?: string;
|
|
210
|
-
isActive?: boolean;
|
|
211
|
-
isVerified?: boolean | null;
|
|
212
|
-
isPro?: boolean | null;
|
|
213
|
-
isDemo?: boolean;
|
|
214
|
-
didWin?: boolean | null;
|
|
215
|
-
dateVerified?: string | null;
|
|
216
|
-
tier?: CampaignTier | null;
|
|
217
|
-
formattedAddress?: string | null;
|
|
218
|
-
placeId?: string | null;
|
|
219
|
-
data?: CampaignData;
|
|
220
|
-
details?: CampaignDetails;
|
|
221
|
-
aiContent?: CampaignAiContent;
|
|
222
|
-
canDownloadFederal?: boolean;
|
|
223
|
-
completedTaskIds?: string[];
|
|
224
|
-
hasFreeTextsOffer?: boolean;
|
|
225
|
-
freeTextsOfferRedeemedAt?: string | null;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
5
|
type OfetchRequestBody = FetchOptions<'json'>['body'];
|
|
229
6
|
declare class HttpClient {
|
|
230
7
|
private baseUrl;
|
|
@@ -245,9 +22,9 @@ declare abstract class BaseResource {
|
|
|
245
22
|
|
|
246
23
|
declare class CampaignsResource extends BaseResource {
|
|
247
24
|
protected readonly resourceBasePath = "/campaigns";
|
|
248
|
-
get: (id: number) => Promise<
|
|
249
|
-
list: (options?:
|
|
250
|
-
update: (id: number, input:
|
|
25
|
+
get: (id: number) => Promise<ReadCampaignOutput>;
|
|
26
|
+
list: (options?: ListCampaignsPagination) => Promise<PaginatedList<ReadCampaignOutput>>;
|
|
27
|
+
update: (id: number, input: UpdateCampaignM2MInput) => Promise<ReadCampaignOutput>;
|
|
251
28
|
}
|
|
252
29
|
|
|
253
30
|
type ElectedOffice = {
|
|
@@ -352,76 +129,11 @@ declare class PathsToVictoryResource extends BaseResource {
|
|
|
352
129
|
update: (id: number, input: UpdatePathToVictoryInput) => Promise<PathToVictory>;
|
|
353
130
|
}
|
|
354
131
|
|
|
355
|
-
declare enum UserRole {
|
|
356
|
-
admin = "admin",
|
|
357
|
-
sales = "sales",
|
|
358
|
-
candidate = "candidate",
|
|
359
|
-
campaignManager = "campaignManager",
|
|
360
|
-
demo = "demo"
|
|
361
|
-
}
|
|
362
|
-
declare enum WhyBrowsing {
|
|
363
|
-
considering = "considering",
|
|
364
|
-
learning = "learning",
|
|
365
|
-
test = "test",
|
|
366
|
-
else = "else"
|
|
367
|
-
}
|
|
368
|
-
declare enum SIGN_UP_MODE {
|
|
369
|
-
CANDIDATE = "candidate",
|
|
370
|
-
FACILITATED = "facilitated"
|
|
371
|
-
}
|
|
372
|
-
type UserMetaData = {
|
|
373
|
-
customerId?: string;
|
|
374
|
-
checkoutSessionId?: string | null;
|
|
375
|
-
accountType?: string | null;
|
|
376
|
-
lastVisited?: number;
|
|
377
|
-
sessionCount?: number;
|
|
378
|
-
isDeleted?: boolean;
|
|
379
|
-
fsUserId?: string;
|
|
380
|
-
whyBrowsing?: WhyBrowsing | null;
|
|
381
|
-
hubspotId?: string;
|
|
382
|
-
profile_updated_count?: number;
|
|
383
|
-
textNotifications?: boolean;
|
|
384
|
-
} | null;
|
|
385
|
-
type User = {
|
|
386
|
-
id: number;
|
|
387
|
-
firstName: string;
|
|
388
|
-
lastName: string;
|
|
389
|
-
name?: string | null;
|
|
390
|
-
email: string;
|
|
391
|
-
phone?: string | null;
|
|
392
|
-
zip?: string | null;
|
|
393
|
-
avatar?: string | null;
|
|
394
|
-
hasPassword: boolean;
|
|
395
|
-
roles?: UserRole[];
|
|
396
|
-
metaData?: UserMetaData;
|
|
397
|
-
};
|
|
398
|
-
type ListUsersOptions = PaginationOptions & {
|
|
399
|
-
firstName?: string;
|
|
400
|
-
lastName?: string;
|
|
401
|
-
email?: string;
|
|
402
|
-
};
|
|
403
|
-
type UpdateUserInput = {
|
|
404
|
-
firstName?: string;
|
|
405
|
-
lastName?: string;
|
|
406
|
-
email?: string;
|
|
407
|
-
name?: string;
|
|
408
|
-
zip?: string;
|
|
409
|
-
phone?: string;
|
|
410
|
-
roles?: UserRole[];
|
|
411
|
-
signUpMode?: SIGN_UP_MODE;
|
|
412
|
-
allowTexts?: boolean;
|
|
413
|
-
metaData?: UserMetaData;
|
|
414
|
-
};
|
|
415
|
-
type UpdatePasswordInput = {
|
|
416
|
-
oldPassword?: string;
|
|
417
|
-
newPassword: string;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
132
|
declare class UsersResource extends BaseResource {
|
|
421
133
|
protected readonly resourceBasePath = "/users";
|
|
422
|
-
list: (options?:
|
|
423
|
-
get: (id: number) => Promise<
|
|
424
|
-
update: (id: number, input: UpdateUserInput) => Promise<
|
|
134
|
+
list: (options?: ListUsersPagination) => Promise<PaginatedList<ReadUserOutput>>;
|
|
135
|
+
get: (id: number) => Promise<ReadUserOutput>;
|
|
136
|
+
update: (id: number, input: UpdateUserInput) => Promise<ReadUserOutput>;
|
|
425
137
|
delete: (id: number) => Promise<void>;
|
|
426
138
|
updatePassword: (id: number, input: UpdatePasswordInput) => Promise<void>;
|
|
427
139
|
}
|
|
@@ -441,4 +153,20 @@ declare class GoodPartyClient {
|
|
|
441
153
|
destroy: () => void;
|
|
442
154
|
}
|
|
443
155
|
|
|
444
|
-
|
|
156
|
+
declare class SdkError extends Error {
|
|
157
|
+
readonly status: number;
|
|
158
|
+
readonly response?: Response;
|
|
159
|
+
constructor(status: number, message: string, response?: Response);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type EnumObject<T extends readonly string[]> = {
|
|
163
|
+
[K in T[number]]: K;
|
|
164
|
+
};
|
|
165
|
+
type UserRole = UserRole$1;
|
|
166
|
+
declare const UserRole: EnumObject<readonly ["admin", "sales", "candidate", "campaignManager", "demo"]>;
|
|
167
|
+
type WhyBrowsing = WhyBrowsing$1;
|
|
168
|
+
declare const WhyBrowsing: EnumObject<readonly ["considering", "learning", "test", "else"]>;
|
|
169
|
+
type CampaignTier = CampaignTier$1;
|
|
170
|
+
declare const CampaignTier: EnumObject<readonly ["WIN", "LOSE", "TOSSUP"]>;
|
|
171
|
+
|
|
172
|
+
export { CampaignTier, type ElectedOffice, GoodPartyClient, type GoodPartyClientConfig, type ListElectedOfficesOptions, type ListPathsToVictoryOptions, P2VSource, P2VStatus, type PathToVictory, type PathToVictoryData, SdkError, type UpdateElectedOfficeInput, type UpdatePathToVictoryInput, UserRole, type ViabilityScore, WhyBrowsing };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,230 +1,7 @@
|
|
|
1
|
+
import { ReadCampaignOutput, ListCampaignsPagination, PaginatedList, UpdateCampaignM2MInput, PaginationOptions, ListUsersPagination, ReadUserOutput, UpdateUserInput, UpdatePasswordInput, CampaignTier as CampaignTier$1, UserRole as UserRole$1, WhyBrowsing as WhyBrowsing$1 } from '@goodparty_org/contracts';
|
|
2
|
+
export { AiChatMessage, AiContentData, AiContentGenerationStatus, AiContentInputValues, BALLOT_READY_POSITION_LEVEL_VALUES, BallotReadyPositionLevel, CAMPAIGN_CREATED_BY_VALUES, CAMPAIGN_LAUNCH_STATUS_VALUES, CAMPAIGN_STATUS_VALUES, CAMPAIGN_TIER_VALUES, ReadCampaignOutput as Campaign, CampaignAiContent, CampaignCreatedBy, CampaignData, CampaignDetails, CampaignFinance, CampaignLaunchStatus, CampaignPlan, CampaignPlanStatus, CampaignStatus, CustomIssue, CustomVoterFile, ELECTION_LEVEL_VALUES, ElectionLevel, GENERATION_STATUS_VALUES, GenerationStatus, GeoLocation, HubSpotUpdates, ListCampaignsPagination, ListUsersPagination, ONBOARDING_STEP_VALUES, OnboardingStep, Opponent, PaginatedList, PaginationMeta, PaginationOptions, ReadCampaignOutput, ReadUserOutput, USER_ROLE_VALUES, UpdateCampaignM2MInput, UpdatePasswordInput, UpdateUserInput, ReadUserOutput as User, UserMetaData, VoterGoals, WHY_BROWSING_VALUES } from '@goodparty_org/contracts';
|
|
1
3
|
import { FetchOptions } from 'ofetch';
|
|
2
4
|
|
|
3
|
-
declare class SdkError extends Error {
|
|
4
|
-
readonly status: number;
|
|
5
|
-
readonly response?: Response;
|
|
6
|
-
constructor(status: number, message: string, response?: Response);
|
|
7
|
-
}
|
|
8
|
-
type PaginationOptions = {
|
|
9
|
-
offset?: number;
|
|
10
|
-
limit?: number;
|
|
11
|
-
sortBy?: string;
|
|
12
|
-
sortOrder?: 'asc' | 'desc';
|
|
13
|
-
};
|
|
14
|
-
type PaginationMeta = {
|
|
15
|
-
total: number;
|
|
16
|
-
offset: number;
|
|
17
|
-
limit: number;
|
|
18
|
-
};
|
|
19
|
-
type PaginatedList<T> = {
|
|
20
|
-
data: T[];
|
|
21
|
-
meta: PaginationMeta;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
declare enum CampaignTier {
|
|
25
|
-
WIN = "WIN",
|
|
26
|
-
LOSE = "LOSE",
|
|
27
|
-
TOSSUP = "TOSSUP"
|
|
28
|
-
}
|
|
29
|
-
declare enum BallotReadyPositionLevel {
|
|
30
|
-
CITY = "CITY",
|
|
31
|
-
COUNTY = "COUNTY",
|
|
32
|
-
FEDERAL = "FEDERAL",
|
|
33
|
-
LOCAL = "LOCAL",
|
|
34
|
-
REGIONAL = "REGIONAL",
|
|
35
|
-
STATE = "STATE",
|
|
36
|
-
TOWNSHIP = "TOWNSHIP"
|
|
37
|
-
}
|
|
38
|
-
declare enum ElectionLevel {
|
|
39
|
-
state = "state",
|
|
40
|
-
county = "county",
|
|
41
|
-
federal = "federal",
|
|
42
|
-
city = "city"
|
|
43
|
-
}
|
|
44
|
-
declare enum CampaignCreatedBy {
|
|
45
|
-
ADMIN = "admin"
|
|
46
|
-
}
|
|
47
|
-
declare enum CampaignLaunchStatus {
|
|
48
|
-
launched = "launched"
|
|
49
|
-
}
|
|
50
|
-
declare enum OnboardingStep {
|
|
51
|
-
complete = "onboarding-complete",
|
|
52
|
-
registration = "registration"
|
|
53
|
-
}
|
|
54
|
-
declare enum GenerationStatus {
|
|
55
|
-
processing = "processing",
|
|
56
|
-
completed = "completed"
|
|
57
|
-
}
|
|
58
|
-
type VoterGoals = {
|
|
59
|
-
doorKnocking?: number;
|
|
60
|
-
calls?: number;
|
|
61
|
-
digital?: number;
|
|
62
|
-
directMail?: number;
|
|
63
|
-
digitalAds?: number;
|
|
64
|
-
text?: number;
|
|
65
|
-
events?: number;
|
|
66
|
-
yardSigns?: number;
|
|
67
|
-
robocall?: number;
|
|
68
|
-
phoneBanking?: number;
|
|
69
|
-
socialMedia?: number;
|
|
70
|
-
};
|
|
71
|
-
type CustomVoterFile = {
|
|
72
|
-
name: string;
|
|
73
|
-
channel?: string;
|
|
74
|
-
purpose?: string;
|
|
75
|
-
filters: string[];
|
|
76
|
-
createdAt: string;
|
|
77
|
-
};
|
|
78
|
-
type AiChatMessage = {
|
|
79
|
-
role: 'user' | 'system' | 'assistant';
|
|
80
|
-
content: string;
|
|
81
|
-
createdAt?: number;
|
|
82
|
-
id?: string;
|
|
83
|
-
usage?: number;
|
|
84
|
-
};
|
|
85
|
-
type AiContentInputValues = Record<string, string | boolean | number | undefined>;
|
|
86
|
-
type AiContentGenerationStatus = {
|
|
87
|
-
status: GenerationStatus;
|
|
88
|
-
createdAt: number;
|
|
89
|
-
prompt?: string;
|
|
90
|
-
existingChat?: AiChatMessage[];
|
|
91
|
-
inputValues?: AiContentInputValues;
|
|
92
|
-
};
|
|
93
|
-
type AiContentData = {
|
|
94
|
-
name: string;
|
|
95
|
-
content: string;
|
|
96
|
-
updatedAt: number;
|
|
97
|
-
inputValues?: AiContentInputValues;
|
|
98
|
-
};
|
|
99
|
-
type GeoLocation = {
|
|
100
|
-
geoHash?: string;
|
|
101
|
-
lng?: number;
|
|
102
|
-
lat?: number;
|
|
103
|
-
};
|
|
104
|
-
type CustomIssue = {
|
|
105
|
-
title: string;
|
|
106
|
-
position: string;
|
|
107
|
-
};
|
|
108
|
-
type Opponent = {
|
|
109
|
-
name: string;
|
|
110
|
-
party: string;
|
|
111
|
-
description: string;
|
|
112
|
-
};
|
|
113
|
-
type HubSpotUpdates = Partial<Record<string, string>>;
|
|
114
|
-
type CampaignDetails = {
|
|
115
|
-
state?: string;
|
|
116
|
-
ballotLevel?: BallotReadyPositionLevel;
|
|
117
|
-
electionDate?: string;
|
|
118
|
-
primaryElectionDate?: string;
|
|
119
|
-
zip?: string | null;
|
|
120
|
-
knowRun?: 'yes' | null;
|
|
121
|
-
runForOffice?: 'yes' | 'no' | null;
|
|
122
|
-
pledged?: boolean;
|
|
123
|
-
isProUpdatedAt?: number;
|
|
124
|
-
customIssues?: CustomIssue[];
|
|
125
|
-
runningAgainst?: Opponent[];
|
|
126
|
-
geoLocation?: GeoLocation;
|
|
127
|
-
geoLocationFailed?: boolean;
|
|
128
|
-
city?: string | null;
|
|
129
|
-
county?: string | null;
|
|
130
|
-
normalizedOffice?: string | null;
|
|
131
|
-
otherOffice?: string;
|
|
132
|
-
office?: string;
|
|
133
|
-
party?: string;
|
|
134
|
-
otherParty?: string;
|
|
135
|
-
district?: string;
|
|
136
|
-
raceId?: string;
|
|
137
|
-
level?: ElectionLevel | null;
|
|
138
|
-
noNormalizedOffice?: boolean;
|
|
139
|
-
website?: string;
|
|
140
|
-
pastExperience?: string | Record<string, string>;
|
|
141
|
-
occupation?: string;
|
|
142
|
-
funFact?: string;
|
|
143
|
-
campaignCommittee?: string;
|
|
144
|
-
statementName?: string;
|
|
145
|
-
subscriptionId?: string | null;
|
|
146
|
-
endOfElectionSubscriptionCanceled?: boolean;
|
|
147
|
-
subscriptionCanceledAt?: number | null;
|
|
148
|
-
subscriptionCancelAt?: number | null;
|
|
149
|
-
filingPeriodsStart?: string | null;
|
|
150
|
-
filingPeriodsEnd?: string | null;
|
|
151
|
-
officeTermLength?: string;
|
|
152
|
-
partisanType?: string;
|
|
153
|
-
priorElectionDates?: string[];
|
|
154
|
-
positionId?: string | null;
|
|
155
|
-
electionId?: string | null;
|
|
156
|
-
tier?: string;
|
|
157
|
-
einNumber?: string | null;
|
|
158
|
-
einSupportingDocument?: string | null;
|
|
159
|
-
wonGeneral?: boolean;
|
|
160
|
-
};
|
|
161
|
-
type CampaignData = {
|
|
162
|
-
createdBy?: CampaignCreatedBy;
|
|
163
|
-
slug?: string;
|
|
164
|
-
hubSpotUpdates?: HubSpotUpdates;
|
|
165
|
-
currentStep?: OnboardingStep;
|
|
166
|
-
launchStatus?: CampaignLaunchStatus;
|
|
167
|
-
lastVisited?: number;
|
|
168
|
-
claimProfile?: string;
|
|
169
|
-
customVoterFiles?: CustomVoterFile[];
|
|
170
|
-
reportedVoterGoals?: VoterGoals;
|
|
171
|
-
textCampaignCount?: number;
|
|
172
|
-
lastStepDate?: string;
|
|
173
|
-
adminUserEmail?: string;
|
|
174
|
-
hubspotId?: string;
|
|
175
|
-
name?: string;
|
|
176
|
-
};
|
|
177
|
-
type CampaignAiContent = {
|
|
178
|
-
generationStatus?: Record<string, AiContentGenerationStatus>;
|
|
179
|
-
campaignPlanAttempts?: Record<string, number>;
|
|
180
|
-
} & Record<string, AiContentData>;
|
|
181
|
-
type Campaign = {
|
|
182
|
-
id: number;
|
|
183
|
-
createdAt: string;
|
|
184
|
-
updatedAt: string;
|
|
185
|
-
slug: string;
|
|
186
|
-
isActive: boolean;
|
|
187
|
-
isVerified?: boolean | null;
|
|
188
|
-
isPro?: boolean | null;
|
|
189
|
-
isDemo: boolean;
|
|
190
|
-
didWin?: boolean | null;
|
|
191
|
-
dateVerified?: string | null;
|
|
192
|
-
tier?: CampaignTier | null;
|
|
193
|
-
formattedAddress?: string | null;
|
|
194
|
-
placeId?: string | null;
|
|
195
|
-
data: CampaignData;
|
|
196
|
-
details: CampaignDetails;
|
|
197
|
-
aiContent: CampaignAiContent;
|
|
198
|
-
userId: number;
|
|
199
|
-
canDownloadFederal: boolean;
|
|
200
|
-
completedTaskIds: string[];
|
|
201
|
-
hasFreeTextsOffer: boolean;
|
|
202
|
-
freeTextsOfferRedeemedAt?: string | null;
|
|
203
|
-
};
|
|
204
|
-
type ListCampaignsOptions = PaginationOptions & {
|
|
205
|
-
userId?: number;
|
|
206
|
-
slug?: string;
|
|
207
|
-
};
|
|
208
|
-
type UpdateCampaignInput = {
|
|
209
|
-
slug?: string;
|
|
210
|
-
isActive?: boolean;
|
|
211
|
-
isVerified?: boolean | null;
|
|
212
|
-
isPro?: boolean | null;
|
|
213
|
-
isDemo?: boolean;
|
|
214
|
-
didWin?: boolean | null;
|
|
215
|
-
dateVerified?: string | null;
|
|
216
|
-
tier?: CampaignTier | null;
|
|
217
|
-
formattedAddress?: string | null;
|
|
218
|
-
placeId?: string | null;
|
|
219
|
-
data?: CampaignData;
|
|
220
|
-
details?: CampaignDetails;
|
|
221
|
-
aiContent?: CampaignAiContent;
|
|
222
|
-
canDownloadFederal?: boolean;
|
|
223
|
-
completedTaskIds?: string[];
|
|
224
|
-
hasFreeTextsOffer?: boolean;
|
|
225
|
-
freeTextsOfferRedeemedAt?: string | null;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
5
|
type OfetchRequestBody = FetchOptions<'json'>['body'];
|
|
229
6
|
declare class HttpClient {
|
|
230
7
|
private baseUrl;
|
|
@@ -245,9 +22,9 @@ declare abstract class BaseResource {
|
|
|
245
22
|
|
|
246
23
|
declare class CampaignsResource extends BaseResource {
|
|
247
24
|
protected readonly resourceBasePath = "/campaigns";
|
|
248
|
-
get: (id: number) => Promise<
|
|
249
|
-
list: (options?:
|
|
250
|
-
update: (id: number, input:
|
|
25
|
+
get: (id: number) => Promise<ReadCampaignOutput>;
|
|
26
|
+
list: (options?: ListCampaignsPagination) => Promise<PaginatedList<ReadCampaignOutput>>;
|
|
27
|
+
update: (id: number, input: UpdateCampaignM2MInput) => Promise<ReadCampaignOutput>;
|
|
251
28
|
}
|
|
252
29
|
|
|
253
30
|
type ElectedOffice = {
|
|
@@ -352,76 +129,11 @@ declare class PathsToVictoryResource extends BaseResource {
|
|
|
352
129
|
update: (id: number, input: UpdatePathToVictoryInput) => Promise<PathToVictory>;
|
|
353
130
|
}
|
|
354
131
|
|
|
355
|
-
declare enum UserRole {
|
|
356
|
-
admin = "admin",
|
|
357
|
-
sales = "sales",
|
|
358
|
-
candidate = "candidate",
|
|
359
|
-
campaignManager = "campaignManager",
|
|
360
|
-
demo = "demo"
|
|
361
|
-
}
|
|
362
|
-
declare enum WhyBrowsing {
|
|
363
|
-
considering = "considering",
|
|
364
|
-
learning = "learning",
|
|
365
|
-
test = "test",
|
|
366
|
-
else = "else"
|
|
367
|
-
}
|
|
368
|
-
declare enum SIGN_UP_MODE {
|
|
369
|
-
CANDIDATE = "candidate",
|
|
370
|
-
FACILITATED = "facilitated"
|
|
371
|
-
}
|
|
372
|
-
type UserMetaData = {
|
|
373
|
-
customerId?: string;
|
|
374
|
-
checkoutSessionId?: string | null;
|
|
375
|
-
accountType?: string | null;
|
|
376
|
-
lastVisited?: number;
|
|
377
|
-
sessionCount?: number;
|
|
378
|
-
isDeleted?: boolean;
|
|
379
|
-
fsUserId?: string;
|
|
380
|
-
whyBrowsing?: WhyBrowsing | null;
|
|
381
|
-
hubspotId?: string;
|
|
382
|
-
profile_updated_count?: number;
|
|
383
|
-
textNotifications?: boolean;
|
|
384
|
-
} | null;
|
|
385
|
-
type User = {
|
|
386
|
-
id: number;
|
|
387
|
-
firstName: string;
|
|
388
|
-
lastName: string;
|
|
389
|
-
name?: string | null;
|
|
390
|
-
email: string;
|
|
391
|
-
phone?: string | null;
|
|
392
|
-
zip?: string | null;
|
|
393
|
-
avatar?: string | null;
|
|
394
|
-
hasPassword: boolean;
|
|
395
|
-
roles?: UserRole[];
|
|
396
|
-
metaData?: UserMetaData;
|
|
397
|
-
};
|
|
398
|
-
type ListUsersOptions = PaginationOptions & {
|
|
399
|
-
firstName?: string;
|
|
400
|
-
lastName?: string;
|
|
401
|
-
email?: string;
|
|
402
|
-
};
|
|
403
|
-
type UpdateUserInput = {
|
|
404
|
-
firstName?: string;
|
|
405
|
-
lastName?: string;
|
|
406
|
-
email?: string;
|
|
407
|
-
name?: string;
|
|
408
|
-
zip?: string;
|
|
409
|
-
phone?: string;
|
|
410
|
-
roles?: UserRole[];
|
|
411
|
-
signUpMode?: SIGN_UP_MODE;
|
|
412
|
-
allowTexts?: boolean;
|
|
413
|
-
metaData?: UserMetaData;
|
|
414
|
-
};
|
|
415
|
-
type UpdatePasswordInput = {
|
|
416
|
-
oldPassword?: string;
|
|
417
|
-
newPassword: string;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
132
|
declare class UsersResource extends BaseResource {
|
|
421
133
|
protected readonly resourceBasePath = "/users";
|
|
422
|
-
list: (options?:
|
|
423
|
-
get: (id: number) => Promise<
|
|
424
|
-
update: (id: number, input: UpdateUserInput) => Promise<
|
|
134
|
+
list: (options?: ListUsersPagination) => Promise<PaginatedList<ReadUserOutput>>;
|
|
135
|
+
get: (id: number) => Promise<ReadUserOutput>;
|
|
136
|
+
update: (id: number, input: UpdateUserInput) => Promise<ReadUserOutput>;
|
|
425
137
|
delete: (id: number) => Promise<void>;
|
|
426
138
|
updatePassword: (id: number, input: UpdatePasswordInput) => Promise<void>;
|
|
427
139
|
}
|
|
@@ -441,4 +153,20 @@ declare class GoodPartyClient {
|
|
|
441
153
|
destroy: () => void;
|
|
442
154
|
}
|
|
443
155
|
|
|
444
|
-
|
|
156
|
+
declare class SdkError extends Error {
|
|
157
|
+
readonly status: number;
|
|
158
|
+
readonly response?: Response;
|
|
159
|
+
constructor(status: number, message: string, response?: Response);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type EnumObject<T extends readonly string[]> = {
|
|
163
|
+
[K in T[number]]: K;
|
|
164
|
+
};
|
|
165
|
+
type UserRole = UserRole$1;
|
|
166
|
+
declare const UserRole: EnumObject<readonly ["admin", "sales", "candidate", "campaignManager", "demo"]>;
|
|
167
|
+
type WhyBrowsing = WhyBrowsing$1;
|
|
168
|
+
declare const WhyBrowsing: EnumObject<readonly ["considering", "learning", "test", "else"]>;
|
|
169
|
+
type CampaignTier = CampaignTier$1;
|
|
170
|
+
declare const CampaignTier: EnumObject<readonly ["WIN", "LOSE", "TOSSUP"]>;
|
|
171
|
+
|
|
172
|
+
export { CampaignTier, type ElectedOffice, GoodPartyClient, type GoodPartyClientConfig, type ListElectedOfficesOptions, type ListPathsToVictoryOptions, P2VSource, P2VStatus, type PathToVictory, type PathToVictoryData, SdkError, type UpdateElectedOfficeInput, type UpdatePathToVictoryInput, UserRole, type ViabilityScore, WhyBrowsing };
|
package/dist/index.js
CHANGED
|
@@ -20,18 +20,29 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
BALLOT_READY_POSITION_LEVEL_VALUES: () => import_contracts2.BALLOT_READY_POSITION_LEVEL_VALUES,
|
|
24
|
+
BallotReadyPositionLevel: () => import_contracts2.BallotReadyPositionLevel,
|
|
25
|
+
CAMPAIGN_CREATED_BY_VALUES: () => import_contracts2.CAMPAIGN_CREATED_BY_VALUES,
|
|
26
|
+
CAMPAIGN_LAUNCH_STATUS_VALUES: () => import_contracts2.CAMPAIGN_LAUNCH_STATUS_VALUES,
|
|
27
|
+
CAMPAIGN_STATUS_VALUES: () => import_contracts2.CAMPAIGN_STATUS_VALUES,
|
|
28
|
+
CAMPAIGN_TIER_VALUES: () => import_contracts2.CAMPAIGN_TIER_VALUES,
|
|
29
|
+
CampaignCreatedBy: () => import_contracts2.CampaignCreatedBy,
|
|
30
|
+
CampaignLaunchStatus: () => import_contracts2.CampaignLaunchStatus,
|
|
31
|
+
CampaignStatus: () => import_contracts2.CampaignStatus,
|
|
26
32
|
CampaignTier: () => CampaignTier,
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
ELECTION_LEVEL_VALUES: () => import_contracts2.ELECTION_LEVEL_VALUES,
|
|
34
|
+
ElectionLevel: () => import_contracts2.ElectionLevel,
|
|
35
|
+
GENERATION_STATUS_VALUES: () => import_contracts2.GENERATION_STATUS_VALUES,
|
|
36
|
+
GenerationStatus: () => import_contracts2.GenerationStatus,
|
|
29
37
|
GoodPartyClient: () => GoodPartyClient,
|
|
30
|
-
|
|
38
|
+
ONBOARDING_STEP_VALUES: () => import_contracts2.ONBOARDING_STEP_VALUES,
|
|
39
|
+
OnboardingStep: () => import_contracts2.OnboardingStep,
|
|
31
40
|
P2VSource: () => P2VSource,
|
|
32
41
|
P2VStatus: () => P2VStatus,
|
|
33
42
|
SdkError: () => SdkError,
|
|
43
|
+
USER_ROLE_VALUES: () => import_contracts2.USER_ROLE_VALUES,
|
|
34
44
|
UserRole: () => UserRole,
|
|
45
|
+
WHY_BROWSING_VALUES: () => import_contracts2.WHY_BROWSING_VALUES,
|
|
35
46
|
WhyBrowsing: () => WhyBrowsing
|
|
36
47
|
});
|
|
37
48
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -127,7 +138,10 @@ var PathsToVictoryResource = class extends BaseResource {
|
|
|
127
138
|
// src/resources/UsersResource.ts
|
|
128
139
|
var UsersResource = class extends BaseResource {
|
|
129
140
|
resourceBasePath = "/users";
|
|
130
|
-
list = (options) => this.getRequest(
|
|
141
|
+
list = (options) => this.getRequest(
|
|
142
|
+
this.resourceBasePath,
|
|
143
|
+
options
|
|
144
|
+
);
|
|
131
145
|
get = (id) => this.getRequest(`/users/${id}`);
|
|
132
146
|
update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
|
|
133
147
|
delete = (id) => this.deleteRequest(`${this.resourceBasePath}/${id}`);
|
|
@@ -247,65 +261,15 @@ var GoodPartyClient = class _GoodPartyClient {
|
|
|
247
261
|
};
|
|
248
262
|
};
|
|
249
263
|
|
|
250
|
-
// src/
|
|
251
|
-
var
|
|
252
|
-
UserRole2["admin"] = "admin";
|
|
253
|
-
UserRole2["sales"] = "sales";
|
|
254
|
-
UserRole2["candidate"] = "candidate";
|
|
255
|
-
UserRole2["campaignManager"] = "campaignManager";
|
|
256
|
-
UserRole2["demo"] = "demo";
|
|
257
|
-
return UserRole2;
|
|
258
|
-
})(UserRole || {});
|
|
259
|
-
var WhyBrowsing = /* @__PURE__ */ ((WhyBrowsing2) => {
|
|
260
|
-
WhyBrowsing2["considering"] = "considering";
|
|
261
|
-
WhyBrowsing2["learning"] = "learning";
|
|
262
|
-
WhyBrowsing2["test"] = "test";
|
|
263
|
-
WhyBrowsing2["else"] = "else";
|
|
264
|
-
return WhyBrowsing2;
|
|
265
|
-
})(WhyBrowsing || {});
|
|
264
|
+
// src/index.ts
|
|
265
|
+
var import_contracts2 = require("@goodparty_org/contracts");
|
|
266
266
|
|
|
267
|
-
// src/
|
|
268
|
-
var
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
})(CampaignTier || {});
|
|
274
|
-
var BallotReadyPositionLevel = /* @__PURE__ */ ((BallotReadyPositionLevel2) => {
|
|
275
|
-
BallotReadyPositionLevel2["CITY"] = "CITY";
|
|
276
|
-
BallotReadyPositionLevel2["COUNTY"] = "COUNTY";
|
|
277
|
-
BallotReadyPositionLevel2["FEDERAL"] = "FEDERAL";
|
|
278
|
-
BallotReadyPositionLevel2["LOCAL"] = "LOCAL";
|
|
279
|
-
BallotReadyPositionLevel2["REGIONAL"] = "REGIONAL";
|
|
280
|
-
BallotReadyPositionLevel2["STATE"] = "STATE";
|
|
281
|
-
BallotReadyPositionLevel2["TOWNSHIP"] = "TOWNSHIP";
|
|
282
|
-
return BallotReadyPositionLevel2;
|
|
283
|
-
})(BallotReadyPositionLevel || {});
|
|
284
|
-
var ElectionLevel = /* @__PURE__ */ ((ElectionLevel2) => {
|
|
285
|
-
ElectionLevel2["state"] = "state";
|
|
286
|
-
ElectionLevel2["county"] = "county";
|
|
287
|
-
ElectionLevel2["federal"] = "federal";
|
|
288
|
-
ElectionLevel2["city"] = "city";
|
|
289
|
-
return ElectionLevel2;
|
|
290
|
-
})(ElectionLevel || {});
|
|
291
|
-
var CampaignCreatedBy = /* @__PURE__ */ ((CampaignCreatedBy2) => {
|
|
292
|
-
CampaignCreatedBy2["ADMIN"] = "admin";
|
|
293
|
-
return CampaignCreatedBy2;
|
|
294
|
-
})(CampaignCreatedBy || {});
|
|
295
|
-
var CampaignLaunchStatus = /* @__PURE__ */ ((CampaignLaunchStatus2) => {
|
|
296
|
-
CampaignLaunchStatus2["launched"] = "launched";
|
|
297
|
-
return CampaignLaunchStatus2;
|
|
298
|
-
})(CampaignLaunchStatus || {});
|
|
299
|
-
var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
|
|
300
|
-
OnboardingStep2["complete"] = "onboarding-complete";
|
|
301
|
-
OnboardingStep2["registration"] = "registration";
|
|
302
|
-
return OnboardingStep2;
|
|
303
|
-
})(OnboardingStep || {});
|
|
304
|
-
var GenerationStatus = /* @__PURE__ */ ((GenerationStatus2) => {
|
|
305
|
-
GenerationStatus2["processing"] = "processing";
|
|
306
|
-
GenerationStatus2["completed"] = "completed";
|
|
307
|
-
return GenerationStatus2;
|
|
308
|
-
})(GenerationStatus || {});
|
|
267
|
+
// src/enums.ts
|
|
268
|
+
var import_contracts = require("@goodparty_org/contracts");
|
|
269
|
+
var toEnumObject = (values) => Object.fromEntries(values.map((v) => [v, v]));
|
|
270
|
+
var UserRole = toEnumObject(import_contracts.USER_ROLE_VALUES);
|
|
271
|
+
var WhyBrowsing = toEnumObject(import_contracts.WHY_BROWSING_VALUES);
|
|
272
|
+
var CampaignTier = toEnumObject(import_contracts.CAMPAIGN_TIER_VALUES);
|
|
309
273
|
|
|
310
274
|
// src/types/pathToVictory.ts
|
|
311
275
|
var P2VStatus = /* @__PURE__ */ ((P2VStatus2) => {
|
|
@@ -322,18 +286,29 @@ var P2VSource = /* @__PURE__ */ ((P2VSource2) => {
|
|
|
322
286
|
})(P2VSource || {});
|
|
323
287
|
// Annotate the CommonJS export names for ESM import in node:
|
|
324
288
|
0 && (module.exports = {
|
|
289
|
+
BALLOT_READY_POSITION_LEVEL_VALUES,
|
|
325
290
|
BallotReadyPositionLevel,
|
|
291
|
+
CAMPAIGN_CREATED_BY_VALUES,
|
|
292
|
+
CAMPAIGN_LAUNCH_STATUS_VALUES,
|
|
293
|
+
CAMPAIGN_STATUS_VALUES,
|
|
294
|
+
CAMPAIGN_TIER_VALUES,
|
|
326
295
|
CampaignCreatedBy,
|
|
327
296
|
CampaignLaunchStatus,
|
|
297
|
+
CampaignStatus,
|
|
328
298
|
CampaignTier,
|
|
299
|
+
ELECTION_LEVEL_VALUES,
|
|
329
300
|
ElectionLevel,
|
|
301
|
+
GENERATION_STATUS_VALUES,
|
|
330
302
|
GenerationStatus,
|
|
331
303
|
GoodPartyClient,
|
|
304
|
+
ONBOARDING_STEP_VALUES,
|
|
332
305
|
OnboardingStep,
|
|
333
306
|
P2VSource,
|
|
334
307
|
P2VStatus,
|
|
335
308
|
SdkError,
|
|
309
|
+
USER_ROLE_VALUES,
|
|
336
310
|
UserRole,
|
|
311
|
+
WHY_BROWSING_VALUES,
|
|
337
312
|
WhyBrowsing
|
|
338
313
|
});
|
|
339
314
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/http/HttpClient.ts","../src/types/result.ts","../src/resources/BaseResource.ts","../src/resources/CampaignsResource.ts","../src/resources/ElectedOfficesResource.ts","../src/resources/PathsToVictoryResource.ts","../src/resources/UsersResource.ts","../src/vendor/clerk/clerk.service.ts","../src/GoodPartyClient.ts","../src/types/user.ts","../src/types/campaign.ts","../src/types/pathToVictory.ts"],"sourcesContent":["export { GoodPartyClient } from './GoodPartyClient'\nexport type { GoodPartyClientConfig } from './GoodPartyClient'\n\nexport { SdkError } from './types/result'\nexport type {\n PaginationOptions,\n PaginationMeta,\n PaginatedList,\n} from './types/result'\n\nexport type {\n User,\n UserMetaData,\n ListUsersOptions,\n UpdateUserInput,\n UpdatePasswordInput,\n} from './types/user'\n\nexport { UserRole, WhyBrowsing } from './types/user'\n\nexport type {\n Campaign,\n CampaignDetails,\n CampaignData,\n CampaignAiContent,\n VoterGoals,\n CustomVoterFile,\n AiChatMessage,\n AiContentInputValues,\n AiContentGenerationStatus,\n AiContentData,\n ListCampaignsOptions,\n UpdateCampaignInput,\n GeoLocation,\n CustomIssue,\n Opponent,\n HubSpotUpdates,\n} from './types/campaign'\n\nexport {\n CampaignTier,\n BallotReadyPositionLevel,\n ElectionLevel,\n CampaignCreatedBy,\n CampaignLaunchStatus,\n OnboardingStep,\n GenerationStatus,\n} from './types/campaign'\n\nexport type {\n ElectedOffice,\n ListElectedOfficesOptions,\n UpdateElectedOfficeInput,\n} from './types/electedOffice'\n\nexport type {\n PathToVictory,\n PathToVictoryData,\n ViabilityScore,\n ListPathsToVictoryOptions,\n UpdatePathToVictoryInput,\n} from './types/pathToVictory'\n\nexport { P2VStatus, P2VSource } from './types/pathToVictory'\n","import { ofetch, FetchError, FetchOptions } from 'ofetch'\nimport { SdkError } from '../types/result'\n\nexport type OfetchRequestBody = FetchOptions<'json'>['body']\n\nexport class HttpClient {\n private baseUrl: string\n private getToken: () => Promise<string>\n\n constructor(gpApiRootUrl: string, getToken: () => Promise<string>) {\n this.baseUrl = gpApiRootUrl\n this.getToken = getToken\n }\n\n request = async <T>(\n path: string,\n init?: FetchOptions<'json'>,\n ): Promise<T> => {\n try {\n return await ofetch<T>(path, {\n baseURL: this.baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getToken()}`,\n ...(init?.headers ?? {}),\n },\n ...init,\n })\n } catch (error: unknown) {\n if (error instanceof FetchError) {\n throw new SdkError(error.statusCode ?? 0, error.message, error.response)\n }\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new SdkError(0, message)\n }\n }\n}\n","export class SdkError extends Error {\n readonly status: number\n readonly response?: Response\n\n constructor(status: number, message: string, response?: Response) {\n super(message)\n this.name = 'SdkError'\n this.status = status\n this.response = response\n }\n}\n\nexport type PaginationOptions = {\n offset?: number\n limit?: number\n sortBy?: string\n sortOrder?: 'asc' | 'desc'\n}\n\nexport type PaginationMeta = {\n total: number\n offset: number\n limit: number\n}\n\nexport type PaginatedList<T> = {\n data: T[]\n meta: PaginationMeta\n}\n","import type { FetchOptions } from 'ofetch'\nimport type { HttpClient, OfetchRequestBody } from '../http/HttpClient'\n\nexport abstract class BaseResource {\n protected httpClient: HttpClient\n protected abstract readonly resourceBasePath: string\n\n constructor(httpClient: HttpClient) {\n this.httpClient = httpClient\n }\n\n protected getRequest = <T>(\n path: string,\n query?: FetchOptions<'json'>['query'],\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'GET', query })\n\n protected postRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'POST', body })\n\n protected putRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'PUT', body })\n\n protected deleteRequest = <T>(path: string): Promise<T> =>\n this.httpClient.request<T>(path, { method: 'DELETE' })\n}\n","import type { PaginatedList } from '../types/result'\nimport type {\n Campaign,\n ListCampaignsOptions,\n UpdateCampaignInput,\n} from '../types/campaign'\nimport { BaseResource } from './BaseResource'\n\nexport class CampaignsResource extends BaseResource {\n protected readonly resourceBasePath = '/campaigns'\n\n get = (id: number): Promise<Campaign> =>\n this.getRequest<Campaign>(`${this.resourceBasePath}/${id}`)\n\n list = (options?: ListCampaignsOptions): Promise<PaginatedList<Campaign>> =>\n this.getRequest<PaginatedList<Campaign>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n update = (id: number, input: UpdateCampaignInput): Promise<Campaign> =>\n this.putRequest<Campaign>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '../types/result'\nimport type {\n ElectedOffice,\n ListElectedOfficesOptions,\n UpdateElectedOfficeInput,\n} from '../types/electedOffice'\nimport { BaseResource } from './BaseResource'\n\nexport class ElectedOfficesResource extends BaseResource {\n protected readonly resourceBasePath = '/elected-office'\n\n list = (\n options?: ListElectedOfficesOptions,\n ): Promise<PaginatedList<ElectedOffice>> =>\n this.getRequest<PaginatedList<ElectedOffice>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n get = (id: string): Promise<ElectedOffice> =>\n this.getRequest<ElectedOffice>(`${this.resourceBasePath}/${id}`)\n\n update = (\n id: string,\n input: UpdateElectedOfficeInput,\n ): Promise<ElectedOffice> =>\n this.putRequest<ElectedOffice>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '../types/result'\nimport type {\n ListPathsToVictoryOptions,\n PathToVictory,\n UpdatePathToVictoryInput,\n} from '../types/pathToVictory'\nimport { BaseResource } from './BaseResource'\n\nexport class PathsToVictoryResource extends BaseResource {\n protected resourceBasePath = '/path-to-victory'\n list = (\n options?: ListPathsToVictoryOptions,\n ): Promise<PaginatedList<PathToVictory>> =>\n this.getRequest<PaginatedList<PathToVictory>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n get = (id: number): Promise<PathToVictory> =>\n this.getRequest<PathToVictory>(`${this.resourceBasePath}/${id}`)\n\n update = (\n id: number,\n input: UpdatePathToVictoryInput,\n ): Promise<PathToVictory> =>\n this.putRequest<PathToVictory>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '../types/result'\nimport type {\n ListUsersOptions,\n UpdatePasswordInput,\n UpdateUserInput,\n User,\n} from '../types/user'\nimport { BaseResource } from './BaseResource'\n\nexport class UsersResource extends BaseResource {\n protected readonly resourceBasePath = '/users'\n\n list = (options?: ListUsersOptions): Promise<PaginatedList<User>> =>\n this.getRequest<PaginatedList<User>>(this.resourceBasePath, options)\n\n get = (id: number): Promise<User> => this.getRequest<User>(`/users/${id}`)\n\n update = (id: number, input: UpdateUserInput): Promise<User> =>\n this.putRequest<User>(`${this.resourceBasePath}/${id}`, input)\n\n delete = (id: number): Promise<void> =>\n this.deleteRequest<void>(`${this.resourceBasePath}/${id}`)\n\n updatePassword = (id: number, input: UpdatePasswordInput): Promise<void> =>\n this.putRequest<void>(`${this.resourceBasePath}/${id}/password`, input)\n}\n","import { createClerkClient } from '@clerk/backend'\nimport { SdkError } from '../../types/result'\n\nconst TOKEN_RENEWAL_BUFFER_MS = 30_000\n\nexport class ClerkService {\n private readonly m2mSecret: string\n private readonly clerkClient: ReturnType<typeof createClerkClient>\n private cachedToken: string | null = null\n private tokenExpiration: number | null = null\n private renewalTimer: ReturnType<typeof setTimeout> | null = null\n private pendingTokenPromise: Promise<string> | null = null\n private destroyed = false\n\n constructor(m2mSecret: string) {\n this.m2mSecret = m2mSecret\n this.clerkClient = createClerkClient({})\n }\n\n getToken = async (): Promise<string> => {\n if (this.cachedToken && this.isTokenValid()) {\n return this.cachedToken\n }\n\n if (this.pendingTokenPromise) {\n return this.pendingTokenPromise\n }\n\n const promise = this.createAndCacheToken()\n this.pendingTokenPromise = promise\n\n try {\n return await promise\n } finally {\n if (this.pendingTokenPromise === promise) {\n this.pendingTokenPromise = null\n }\n }\n }\n\n destroy = (): void => {\n this.destroyed = true\n if (this.renewalTimer) {\n clearTimeout(this.renewalTimer)\n this.renewalTimer = null\n }\n this.cachedToken = null\n this.tokenExpiration = null\n this.pendingTokenPromise = null\n }\n\n private isTokenValid = (): boolean => {\n if (!this.tokenExpiration) return true\n return Date.now() < this.tokenExpiration - TOKEN_RENEWAL_BUFFER_MS\n }\n\n private createAndCacheToken = async (): Promise<string> => {\n try {\n const m2mToken = await this.clerkClient.m2m.createToken({\n machineSecretKey: this.m2mSecret,\n })\n\n if (!m2mToken.token) {\n throw new SdkError(\n 0,\n 'Clerk M2M token creation succeeded but returned no token string',\n )\n }\n\n if (this.destroyed) return m2mToken.token\n\n this.cachedToken = m2mToken.token\n this.tokenExpiration = m2mToken.expiration\n this.scheduleRenewal()\n\n return this.cachedToken\n } catch (error: unknown) {\n if (error instanceof SdkError) {\n throw error\n }\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new SdkError(0, `Failed to create Clerk M2M token: ${message}`)\n }\n }\n\n private scheduleRenewal = (): void => {\n if (this.renewalTimer) {\n clearTimeout(this.renewalTimer)\n this.renewalTimer = null\n }\n\n if (!this.tokenExpiration) return\n\n const timeUntilRenewal =\n this.tokenExpiration - Date.now() - TOKEN_RENEWAL_BUFFER_MS\n\n if (timeUntilRenewal <= 0) return\n\n this.renewalTimer = setTimeout(() => {\n this.cachedToken = null\n this.getToken().catch((error: unknown) => {\n console.error('Proactive M2M token renewal failed:', error)\n })\n }, timeUntilRenewal)\n }\n}\n","import { HttpClient } from './http/HttpClient'\nimport { CampaignsResource } from './resources/CampaignsResource'\nimport { ElectedOfficesResource } from './resources/ElectedOfficesResource'\nimport { PathsToVictoryResource } from './resources/PathsToVictoryResource'\nimport { UsersResource } from './resources/UsersResource'\nimport { ClerkService } from './vendor/clerk/clerk.service'\n\nexport type GoodPartyClientConfig = {\n m2mSecret: string\n gpApiRootUrl: string\n}\n\nexport class GoodPartyClient {\n readonly users: UsersResource\n readonly campaigns: CampaignsResource\n readonly electedOffices: ElectedOfficesResource\n readonly pathsToVictory: PathsToVictoryResource\n private clerkService: ClerkService\n\n private constructor(clerkService: ClerkService, gpApiRootUrl: string) {\n this.clerkService = clerkService\n const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken)\n this.users = new UsersResource(httpClient)\n this.campaigns = new CampaignsResource(httpClient)\n this.electedOffices = new ElectedOfficesResource(httpClient)\n this.pathsToVictory = new PathsToVictoryResource(httpClient)\n }\n\n static create = async (\n config: GoodPartyClientConfig,\n ): Promise<GoodPartyClient> => {\n const { m2mSecret, gpApiRootUrl } = config\n const clerkService = new ClerkService(m2mSecret)\n await clerkService.getToken()\n return new GoodPartyClient(clerkService, gpApiRootUrl)\n }\n\n destroy = (): void => {\n this.clerkService.destroy()\n }\n}\n","import type { PaginationOptions } from './result'\n\nexport enum UserRole {\n admin = 'admin',\n sales = 'sales',\n candidate = 'candidate',\n campaignManager = 'campaignManager',\n demo = 'demo',\n}\n\nexport enum WhyBrowsing {\n considering = 'considering',\n learning = 'learning',\n test = 'test',\n else = 'else',\n}\n\nexport enum SIGN_UP_MODE {\n CANDIDATE = 'candidate',\n FACILITATED = 'facilitated',\n}\n\nexport type UserMetaData = {\n customerId?: string\n checkoutSessionId?: string | null\n accountType?: string | null\n lastVisited?: number\n sessionCount?: number\n isDeleted?: boolean\n fsUserId?: string\n whyBrowsing?: WhyBrowsing | null\n hubspotId?: string\n profile_updated_count?: number\n textNotifications?: boolean\n} | null\n\nexport type User = {\n id: number\n firstName: string\n lastName: string\n name?: string | null\n email: string\n phone?: string | null\n zip?: string | null\n avatar?: string | null\n hasPassword: boolean\n roles?: UserRole[]\n metaData?: UserMetaData\n}\n\nexport type ListUsersOptions = PaginationOptions & {\n firstName?: string\n lastName?: string\n email?: string\n}\n\nexport type UpdateUserInput = {\n firstName?: string\n lastName?: string\n email?: string\n name?: string\n zip?: string\n phone?: string\n roles?: UserRole[]\n signUpMode?: SIGN_UP_MODE\n allowTexts?: boolean\n metaData?: UserMetaData\n}\n\nexport type UpdatePasswordInput = {\n oldPassword?: string\n newPassword: string\n}\n","import type { PaginationOptions } from './result'\n\nexport enum CampaignTier {\n WIN = 'WIN',\n LOSE = 'LOSE',\n TOSSUP = 'TOSSUP',\n}\n\nexport enum BallotReadyPositionLevel {\n CITY = 'CITY',\n COUNTY = 'COUNTY',\n FEDERAL = 'FEDERAL',\n LOCAL = 'LOCAL',\n REGIONAL = 'REGIONAL',\n STATE = 'STATE',\n TOWNSHIP = 'TOWNSHIP',\n}\n\nexport enum ElectionLevel {\n state = 'state',\n county = 'county',\n federal = 'federal',\n city = 'city',\n}\n\nexport enum CampaignCreatedBy {\n ADMIN = 'admin',\n}\n\nexport enum CampaignLaunchStatus {\n launched = 'launched',\n}\n\nexport enum OnboardingStep {\n complete = 'onboarding-complete',\n registration = 'registration',\n}\n\nexport enum GenerationStatus {\n processing = 'processing',\n completed = 'completed',\n}\n\nexport type VoterGoals = {\n doorKnocking?: number\n calls?: number\n digital?: number\n directMail?: number\n digitalAds?: number\n text?: number\n events?: number\n yardSigns?: number\n robocall?: number\n phoneBanking?: number\n socialMedia?: number\n}\n\nexport type CustomVoterFile = {\n name: string\n channel?: string\n purpose?: string\n filters: string[]\n createdAt: string\n}\n\nexport type AiChatMessage = {\n role: 'user' | 'system' | 'assistant'\n content: string\n createdAt?: number\n id?: string\n usage?: number\n}\n\nexport type AiContentInputValues = Record<\n string,\n string | boolean | number | undefined\n>\n\nexport type AiContentGenerationStatus = {\n status: GenerationStatus\n createdAt: number\n prompt?: string\n existingChat?: AiChatMessage[]\n inputValues?: AiContentInputValues\n}\n\nexport type AiContentData = {\n name: string\n content: string\n updatedAt: number\n inputValues?: AiContentInputValues\n}\n\nexport type GeoLocation = { geoHash?: string; lng?: number; lat?: number }\n\nexport type CustomIssue = { title: string; position: string }\n\nexport type Opponent = { name: string; party: string; description: string }\n\nexport type HubSpotUpdates = Partial<Record<string, string>>\n\nexport type CampaignDetails = {\n state?: string\n ballotLevel?: BallotReadyPositionLevel\n electionDate?: string\n primaryElectionDate?: string\n zip?: string | null\n knowRun?: 'yes' | null\n runForOffice?: 'yes' | 'no' | null\n pledged?: boolean\n isProUpdatedAt?: number\n customIssues?: CustomIssue[]\n runningAgainst?: Opponent[]\n geoLocation?: GeoLocation\n geoLocationFailed?: boolean\n city?: string | null\n county?: string | null\n normalizedOffice?: string | null\n otherOffice?: string\n office?: string\n party?: string\n otherParty?: string\n district?: string\n raceId?: string\n level?: ElectionLevel | null\n noNormalizedOffice?: boolean\n website?: string\n pastExperience?: string | Record<string, string>\n occupation?: string\n funFact?: string\n campaignCommittee?: string\n statementName?: string\n subscriptionId?: string | null\n endOfElectionSubscriptionCanceled?: boolean\n subscriptionCanceledAt?: number | null\n subscriptionCancelAt?: number | null\n filingPeriodsStart?: string | null\n filingPeriodsEnd?: string | null\n officeTermLength?: string\n partisanType?: string\n priorElectionDates?: string[]\n positionId?: string | null\n electionId?: string | null\n tier?: string\n einNumber?: string | null\n einSupportingDocument?: string | null\n wonGeneral?: boolean\n}\n\nexport type CampaignData = {\n createdBy?: CampaignCreatedBy\n slug?: string\n hubSpotUpdates?: HubSpotUpdates\n currentStep?: OnboardingStep\n launchStatus?: CampaignLaunchStatus\n lastVisited?: number\n claimProfile?: string\n customVoterFiles?: CustomVoterFile[]\n reportedVoterGoals?: VoterGoals\n textCampaignCount?: number\n lastStepDate?: string\n adminUserEmail?: string\n hubspotId?: string\n name?: string\n}\n\nexport type CampaignAiContent = {\n generationStatus?: Record<string, AiContentGenerationStatus>\n campaignPlanAttempts?: Record<string, number>\n} & Record<string, AiContentData>\n\nexport type Campaign = {\n id: number\n createdAt: string\n updatedAt: string\n slug: string\n isActive: boolean\n isVerified?: boolean | null\n isPro?: boolean | null\n isDemo: boolean\n didWin?: boolean | null\n dateVerified?: string | null\n tier?: CampaignTier | null\n formattedAddress?: string | null\n placeId?: string | null\n data: CampaignData\n details: CampaignDetails\n aiContent: CampaignAiContent\n userId: number\n canDownloadFederal: boolean\n completedTaskIds: string[]\n hasFreeTextsOffer: boolean\n freeTextsOfferRedeemedAt?: string | null\n}\n\nexport type ListCampaignsOptions = PaginationOptions & {\n userId?: number\n slug?: string\n}\n\nexport type UpdateCampaignInput = {\n slug?: string\n isActive?: boolean\n isVerified?: boolean | null\n isPro?: boolean | null\n isDemo?: boolean\n didWin?: boolean | null\n dateVerified?: string | null\n tier?: CampaignTier | null\n formattedAddress?: string | null\n placeId?: string | null\n data?: CampaignData\n details?: CampaignDetails\n aiContent?: CampaignAiContent\n canDownloadFederal?: boolean\n completedTaskIds?: string[]\n hasFreeTextsOffer?: boolean\n freeTextsOfferRedeemedAt?: string | null\n}\n","import type { PaginationOptions } from './result'\n\nexport enum P2VStatus {\n complete = 'Complete',\n waiting = 'Waiting',\n failed = 'Failed',\n districtMatched = 'DistrictMatched',\n}\n\nexport enum P2VSource {\n GpApi = 'GpApi',\n ElectionApi = 'ElectionApi',\n}\n\nexport type ViabilityScore = {\n level: string\n isPartisan: boolean\n isIncumbent: boolean\n isUncontested: boolean\n candidates: number\n seats: number\n candidatesPerSeat: number\n score: number\n probOfWin: number\n}\n\nexport type PathToVictoryData = {\n p2vStatus?: P2VStatus\n p2vAttempts?: number\n p2vCompleteDate?: string\n completedBy?: number\n electionType?: string\n electionLocation?: string\n voterContactGoal?: number\n winNumber?: number\n p2vNotNeeded?: boolean\n totalRegisteredVoters?: number\n republicans?: number\n democrats?: number\n indies?: number\n women?: number\n men?: number\n white?: number\n asian?: number\n africanAmerican?: number\n hispanic?: number\n averageTurnout?: number\n projectedTurnout?: number\n viability?: ViabilityScore\n source?: P2VSource\n districtId?: string\n districtManuallySet?: boolean\n officeContextFingerprint?: string\n}\n\nexport type PathToVictory = {\n id: number\n createdAt: string\n updatedAt: string\n campaignId: number\n data: PathToVictoryData\n}\n\nexport type ListPathsToVictoryOptions = PaginationOptions & {\n userId?: number\n}\n\nexport type UpdatePathToVictoryInput = {\n data: PathToVictoryData\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAiD;;;ACA1C,IAAM,WAAN,cAAuB,MAAM;AAAA,EACzB;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,SAAiB,UAAqB;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AACF;;;ADLO,IAAM,aAAN,MAAiB;AAAA,EACd;AAAA,EACA;AAAA,EAER,YAAY,cAAsB,UAAiC;AACjE,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,UAAU,OACR,MACA,SACe;AACf,QAAI;AACF,aAAO,UAAM,sBAAU,MAAM;AAAA,QAC3B,SAAS,KAAK;AAAA,QACd,SAAS;AAAA,UACP,eAAe,UAAU,MAAM,KAAK,SAAS,CAAC;AAAA,UAC9C,GAAI,MAAM,WAAW,CAAC;AAAA,QACxB;AAAA,QACA,GAAG;AAAA,MACL,CAAC;AAA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iBAAc;AAFJ,SAAAA;AAAA,GAAA;","names":["UserRole","WhyBrowsing","CampaignTier","BallotReadyPositionLevel","ElectionLevel","CampaignCreatedBy","CampaignLaunchStatus","OnboardingStep","GenerationStatus","P2VStatus","P2VSource"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/http/HttpClient.ts","../src/types/result.ts","../src/resources/BaseResource.ts","../src/resources/CampaignsResource.ts","../src/resources/ElectedOfficesResource.ts","../src/resources/PathsToVictoryResource.ts","../src/resources/UsersResource.ts","../src/vendor/clerk/clerk.service.ts","../src/GoodPartyClient.ts","../src/enums.ts","../src/types/pathToVictory.ts"],"sourcesContent":["export { GoodPartyClient } from './GoodPartyClient'\nexport type { GoodPartyClientConfig } from './GoodPartyClient'\n\nexport { SdkError } from './types/result'\n\nexport type {\n PaginationMeta,\n PaginatedList,\n PaginationOptions,\n ReadUserOutput,\n ReadUserOutput as User,\n UpdatePasswordInput,\n UpdateUserInput,\n UserMetaData,\n ListUsersPagination,\n ReadCampaignOutput,\n ReadCampaignOutput as Campaign,\n CampaignDetails,\n CampaignData,\n CampaignAiContent,\n VoterGoals,\n CustomVoterFile,\n AiChatMessage,\n AiContentInputValues,\n AiContentGenerationStatus,\n AiContentData,\n GeoLocation,\n CustomIssue,\n Opponent,\n HubSpotUpdates,\n CampaignFinance,\n CampaignPlan,\n CampaignPlanStatus,\n ListCampaignsPagination,\n UpdateCampaignM2MInput,\n} from '@goodparty_org/contracts'\n\nexport {\n USER_ROLE_VALUES,\n WHY_BROWSING_VALUES,\n CAMPAIGN_TIER_VALUES,\n BALLOT_READY_POSITION_LEVEL_VALUES,\n ELECTION_LEVEL_VALUES,\n CAMPAIGN_CREATED_BY_VALUES,\n CAMPAIGN_LAUNCH_STATUS_VALUES,\n CAMPAIGN_STATUS_VALUES,\n ONBOARDING_STEP_VALUES,\n GENERATION_STATUS_VALUES,\n BallotReadyPositionLevel,\n ElectionLevel,\n CampaignCreatedBy,\n CampaignLaunchStatus,\n CampaignStatus,\n OnboardingStep,\n GenerationStatus,\n} from '@goodparty_org/contracts'\n\nexport { UserRole, WhyBrowsing, CampaignTier } from './enums'\n\nexport type {\n ElectedOffice,\n ListElectedOfficesOptions,\n UpdateElectedOfficeInput,\n} from './types/electedOffice'\n\nexport type {\n PathToVictory,\n PathToVictoryData,\n ViabilityScore,\n ListPathsToVictoryOptions,\n UpdatePathToVictoryInput,\n} from './types/pathToVictory'\n\nexport { P2VStatus, P2VSource } from './types/pathToVictory'\n","import { ofetch, FetchError, FetchOptions } from 'ofetch'\nimport { SdkError } from '../types/result'\n\nexport type OfetchRequestBody = FetchOptions<'json'>['body']\n\nexport class HttpClient {\n private baseUrl: string\n private getToken: () => Promise<string>\n\n constructor(gpApiRootUrl: string, getToken: () => Promise<string>) {\n this.baseUrl = gpApiRootUrl\n this.getToken = getToken\n }\n\n request = async <T>(\n path: string,\n init?: FetchOptions<'json'>,\n ): Promise<T> => {\n try {\n return await ofetch<T>(path, {\n baseURL: this.baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getToken()}`,\n ...(init?.headers ?? {}),\n },\n ...init,\n })\n } catch (error: unknown) {\n if (error instanceof FetchError) {\n throw new SdkError(error.statusCode ?? 0, error.message, error.response)\n }\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new SdkError(0, message)\n }\n }\n}\n","export class SdkError extends Error {\n readonly status: number\n readonly response?: Response\n\n constructor(status: number, message: string, response?: Response) {\n super(message)\n this.name = 'SdkError'\n this.status = status\n this.response = response\n }\n}\n","import type { FetchOptions } from 'ofetch'\nimport type { HttpClient, OfetchRequestBody } from '../http/HttpClient'\n\nexport abstract class BaseResource {\n protected httpClient: HttpClient\n protected abstract readonly resourceBasePath: string\n\n constructor(httpClient: HttpClient) {\n this.httpClient = httpClient\n }\n\n protected getRequest = <T>(\n path: string,\n query?: FetchOptions<'json'>['query'],\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'GET', query })\n\n protected postRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'POST', body })\n\n protected putRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'PUT', body })\n\n protected deleteRequest = <T>(path: string): Promise<T> =>\n this.httpClient.request<T>(path, { method: 'DELETE' })\n}\n","import type {\n ListCampaignsPagination,\n PaginatedList,\n ReadCampaignOutput,\n UpdateCampaignM2MInput,\n} from '@goodparty_org/contracts'\nimport { BaseResource } from './BaseResource'\n\nexport class CampaignsResource extends BaseResource {\n protected readonly resourceBasePath = '/campaigns'\n\n get = (id: number): Promise<ReadCampaignOutput> =>\n this.getRequest<ReadCampaignOutput>(`${this.resourceBasePath}/${id}`)\n\n list = (\n options?: ListCampaignsPagination,\n ): Promise<PaginatedList<ReadCampaignOutput>> =>\n this.getRequest<PaginatedList<ReadCampaignOutput>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n update = (\n id: number,\n input: UpdateCampaignM2MInput,\n ): Promise<ReadCampaignOutput> =>\n this.putRequest<ReadCampaignOutput>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '@goodparty_org/contracts'\nimport type {\n ElectedOffice,\n ListElectedOfficesOptions,\n UpdateElectedOfficeInput,\n} from '../types/electedOffice'\nimport { BaseResource } from './BaseResource'\n\nexport class ElectedOfficesResource extends BaseResource {\n protected readonly resourceBasePath = '/elected-office'\n\n list = (\n options?: ListElectedOfficesOptions,\n ): Promise<PaginatedList<ElectedOffice>> =>\n this.getRequest<PaginatedList<ElectedOffice>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n get = (id: string): Promise<ElectedOffice> =>\n this.getRequest<ElectedOffice>(`${this.resourceBasePath}/${id}`)\n\n update = (\n id: string,\n input: UpdateElectedOfficeInput,\n ): Promise<ElectedOffice> =>\n this.putRequest<ElectedOffice>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '@goodparty_org/contracts'\nimport type {\n ListPathsToVictoryOptions,\n PathToVictory,\n UpdatePathToVictoryInput,\n} from '../types/pathToVictory'\nimport { BaseResource } from './BaseResource'\n\nexport class PathsToVictoryResource extends BaseResource {\n protected resourceBasePath = '/path-to-victory'\n list = (\n options?: ListPathsToVictoryOptions,\n ): Promise<PaginatedList<PathToVictory>> =>\n this.getRequest<PaginatedList<PathToVictory>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n get = (id: number): Promise<PathToVictory> =>\n this.getRequest<PathToVictory>(`${this.resourceBasePath}/${id}`)\n\n update = (\n id: number,\n input: UpdatePathToVictoryInput,\n ): Promise<PathToVictory> =>\n this.putRequest<PathToVictory>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type {\n ListUsersPagination,\n PaginatedList,\n ReadUserOutput,\n UpdatePasswordInput,\n UpdateUserInput,\n} from '@goodparty_org/contracts'\nimport { BaseResource } from './BaseResource'\n\nexport class UsersResource extends BaseResource {\n protected readonly resourceBasePath = '/users'\n\n list = (\n options?: ListUsersPagination,\n ): Promise<PaginatedList<ReadUserOutput>> =>\n this.getRequest<PaginatedList<ReadUserOutput>>(\n this.resourceBasePath,\n options,\n )\n\n get = (id: number): Promise<ReadUserOutput> =>\n this.getRequest<ReadUserOutput>(`/users/${id}`)\n\n update = (id: number, input: UpdateUserInput): Promise<ReadUserOutput> =>\n this.putRequest<ReadUserOutput>(`${this.resourceBasePath}/${id}`, input)\n\n delete = (id: number): Promise<void> =>\n this.deleteRequest<void>(`${this.resourceBasePath}/${id}`)\n\n updatePassword = (id: number, input: UpdatePasswordInput): Promise<void> =>\n this.putRequest<void>(`${this.resourceBasePath}/${id}/password`, input)\n}\n","import { createClerkClient } from '@clerk/backend'\nimport { SdkError } from '../../types/result'\n\nconst TOKEN_RENEWAL_BUFFER_MS = 30_000\n\nexport class ClerkService {\n private readonly m2mSecret: string\n private readonly clerkClient: ReturnType<typeof createClerkClient>\n private cachedToken: string | null = null\n private tokenExpiration: number | null = null\n private renewalTimer: ReturnType<typeof setTimeout> | null = null\n private pendingTokenPromise: Promise<string> | null = null\n private destroyed = false\n\n constructor(m2mSecret: string) {\n this.m2mSecret = m2mSecret\n this.clerkClient = createClerkClient({})\n }\n\n getToken = async (): Promise<string> => {\n if (this.cachedToken && this.isTokenValid()) {\n return this.cachedToken\n }\n\n if (this.pendingTokenPromise) {\n return this.pendingTokenPromise\n }\n\n const promise = this.createAndCacheToken()\n this.pendingTokenPromise = promise\n\n try {\n return await promise\n } finally {\n if (this.pendingTokenPromise === promise) {\n this.pendingTokenPromise = null\n }\n }\n }\n\n destroy = (): void => {\n this.destroyed = true\n if (this.renewalTimer) {\n clearTimeout(this.renewalTimer)\n this.renewalTimer = null\n }\n this.cachedToken = null\n this.tokenExpiration = null\n this.pendingTokenPromise = null\n }\n\n private isTokenValid = (): boolean => {\n if (!this.tokenExpiration) return true\n return Date.now() < this.tokenExpiration - TOKEN_RENEWAL_BUFFER_MS\n }\n\n private createAndCacheToken = async (): Promise<string> => {\n try {\n const m2mToken = await this.clerkClient.m2m.createToken({\n machineSecretKey: this.m2mSecret,\n })\n\n if (!m2mToken.token) {\n throw new SdkError(\n 0,\n 'Clerk M2M token creation succeeded but returned no token string',\n )\n }\n\n if (this.destroyed) return m2mToken.token\n\n this.cachedToken = m2mToken.token\n this.tokenExpiration = m2mToken.expiration\n this.scheduleRenewal()\n\n return this.cachedToken\n } catch (error: unknown) {\n if (error instanceof SdkError) {\n throw error\n }\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new SdkError(0, `Failed to create Clerk M2M token: ${message}`)\n }\n }\n\n private scheduleRenewal = (): void => {\n if (this.renewalTimer) {\n clearTimeout(this.renewalTimer)\n this.renewalTimer = null\n }\n\n if (!this.tokenExpiration) return\n\n const timeUntilRenewal =\n this.tokenExpiration - Date.now() - TOKEN_RENEWAL_BUFFER_MS\n\n if (timeUntilRenewal <= 0) return\n\n this.renewalTimer = setTimeout(() => {\n this.cachedToken = null\n this.getToken().catch((error: unknown) => {\n console.error('Proactive M2M token renewal failed:', error)\n })\n }, timeUntilRenewal)\n }\n}\n","import { HttpClient } from './http/HttpClient'\nimport { CampaignsResource } from './resources/CampaignsResource'\nimport { ElectedOfficesResource } from './resources/ElectedOfficesResource'\nimport { PathsToVictoryResource } from './resources/PathsToVictoryResource'\nimport { UsersResource } from './resources/UsersResource'\nimport { ClerkService } from './vendor/clerk/clerk.service'\n\nexport type GoodPartyClientConfig = {\n m2mSecret: string\n gpApiRootUrl: string\n}\n\nexport class GoodPartyClient {\n readonly users: UsersResource\n readonly campaigns: CampaignsResource\n readonly electedOffices: ElectedOfficesResource\n readonly pathsToVictory: PathsToVictoryResource\n private clerkService: ClerkService\n\n private constructor(clerkService: ClerkService, gpApiRootUrl: string) {\n this.clerkService = clerkService\n const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken)\n this.users = new UsersResource(httpClient)\n this.campaigns = new CampaignsResource(httpClient)\n this.electedOffices = new ElectedOfficesResource(httpClient)\n this.pathsToVictory = new PathsToVictoryResource(httpClient)\n }\n\n static create = async (\n config: GoodPartyClientConfig,\n ): Promise<GoodPartyClient> => {\n const { m2mSecret, gpApiRootUrl } = config\n const clerkService = new ClerkService(m2mSecret)\n await clerkService.getToken()\n return new GoodPartyClient(clerkService, gpApiRootUrl)\n }\n\n destroy = (): void => {\n this.clerkService.destroy()\n }\n}\n","import {\n USER_ROLE_VALUES,\n type UserRole as UserRoleType,\n WHY_BROWSING_VALUES,\n type WhyBrowsing as WhyBrowsingType,\n CAMPAIGN_TIER_VALUES,\n type CampaignTier as CampaignTierType,\n} from '@goodparty_org/contracts'\n\ntype EnumObject<T extends readonly string[]> = { [K in T[number]]: K }\n\nconst toEnumObject = <T extends readonly string[]>(values: T): EnumObject<T> =>\n Object.fromEntries(values.map((v) => [v, v])) as EnumObject<T>\n\nexport type UserRole = UserRoleType\nexport const UserRole = toEnumObject(USER_ROLE_VALUES)\n\nexport type WhyBrowsing = WhyBrowsingType\nexport const WhyBrowsing = toEnumObject(WHY_BROWSING_VALUES)\n\nexport type CampaignTier = CampaignTierType\nexport const CampaignTier = toEnumObject(CAMPAIGN_TIER_VALUES)\n","import type { PaginationOptions } from '@goodparty_org/contracts'\n\nexport enum P2VStatus {\n complete = 'Complete',\n waiting = 'Waiting',\n failed = 'Failed',\n districtMatched = 'DistrictMatched',\n}\n\nexport enum P2VSource {\n GpApi = 'GpApi',\n ElectionApi = 'ElectionApi',\n}\n\nexport type ViabilityScore = {\n level: string\n isPartisan: boolean\n isIncumbent: boolean\n isUncontested: boolean\n candidates: number\n seats: number\n candidatesPerSeat: number\n score: number\n probOfWin: number\n}\n\nexport type PathToVictoryData = {\n p2vStatus?: P2VStatus\n p2vAttempts?: number\n p2vCompleteDate?: string\n completedBy?: number\n electionType?: string\n electionLocation?: string\n voterContactGoal?: number\n winNumber?: number\n p2vNotNeeded?: boolean\n totalRegisteredVoters?: number\n republicans?: number\n democrats?: number\n indies?: number\n women?: number\n men?: number\n white?: number\n asian?: number\n africanAmerican?: number\n hispanic?: number\n averageTurnout?: number\n projectedTurnout?: number\n viability?: ViabilityScore\n source?: P2VSource\n districtId?: string\n districtManuallySet?: boolean\n officeContextFingerprint?: string\n}\n\nexport type PathToVictory = {\n id: number\n createdAt: string\n updatedAt: string\n campaignId: number\n data: PathToVictoryData\n}\n\nexport type ListPathsToVictoryOptions = PaginationOptions & {\n userId?: number\n}\n\nexport type UpdatePathToVictoryInput = {\n data: PathToVictoryData\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAiD;;;ACA1C,IAAM,WAAN,cAAuB,MAAM;AAAA,EACzB;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,SAAiB,UAAqB;AAChE,UAAM,OAAO;AACb,SAAK,OAA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eAAe,IAAI,aAAa,SAAS;AAC/C,UAAM,aAAa,SAAS;AAC5B,WAAO,IAAI,iBAAgB,cAAc,YAAY;AAAA,EACvD;AAAA,EAEA,UAAU,MAAY;AACpB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;;;ATHA,IAAAA,oBAkBO;;;AUvDP,uBAOO;AAIP,IAAM,eAAe,CAA8B,WACjD,OAAO,YAAY,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAGvC,IAAM,WAAW,aAAa,iCAAgB;AAG9C,IAAM,cAAc,aAAa,oCAAmB;AAGpD,IAAM,eAAe,aAAa,qCAAoB;;;ACnBtD,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,aAAU;AACV,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,qBAAkB;AAJR,SAAAA;AAAA,GAAA;AAOL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,iBAAc;AAFJ,SAAAA;AAAA,GAAA;","names":["import_contracts","P2VStatus","P2VSource"]}
|
package/dist/index.mjs
CHANGED
|
@@ -89,7 +89,10 @@ var PathsToVictoryResource = class extends BaseResource {
|
|
|
89
89
|
// src/resources/UsersResource.ts
|
|
90
90
|
var UsersResource = class extends BaseResource {
|
|
91
91
|
resourceBasePath = "/users";
|
|
92
|
-
list = (options) => this.getRequest(
|
|
92
|
+
list = (options) => this.getRequest(
|
|
93
|
+
this.resourceBasePath,
|
|
94
|
+
options
|
|
95
|
+
);
|
|
93
96
|
get = (id) => this.getRequest(`/users/${id}`);
|
|
94
97
|
update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
|
|
95
98
|
delete = (id) => this.deleteRequest(`${this.resourceBasePath}/${id}`);
|
|
@@ -209,65 +212,37 @@ var GoodPartyClient = class _GoodPartyClient {
|
|
|
209
212
|
};
|
|
210
213
|
};
|
|
211
214
|
|
|
212
|
-
// src/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
215
|
+
// src/index.ts
|
|
216
|
+
import {
|
|
217
|
+
USER_ROLE_VALUES as USER_ROLE_VALUES2,
|
|
218
|
+
WHY_BROWSING_VALUES as WHY_BROWSING_VALUES2,
|
|
219
|
+
CAMPAIGN_TIER_VALUES as CAMPAIGN_TIER_VALUES2,
|
|
220
|
+
BALLOT_READY_POSITION_LEVEL_VALUES,
|
|
221
|
+
ELECTION_LEVEL_VALUES,
|
|
222
|
+
CAMPAIGN_CREATED_BY_VALUES,
|
|
223
|
+
CAMPAIGN_LAUNCH_STATUS_VALUES,
|
|
224
|
+
CAMPAIGN_STATUS_VALUES,
|
|
225
|
+
ONBOARDING_STEP_VALUES,
|
|
226
|
+
GENERATION_STATUS_VALUES,
|
|
227
|
+
BallotReadyPositionLevel,
|
|
228
|
+
ElectionLevel,
|
|
229
|
+
CampaignCreatedBy,
|
|
230
|
+
CampaignLaunchStatus,
|
|
231
|
+
CampaignStatus,
|
|
232
|
+
OnboardingStep,
|
|
233
|
+
GenerationStatus
|
|
234
|
+
} from "@goodparty_org/contracts";
|
|
228
235
|
|
|
229
|
-
// src/
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
var
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
BallotReadyPositionLevel2["FEDERAL"] = "FEDERAL";
|
|
240
|
-
BallotReadyPositionLevel2["LOCAL"] = "LOCAL";
|
|
241
|
-
BallotReadyPositionLevel2["REGIONAL"] = "REGIONAL";
|
|
242
|
-
BallotReadyPositionLevel2["STATE"] = "STATE";
|
|
243
|
-
BallotReadyPositionLevel2["TOWNSHIP"] = "TOWNSHIP";
|
|
244
|
-
return BallotReadyPositionLevel2;
|
|
245
|
-
})(BallotReadyPositionLevel || {});
|
|
246
|
-
var ElectionLevel = /* @__PURE__ */ ((ElectionLevel2) => {
|
|
247
|
-
ElectionLevel2["state"] = "state";
|
|
248
|
-
ElectionLevel2["county"] = "county";
|
|
249
|
-
ElectionLevel2["federal"] = "federal";
|
|
250
|
-
ElectionLevel2["city"] = "city";
|
|
251
|
-
return ElectionLevel2;
|
|
252
|
-
})(ElectionLevel || {});
|
|
253
|
-
var CampaignCreatedBy = /* @__PURE__ */ ((CampaignCreatedBy2) => {
|
|
254
|
-
CampaignCreatedBy2["ADMIN"] = "admin";
|
|
255
|
-
return CampaignCreatedBy2;
|
|
256
|
-
})(CampaignCreatedBy || {});
|
|
257
|
-
var CampaignLaunchStatus = /* @__PURE__ */ ((CampaignLaunchStatus2) => {
|
|
258
|
-
CampaignLaunchStatus2["launched"] = "launched";
|
|
259
|
-
return CampaignLaunchStatus2;
|
|
260
|
-
})(CampaignLaunchStatus || {});
|
|
261
|
-
var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
|
|
262
|
-
OnboardingStep2["complete"] = "onboarding-complete";
|
|
263
|
-
OnboardingStep2["registration"] = "registration";
|
|
264
|
-
return OnboardingStep2;
|
|
265
|
-
})(OnboardingStep || {});
|
|
266
|
-
var GenerationStatus = /* @__PURE__ */ ((GenerationStatus2) => {
|
|
267
|
-
GenerationStatus2["processing"] = "processing";
|
|
268
|
-
GenerationStatus2["completed"] = "completed";
|
|
269
|
-
return GenerationStatus2;
|
|
270
|
-
})(GenerationStatus || {});
|
|
236
|
+
// src/enums.ts
|
|
237
|
+
import {
|
|
238
|
+
USER_ROLE_VALUES,
|
|
239
|
+
WHY_BROWSING_VALUES,
|
|
240
|
+
CAMPAIGN_TIER_VALUES
|
|
241
|
+
} from "@goodparty_org/contracts";
|
|
242
|
+
var toEnumObject = (values) => Object.fromEntries(values.map((v) => [v, v]));
|
|
243
|
+
var UserRole = toEnumObject(USER_ROLE_VALUES);
|
|
244
|
+
var WhyBrowsing = toEnumObject(WHY_BROWSING_VALUES);
|
|
245
|
+
var CampaignTier = toEnumObject(CAMPAIGN_TIER_VALUES);
|
|
271
246
|
|
|
272
247
|
// src/types/pathToVictory.ts
|
|
273
248
|
var P2VStatus = /* @__PURE__ */ ((P2VStatus2) => {
|
|
@@ -283,18 +258,29 @@ var P2VSource = /* @__PURE__ */ ((P2VSource2) => {
|
|
|
283
258
|
return P2VSource2;
|
|
284
259
|
})(P2VSource || {});
|
|
285
260
|
export {
|
|
261
|
+
BALLOT_READY_POSITION_LEVEL_VALUES,
|
|
286
262
|
BallotReadyPositionLevel,
|
|
263
|
+
CAMPAIGN_CREATED_BY_VALUES,
|
|
264
|
+
CAMPAIGN_LAUNCH_STATUS_VALUES,
|
|
265
|
+
CAMPAIGN_STATUS_VALUES,
|
|
266
|
+
CAMPAIGN_TIER_VALUES2 as CAMPAIGN_TIER_VALUES,
|
|
287
267
|
CampaignCreatedBy,
|
|
288
268
|
CampaignLaunchStatus,
|
|
269
|
+
CampaignStatus,
|
|
289
270
|
CampaignTier,
|
|
271
|
+
ELECTION_LEVEL_VALUES,
|
|
290
272
|
ElectionLevel,
|
|
273
|
+
GENERATION_STATUS_VALUES,
|
|
291
274
|
GenerationStatus,
|
|
292
275
|
GoodPartyClient,
|
|
276
|
+
ONBOARDING_STEP_VALUES,
|
|
293
277
|
OnboardingStep,
|
|
294
278
|
P2VSource,
|
|
295
279
|
P2VStatus,
|
|
296
280
|
SdkError,
|
|
281
|
+
USER_ROLE_VALUES2 as USER_ROLE_VALUES,
|
|
297
282
|
UserRole,
|
|
283
|
+
WHY_BROWSING_VALUES2 as WHY_BROWSING_VALUES,
|
|
298
284
|
WhyBrowsing
|
|
299
285
|
};
|
|
300
286
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/http/HttpClient.ts","../src/types/result.ts","../src/resources/BaseResource.ts","../src/resources/CampaignsResource.ts","../src/resources/ElectedOfficesResource.ts","../src/resources/PathsToVictoryResource.ts","../src/resources/UsersResource.ts","../src/vendor/clerk/clerk.service.ts","../src/GoodPartyClient.ts","../src/types/user.ts","../src/types/campaign.ts","../src/types/pathToVictory.ts"],"sourcesContent":["import { ofetch, FetchError, FetchOptions } from 'ofetch'\nimport { SdkError } from '../types/result'\n\nexport type OfetchRequestBody = FetchOptions<'json'>['body']\n\nexport class HttpClient {\n private baseUrl: string\n private getToken: () => Promise<string>\n\n constructor(gpApiRootUrl: string, getToken: () => Promise<string>) {\n this.baseUrl = gpApiRootUrl\n this.getToken = getToken\n }\n\n request = async <T>(\n path: string,\n init?: FetchOptions<'json'>,\n ): Promise<T> => {\n try {\n return await ofetch<T>(path, {\n baseURL: this.baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getToken()}`,\n ...(init?.headers ?? {}),\n },\n ...init,\n })\n } catch (error: unknown) {\n if (error instanceof FetchError) {\n throw new SdkError(error.statusCode ?? 0, error.message, error.response)\n }\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new SdkError(0, message)\n }\n }\n}\n","export class SdkError extends Error {\n readonly status: number\n readonly response?: Response\n\n constructor(status: number, message: string, response?: Response) {\n super(message)\n this.name = 'SdkError'\n this.status = status\n this.response = response\n }\n}\n\nexport type PaginationOptions = {\n offset?: number\n limit?: number\n sortBy?: string\n sortOrder?: 'asc' | 'desc'\n}\n\nexport type PaginationMeta = {\n total: number\n offset: number\n limit: number\n}\n\nexport type PaginatedList<T> = {\n data: T[]\n meta: PaginationMeta\n}\n","import type { FetchOptions } from 'ofetch'\nimport type { HttpClient, OfetchRequestBody } from '../http/HttpClient'\n\nexport abstract class BaseResource {\n protected httpClient: HttpClient\n protected abstract readonly resourceBasePath: string\n\n constructor(httpClient: HttpClient) {\n this.httpClient = httpClient\n }\n\n protected getRequest = <T>(\n path: string,\n query?: FetchOptions<'json'>['query'],\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'GET', query })\n\n protected postRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'POST', body })\n\n protected putRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'PUT', body })\n\n protected deleteRequest = <T>(path: string): Promise<T> =>\n this.httpClient.request<T>(path, { method: 'DELETE' })\n}\n","import type { PaginatedList } from '../types/result'\nimport type {\n Campaign,\n ListCampaignsOptions,\n UpdateCampaignInput,\n} from '../types/campaign'\nimport { BaseResource } from './BaseResource'\n\nexport class CampaignsResource extends BaseResource {\n protected readonly resourceBasePath = '/campaigns'\n\n get = (id: number): Promise<Campaign> =>\n this.getRequest<Campaign>(`${this.resourceBasePath}/${id}`)\n\n list = (options?: ListCampaignsOptions): Promise<PaginatedList<Campaign>> =>\n this.getRequest<PaginatedList<Campaign>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n update = (id: number, input: UpdateCampaignInput): Promise<Campaign> =>\n this.putRequest<Campaign>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '../types/result'\nimport type {\n ElectedOffice,\n ListElectedOfficesOptions,\n UpdateElectedOfficeInput,\n} from '../types/electedOffice'\nimport { BaseResource } from './BaseResource'\n\nexport class ElectedOfficesResource extends BaseResource {\n protected readonly resourceBasePath = '/elected-office'\n\n list = (\n options?: ListElectedOfficesOptions,\n ): Promise<PaginatedList<ElectedOffice>> =>\n this.getRequest<PaginatedList<ElectedOffice>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n get = (id: string): Promise<ElectedOffice> =>\n this.getRequest<ElectedOffice>(`${this.resourceBasePath}/${id}`)\n\n update = (\n id: string,\n input: UpdateElectedOfficeInput,\n ): Promise<ElectedOffice> =>\n this.putRequest<ElectedOffice>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '../types/result'\nimport type {\n ListPathsToVictoryOptions,\n PathToVictory,\n UpdatePathToVictoryInput,\n} from '../types/pathToVictory'\nimport { BaseResource } from './BaseResource'\n\nexport class PathsToVictoryResource extends BaseResource {\n protected resourceBasePath = '/path-to-victory'\n list = (\n options?: ListPathsToVictoryOptions,\n ): Promise<PaginatedList<PathToVictory>> =>\n this.getRequest<PaginatedList<PathToVictory>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n get = (id: number): Promise<PathToVictory> =>\n this.getRequest<PathToVictory>(`${this.resourceBasePath}/${id}`)\n\n update = (\n id: number,\n input: UpdatePathToVictoryInput,\n ): Promise<PathToVictory> =>\n this.putRequest<PathToVictory>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '../types/result'\nimport type {\n ListUsersOptions,\n UpdatePasswordInput,\n UpdateUserInput,\n User,\n} from '../types/user'\nimport { BaseResource } from './BaseResource'\n\nexport class UsersResource extends BaseResource {\n protected readonly resourceBasePath = '/users'\n\n list = (options?: ListUsersOptions): Promise<PaginatedList<User>> =>\n this.getRequest<PaginatedList<User>>(this.resourceBasePath, options)\n\n get = (id: number): Promise<User> => this.getRequest<User>(`/users/${id}`)\n\n update = (id: number, input: UpdateUserInput): Promise<User> =>\n this.putRequest<User>(`${this.resourceBasePath}/${id}`, input)\n\n delete = (id: number): Promise<void> =>\n this.deleteRequest<void>(`${this.resourceBasePath}/${id}`)\n\n updatePassword = (id: number, input: UpdatePasswordInput): Promise<void> =>\n this.putRequest<void>(`${this.resourceBasePath}/${id}/password`, input)\n}\n","import { createClerkClient } from '@clerk/backend'\nimport { SdkError } from '../../types/result'\n\nconst TOKEN_RENEWAL_BUFFER_MS = 30_000\n\nexport class ClerkService {\n private readonly m2mSecret: string\n private readonly clerkClient: ReturnType<typeof createClerkClient>\n private cachedToken: string | null = null\n private tokenExpiration: number | null = null\n private renewalTimer: ReturnType<typeof setTimeout> | null = null\n private pendingTokenPromise: Promise<string> | null = null\n private destroyed = false\n\n constructor(m2mSecret: string) {\n this.m2mSecret = m2mSecret\n this.clerkClient = createClerkClient({})\n }\n\n getToken = async (): Promise<string> => {\n if (this.cachedToken && this.isTokenValid()) {\n return this.cachedToken\n }\n\n if (this.pendingTokenPromise) {\n return this.pendingTokenPromise\n }\n\n const promise = this.createAndCacheToken()\n this.pendingTokenPromise = promise\n\n try {\n return await promise\n } finally {\n if (this.pendingTokenPromise === promise) {\n this.pendingTokenPromise = null\n }\n }\n }\n\n destroy = (): void => {\n this.destroyed = true\n if (this.renewalTimer) {\n clearTimeout(this.renewalTimer)\n this.renewalTimer = null\n }\n this.cachedToken = null\n this.tokenExpiration = null\n this.pendingTokenPromise = null\n }\n\n private isTokenValid = (): boolean => {\n if (!this.tokenExpiration) return true\n return Date.now() < this.tokenExpiration - TOKEN_RENEWAL_BUFFER_MS\n }\n\n private createAndCacheToken = async (): Promise<string> => {\n try {\n const m2mToken = await this.clerkClient.m2m.createToken({\n machineSecretKey: this.m2mSecret,\n })\n\n if (!m2mToken.token) {\n throw new SdkError(\n 0,\n 'Clerk M2M token creation succeeded but returned no token string',\n )\n }\n\n if (this.destroyed) return m2mToken.token\n\n this.cachedToken = m2mToken.token\n this.tokenExpiration = m2mToken.expiration\n this.scheduleRenewal()\n\n return this.cachedToken\n } catch (error: unknown) {\n if (error instanceof SdkError) {\n throw error\n }\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new SdkError(0, `Failed to create Clerk M2M token: ${message}`)\n }\n }\n\n private scheduleRenewal = (): void => {\n if (this.renewalTimer) {\n clearTimeout(this.renewalTimer)\n this.renewalTimer = null\n }\n\n if (!this.tokenExpiration) return\n\n const timeUntilRenewal =\n this.tokenExpiration - Date.now() - TOKEN_RENEWAL_BUFFER_MS\n\n if (timeUntilRenewal <= 0) return\n\n this.renewalTimer = setTimeout(() => {\n this.cachedToken = null\n this.getToken().catch((error: unknown) => {\n console.error('Proactive M2M token renewal failed:', error)\n })\n }, timeUntilRenewal)\n }\n}\n","import { HttpClient } from './http/HttpClient'\nimport { CampaignsResource } from './resources/CampaignsResource'\nimport { ElectedOfficesResource } from './resources/ElectedOfficesResource'\nimport { PathsToVictoryResource } from './resources/PathsToVictoryResource'\nimport { UsersResource } from './resources/UsersResource'\nimport { ClerkService } from './vendor/clerk/clerk.service'\n\nexport type GoodPartyClientConfig = {\n m2mSecret: string\n gpApiRootUrl: string\n}\n\nexport class GoodPartyClient {\n readonly users: UsersResource\n readonly campaigns: CampaignsResource\n readonly electedOffices: ElectedOfficesResource\n readonly pathsToVictory: PathsToVictoryResource\n private clerkService: ClerkService\n\n private constructor(clerkService: ClerkService, gpApiRootUrl: string) {\n this.clerkService = clerkService\n const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken)\n this.users = new UsersResource(httpClient)\n this.campaigns = new CampaignsResource(httpClient)\n this.electedOffices = new ElectedOfficesResource(httpClient)\n this.pathsToVictory = new PathsToVictoryResource(httpClient)\n }\n\n static create = async (\n config: GoodPartyClientConfig,\n ): Promise<GoodPartyClient> => {\n const { m2mSecret, gpApiRootUrl } = config\n const clerkService = new ClerkService(m2mSecret)\n await clerkService.getToken()\n return new GoodPartyClient(clerkService, gpApiRootUrl)\n }\n\n destroy = (): void => {\n this.clerkService.destroy()\n }\n}\n","import type { PaginationOptions } from './result'\n\nexport enum UserRole {\n admin = 'admin',\n sales = 'sales',\n candidate = 'candidate',\n campaignManager = 'campaignManager',\n demo = 'demo',\n}\n\nexport enum WhyBrowsing {\n considering = 'considering',\n learning = 'learning',\n test = 'test',\n else = 'else',\n}\n\nexport enum SIGN_UP_MODE {\n CANDIDATE = 'candidate',\n FACILITATED = 'facilitated',\n}\n\nexport type UserMetaData = {\n customerId?: string\n checkoutSessionId?: string | null\n accountType?: string | null\n lastVisited?: number\n sessionCount?: number\n isDeleted?: boolean\n fsUserId?: string\n whyBrowsing?: WhyBrowsing | null\n hubspotId?: string\n profile_updated_count?: number\n textNotifications?: boolean\n} | null\n\nexport type User = {\n id: number\n firstName: string\n lastName: string\n name?: string | null\n email: string\n phone?: string | null\n zip?: string | null\n avatar?: string | null\n hasPassword: boolean\n roles?: UserRole[]\n metaData?: UserMetaData\n}\n\nexport type ListUsersOptions = PaginationOptions & {\n firstName?: string\n lastName?: string\n email?: string\n}\n\nexport type UpdateUserInput = {\n firstName?: string\n lastName?: string\n email?: string\n name?: string\n zip?: string\n phone?: string\n roles?: UserRole[]\n signUpMode?: SIGN_UP_MODE\n allowTexts?: boolean\n metaData?: UserMetaData\n}\n\nexport type UpdatePasswordInput = {\n oldPassword?: string\n newPassword: string\n}\n","import type { PaginationOptions } from './result'\n\nexport enum CampaignTier {\n WIN = 'WIN',\n LOSE = 'LOSE',\n TOSSUP = 'TOSSUP',\n}\n\nexport enum BallotReadyPositionLevel {\n CITY = 'CITY',\n COUNTY = 'COUNTY',\n FEDERAL = 'FEDERAL',\n LOCAL = 'LOCAL',\n REGIONAL = 'REGIONAL',\n STATE = 'STATE',\n TOWNSHIP = 'TOWNSHIP',\n}\n\nexport enum ElectionLevel {\n state = 'state',\n county = 'county',\n federal = 'federal',\n city = 'city',\n}\n\nexport enum CampaignCreatedBy {\n ADMIN = 'admin',\n}\n\nexport enum CampaignLaunchStatus {\n launched = 'launched',\n}\n\nexport enum OnboardingStep {\n complete = 'onboarding-complete',\n registration = 'registration',\n}\n\nexport enum GenerationStatus {\n processing = 'processing',\n completed = 'completed',\n}\n\nexport type VoterGoals = {\n doorKnocking?: number\n calls?: number\n digital?: number\n directMail?: number\n digitalAds?: number\n text?: number\n events?: number\n yardSigns?: number\n robocall?: number\n phoneBanking?: number\n socialMedia?: number\n}\n\nexport type CustomVoterFile = {\n name: string\n channel?: string\n purpose?: string\n filters: string[]\n createdAt: string\n}\n\nexport type AiChatMessage = {\n role: 'user' | 'system' | 'assistant'\n content: string\n createdAt?: number\n id?: string\n usage?: number\n}\n\nexport type AiContentInputValues = Record<\n string,\n string | boolean | number | undefined\n>\n\nexport type AiContentGenerationStatus = {\n status: GenerationStatus\n createdAt: number\n prompt?: string\n existingChat?: AiChatMessage[]\n inputValues?: AiContentInputValues\n}\n\nexport type AiContentData = {\n name: string\n content: string\n updatedAt: number\n inputValues?: AiContentInputValues\n}\n\nexport type GeoLocation = { geoHash?: string; lng?: number; lat?: number }\n\nexport type CustomIssue = { title: string; position: string }\n\nexport type Opponent = { name: string; party: string; description: string }\n\nexport type HubSpotUpdates = Partial<Record<string, string>>\n\nexport type CampaignDetails = {\n state?: string\n ballotLevel?: BallotReadyPositionLevel\n electionDate?: string\n primaryElectionDate?: string\n zip?: string | null\n knowRun?: 'yes' | null\n runForOffice?: 'yes' | 'no' | null\n pledged?: boolean\n isProUpdatedAt?: number\n customIssues?: CustomIssue[]\n runningAgainst?: Opponent[]\n geoLocation?: GeoLocation\n geoLocationFailed?: boolean\n city?: string | null\n county?: string | null\n normalizedOffice?: string | null\n otherOffice?: string\n office?: string\n party?: string\n otherParty?: string\n district?: string\n raceId?: string\n level?: ElectionLevel | null\n noNormalizedOffice?: boolean\n website?: string\n pastExperience?: string | Record<string, string>\n occupation?: string\n funFact?: string\n campaignCommittee?: string\n statementName?: string\n subscriptionId?: string | null\n endOfElectionSubscriptionCanceled?: boolean\n subscriptionCanceledAt?: number | null\n subscriptionCancelAt?: number | null\n filingPeriodsStart?: string | null\n filingPeriodsEnd?: string | null\n officeTermLength?: string\n partisanType?: string\n priorElectionDates?: string[]\n positionId?: string | null\n electionId?: string | null\n tier?: string\n einNumber?: string | null\n einSupportingDocument?: string | null\n wonGeneral?: boolean\n}\n\nexport type CampaignData = {\n createdBy?: CampaignCreatedBy\n slug?: string\n hubSpotUpdates?: HubSpotUpdates\n currentStep?: OnboardingStep\n launchStatus?: CampaignLaunchStatus\n lastVisited?: number\n claimProfile?: string\n customVoterFiles?: CustomVoterFile[]\n reportedVoterGoals?: VoterGoals\n textCampaignCount?: number\n lastStepDate?: string\n adminUserEmail?: string\n hubspotId?: string\n name?: string\n}\n\nexport type CampaignAiContent = {\n generationStatus?: Record<string, AiContentGenerationStatus>\n campaignPlanAttempts?: Record<string, number>\n} & Record<string, AiContentData>\n\nexport type Campaign = {\n id: number\n createdAt: string\n updatedAt: string\n slug: string\n isActive: boolean\n isVerified?: boolean | null\n isPro?: boolean | null\n isDemo: boolean\n didWin?: boolean | null\n dateVerified?: string | null\n tier?: CampaignTier | null\n formattedAddress?: string | null\n placeId?: string | null\n data: CampaignData\n details: CampaignDetails\n aiContent: CampaignAiContent\n userId: number\n canDownloadFederal: boolean\n completedTaskIds: string[]\n hasFreeTextsOffer: boolean\n freeTextsOfferRedeemedAt?: string | null\n}\n\nexport type ListCampaignsOptions = PaginationOptions & {\n userId?: number\n slug?: string\n}\n\nexport type UpdateCampaignInput = {\n slug?: string\n isActive?: boolean\n isVerified?: boolean | null\n isPro?: boolean | null\n isDemo?: boolean\n didWin?: boolean | null\n dateVerified?: string | null\n tier?: CampaignTier | null\n formattedAddress?: string | null\n placeId?: string | null\n data?: CampaignData\n details?: CampaignDetails\n aiContent?: CampaignAiContent\n canDownloadFederal?: boolean\n completedTaskIds?: string[]\n hasFreeTextsOffer?: boolean\n freeTextsOfferRedeemedAt?: string | null\n}\n","import type { PaginationOptions } from './result'\n\nexport enum P2VStatus {\n complete = 'Complete',\n waiting = 'Waiting',\n failed = 'Failed',\n districtMatched = 'DistrictMatched',\n}\n\nexport enum P2VSource {\n GpApi = 'GpApi',\n ElectionApi = 'ElectionApi',\n}\n\nexport type ViabilityScore = {\n level: string\n isPartisan: boolean\n isIncumbent: boolean\n isUncontested: boolean\n candidates: number\n seats: number\n candidatesPerSeat: number\n score: number\n probOfWin: number\n}\n\nexport type PathToVictoryData = {\n p2vStatus?: P2VStatus\n p2vAttempts?: number\n p2vCompleteDate?: string\n completedBy?: number\n electionType?: string\n electionLocation?: string\n voterContactGoal?: number\n winNumber?: number\n p2vNotNeeded?: boolean\n totalRegisteredVoters?: number\n republicans?: number\n democrats?: number\n indies?: number\n women?: number\n men?: number\n white?: number\n asian?: number\n africanAmerican?: number\n hispanic?: number\n averageTurnout?: number\n projectedTurnout?: number\n viability?: ViabilityScore\n source?: P2VSource\n districtId?: string\n districtManuallySet?: boolean\n officeContextFingerprint?: string\n}\n\nexport type PathToVictory = {\n id: number\n createdAt: string\n updatedAt: string\n campaignId: number\n data: PathToVictoryData\n}\n\nexport type ListPathsToVictoryOptions = PaginationOptions & {\n userId?: number\n}\n\nexport type UpdatePathToVictoryInput = {\n data: PathToVictoryData\n}\n"],"mappings":";AAAA,SAAS,QAAQ,kBAAgC;;;ACA1C,IAAM,WAAN,cAAuB,MAAM;AAAA,EACzB;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,SAAiB,UAAqB;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AACF;;;ADLO,IAAM,aAAN,MAAiB;AAAA,EACd;AAAA,EACA;AAAA,EAER,YAAY,cAAsB,UAAiC;AACjE,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,UAAU,OACR,MACA,SACe;AACf,QAAI;AACF,aAAO,MAAM,OAAU,MAAM;AAAA,QAC3B,SAAS,KAAK;AAAA,QACd,SAAS;AAAA,UACP,eAAe,UAAU,MAAM,KAAK,SAAS,CAAC;AAAA,UAC9C,GAAI,MAAM,WAAW,CAAC;AAAA,QACxB;AAAA,QACA,GAAG;AAAA,MACL,CAAC;AAAA,IACH,SAAS,OAAgB;AACvB,UAAI,iBAAiB,YAAY;AAC/B,cAAM,IAAI,SAAS,MAAM,cAAc,GAAG,MAAM,SAAS,MAAM,QAAQ;AAAA,MACzE;AACA,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,YAAM,IAAI,SAAS,GAAG,OAAO;AAAA,IAC/B;AAAA,EACF;AACF;;;AEhCO,IAAe,eAAf,MAA4B;AAAA,EACvB;AAAA,EAGV,YAAY,YAAwB;AAClC,SAAK,aAAa;AAAA,EACpB;AAAA,EAEU,aAAa,CACrB,MACA,UACe,KAAK,WAAW,QAAW,MAAM,EAAE,QAA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R,EAAAA,0BAAA,cAAW;AAPD,SAAAA;AAAA,GAAA;AAUL,IAAK,gBAAL,kBAAKC,mBAAL;AACL,EAAAA,eAAA,WAAQ;AACR,EAAAA,eAAA,YAAS;AACT,EAAAA,eAAA,aAAU;AACV,EAAAA,eAAA,UAAO;AAJG,SAAAA;AAAA,GAAA;AAOL,IAAK,oBAAL,kBAAKC,uBAAL;AACL,EAAAA,mBAAA,WAAQ;AADE,SAAAA;AAAA,GAAA;AAIL,IAAK,uBAAL,kBAAKC,0BAAL;AACL,EAAAA,sBAAA,cAAW;AADD,SAAAA;AAAA,GAAA;AAIL,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,cAAW;AACX,EAAAA,gBAAA,kBAAe;AAFL,SAAAA;AAAA,GAAA;AAKL,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,gBAAa;AACb,EAAAA,kBAAA,eAAY;AAFF,SAAAA;AAAA,GAAA;;;ACpCL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,aAAU;AACV,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,qBAAkB;AAJR,SAAAA;AAAA,GAAA;AAOL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,iBAAc;AAFJ,SAAAA;AAAA,GAAA;","names":["UserRole","WhyBrowsing","CampaignTier","BallotReadyPositionLevel","ElectionLevel","CampaignCreatedBy","CampaignLaunchStatus","OnboardingStep","GenerationStatus","P2VStatus","P2VSource"]}
|
|
1
|
+
{"version":3,"sources":["../src/http/HttpClient.ts","../src/types/result.ts","../src/resources/BaseResource.ts","../src/resources/CampaignsResource.ts","../src/resources/ElectedOfficesResource.ts","../src/resources/PathsToVictoryResource.ts","../src/resources/UsersResource.ts","../src/vendor/clerk/clerk.service.ts","../src/GoodPartyClient.ts","../src/index.ts","../src/enums.ts","../src/types/pathToVictory.ts"],"sourcesContent":["import { ofetch, FetchError, FetchOptions } from 'ofetch'\nimport { SdkError } from '../types/result'\n\nexport type OfetchRequestBody = FetchOptions<'json'>['body']\n\nexport class HttpClient {\n private baseUrl: string\n private getToken: () => Promise<string>\n\n constructor(gpApiRootUrl: string, getToken: () => Promise<string>) {\n this.baseUrl = gpApiRootUrl\n this.getToken = getToken\n }\n\n request = async <T>(\n path: string,\n init?: FetchOptions<'json'>,\n ): Promise<T> => {\n try {\n return await ofetch<T>(path, {\n baseURL: this.baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getToken()}`,\n ...(init?.headers ?? {}),\n },\n ...init,\n })\n } catch (error: unknown) {\n if (error instanceof FetchError) {\n throw new SdkError(error.statusCode ?? 0, error.message, error.response)\n }\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new SdkError(0, message)\n }\n }\n}\n","export class SdkError extends Error {\n readonly status: number\n readonly response?: Response\n\n constructor(status: number, message: string, response?: Response) {\n super(message)\n this.name = 'SdkError'\n this.status = status\n this.response = response\n }\n}\n","import type { FetchOptions } from 'ofetch'\nimport type { HttpClient, OfetchRequestBody } from '../http/HttpClient'\n\nexport abstract class BaseResource {\n protected httpClient: HttpClient\n protected abstract readonly resourceBasePath: string\n\n constructor(httpClient: HttpClient) {\n this.httpClient = httpClient\n }\n\n protected getRequest = <T>(\n path: string,\n query?: FetchOptions<'json'>['query'],\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'GET', query })\n\n protected postRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'POST', body })\n\n protected putRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'PUT', body })\n\n protected deleteRequest = <T>(path: string): Promise<T> =>\n this.httpClient.request<T>(path, { method: 'DELETE' })\n}\n","import type {\n ListCampaignsPagination,\n PaginatedList,\n ReadCampaignOutput,\n UpdateCampaignM2MInput,\n} from '@goodparty_org/contracts'\nimport { BaseResource } from './BaseResource'\n\nexport class CampaignsResource extends BaseResource {\n protected readonly resourceBasePath = '/campaigns'\n\n get = (id: number): Promise<ReadCampaignOutput> =>\n this.getRequest<ReadCampaignOutput>(`${this.resourceBasePath}/${id}`)\n\n list = (\n options?: ListCampaignsPagination,\n ): Promise<PaginatedList<ReadCampaignOutput>> =>\n this.getRequest<PaginatedList<ReadCampaignOutput>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n update = (\n id: number,\n input: UpdateCampaignM2MInput,\n ): Promise<ReadCampaignOutput> =>\n this.putRequest<ReadCampaignOutput>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '@goodparty_org/contracts'\nimport type {\n ElectedOffice,\n ListElectedOfficesOptions,\n UpdateElectedOfficeInput,\n} from '../types/electedOffice'\nimport { BaseResource } from './BaseResource'\n\nexport class ElectedOfficesResource extends BaseResource {\n protected readonly resourceBasePath = '/elected-office'\n\n list = (\n options?: ListElectedOfficesOptions,\n ): Promise<PaginatedList<ElectedOffice>> =>\n this.getRequest<PaginatedList<ElectedOffice>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n get = (id: string): Promise<ElectedOffice> =>\n this.getRequest<ElectedOffice>(`${this.resourceBasePath}/${id}`)\n\n update = (\n id: string,\n input: UpdateElectedOfficeInput,\n ): Promise<ElectedOffice> =>\n this.putRequest<ElectedOffice>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type { PaginatedList } from '@goodparty_org/contracts'\nimport type {\n ListPathsToVictoryOptions,\n PathToVictory,\n UpdatePathToVictoryInput,\n} from '../types/pathToVictory'\nimport { BaseResource } from './BaseResource'\n\nexport class PathsToVictoryResource extends BaseResource {\n protected resourceBasePath = '/path-to-victory'\n list = (\n options?: ListPathsToVictoryOptions,\n ): Promise<PaginatedList<PathToVictory>> =>\n this.getRequest<PaginatedList<PathToVictory>>(\n `${this.resourceBasePath}/list`,\n options,\n )\n\n get = (id: number): Promise<PathToVictory> =>\n this.getRequest<PathToVictory>(`${this.resourceBasePath}/${id}`)\n\n update = (\n id: number,\n input: UpdatePathToVictoryInput,\n ): Promise<PathToVictory> =>\n this.putRequest<PathToVictory>(`${this.resourceBasePath}/${id}`, input)\n}\n","import type {\n ListUsersPagination,\n PaginatedList,\n ReadUserOutput,\n UpdatePasswordInput,\n UpdateUserInput,\n} from '@goodparty_org/contracts'\nimport { BaseResource } from './BaseResource'\n\nexport class UsersResource extends BaseResource {\n protected readonly resourceBasePath = '/users'\n\n list = (\n options?: ListUsersPagination,\n ): Promise<PaginatedList<ReadUserOutput>> =>\n this.getRequest<PaginatedList<ReadUserOutput>>(\n this.resourceBasePath,\n options,\n )\n\n get = (id: number): Promise<ReadUserOutput> =>\n this.getRequest<ReadUserOutput>(`/users/${id}`)\n\n update = (id: number, input: UpdateUserInput): Promise<ReadUserOutput> =>\n this.putRequest<ReadUserOutput>(`${this.resourceBasePath}/${id}`, input)\n\n delete = (id: number): Promise<void> =>\n this.deleteRequest<void>(`${this.resourceBasePath}/${id}`)\n\n updatePassword = (id: number, input: UpdatePasswordInput): Promise<void> =>\n this.putRequest<void>(`${this.resourceBasePath}/${id}/password`, input)\n}\n","import { createClerkClient } from '@clerk/backend'\nimport { SdkError } from '../../types/result'\n\nconst TOKEN_RENEWAL_BUFFER_MS = 30_000\n\nexport class ClerkService {\n private readonly m2mSecret: string\n private readonly clerkClient: ReturnType<typeof createClerkClient>\n private cachedToken: string | null = null\n private tokenExpiration: number | null = null\n private renewalTimer: ReturnType<typeof setTimeout> | null = null\n private pendingTokenPromise: Promise<string> | null = null\n private destroyed = false\n\n constructor(m2mSecret: string) {\n this.m2mSecret = m2mSecret\n this.clerkClient = createClerkClient({})\n }\n\n getToken = async (): Promise<string> => {\n if (this.cachedToken && this.isTokenValid()) {\n return this.cachedToken\n }\n\n if (this.pendingTokenPromise) {\n return this.pendingTokenPromise\n }\n\n const promise = this.createAndCacheToken()\n this.pendingTokenPromise = promise\n\n try {\n return await promise\n } finally {\n if (this.pendingTokenPromise === promise) {\n this.pendingTokenPromise = null\n }\n }\n }\n\n destroy = (): void => {\n this.destroyed = true\n if (this.renewalTimer) {\n clearTimeout(this.renewalTimer)\n this.renewalTimer = null\n }\n this.cachedToken = null\n this.tokenExpiration = null\n this.pendingTokenPromise = null\n }\n\n private isTokenValid = (): boolean => {\n if (!this.tokenExpiration) return true\n return Date.now() < this.tokenExpiration - TOKEN_RENEWAL_BUFFER_MS\n }\n\n private createAndCacheToken = async (): Promise<string> => {\n try {\n const m2mToken = await this.clerkClient.m2m.createToken({\n machineSecretKey: this.m2mSecret,\n })\n\n if (!m2mToken.token) {\n throw new SdkError(\n 0,\n 'Clerk M2M token creation succeeded but returned no token string',\n )\n }\n\n if (this.destroyed) return m2mToken.token\n\n this.cachedToken = m2mToken.token\n this.tokenExpiration = m2mToken.expiration\n this.scheduleRenewal()\n\n return this.cachedToken\n } catch (error: unknown) {\n if (error instanceof SdkError) {\n throw error\n }\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new SdkError(0, `Failed to create Clerk M2M token: ${message}`)\n }\n }\n\n private scheduleRenewal = (): void => {\n if (this.renewalTimer) {\n clearTimeout(this.renewalTimer)\n this.renewalTimer = null\n }\n\n if (!this.tokenExpiration) return\n\n const timeUntilRenewal =\n this.tokenExpiration - Date.now() - TOKEN_RENEWAL_BUFFER_MS\n\n if (timeUntilRenewal <= 0) return\n\n this.renewalTimer = setTimeout(() => {\n this.cachedToken = null\n this.getToken().catch((error: unknown) => {\n console.error('Proactive M2M token renewal failed:', error)\n })\n }, timeUntilRenewal)\n }\n}\n","import { HttpClient } from './http/HttpClient'\nimport { CampaignsResource } from './resources/CampaignsResource'\nimport { ElectedOfficesResource } from './resources/ElectedOfficesResource'\nimport { PathsToVictoryResource } from './resources/PathsToVictoryResource'\nimport { UsersResource } from './resources/UsersResource'\nimport { ClerkService } from './vendor/clerk/clerk.service'\n\nexport type GoodPartyClientConfig = {\n m2mSecret: string\n gpApiRootUrl: string\n}\n\nexport class GoodPartyClient {\n readonly users: UsersResource\n readonly campaigns: CampaignsResource\n readonly electedOffices: ElectedOfficesResource\n readonly pathsToVictory: PathsToVictoryResource\n private clerkService: ClerkService\n\n private constructor(clerkService: ClerkService, gpApiRootUrl: string) {\n this.clerkService = clerkService\n const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken)\n this.users = new UsersResource(httpClient)\n this.campaigns = new CampaignsResource(httpClient)\n this.electedOffices = new ElectedOfficesResource(httpClient)\n this.pathsToVictory = new PathsToVictoryResource(httpClient)\n }\n\n static create = async (\n config: GoodPartyClientConfig,\n ): Promise<GoodPartyClient> => {\n const { m2mSecret, gpApiRootUrl } = config\n const clerkService = new ClerkService(m2mSecret)\n await clerkService.getToken()\n return new GoodPartyClient(clerkService, gpApiRootUrl)\n }\n\n destroy = (): void => {\n this.clerkService.destroy()\n }\n}\n","export { GoodPartyClient } from './GoodPartyClient'\nexport type { GoodPartyClientConfig } from './GoodPartyClient'\n\nexport { SdkError } from './types/result'\n\nexport type {\n PaginationMeta,\n PaginatedList,\n PaginationOptions,\n ReadUserOutput,\n ReadUserOutput as User,\n UpdatePasswordInput,\n UpdateUserInput,\n UserMetaData,\n ListUsersPagination,\n ReadCampaignOutput,\n ReadCampaignOutput as Campaign,\n CampaignDetails,\n CampaignData,\n CampaignAiContent,\n VoterGoals,\n CustomVoterFile,\n AiChatMessage,\n AiContentInputValues,\n AiContentGenerationStatus,\n AiContentData,\n GeoLocation,\n CustomIssue,\n Opponent,\n HubSpotUpdates,\n CampaignFinance,\n CampaignPlan,\n CampaignPlanStatus,\n ListCampaignsPagination,\n UpdateCampaignM2MInput,\n} from '@goodparty_org/contracts'\n\nexport {\n USER_ROLE_VALUES,\n WHY_BROWSING_VALUES,\n CAMPAIGN_TIER_VALUES,\n BALLOT_READY_POSITION_LEVEL_VALUES,\n ELECTION_LEVEL_VALUES,\n CAMPAIGN_CREATED_BY_VALUES,\n CAMPAIGN_LAUNCH_STATUS_VALUES,\n CAMPAIGN_STATUS_VALUES,\n ONBOARDING_STEP_VALUES,\n GENERATION_STATUS_VALUES,\n BallotReadyPositionLevel,\n ElectionLevel,\n CampaignCreatedBy,\n CampaignLaunchStatus,\n CampaignStatus,\n OnboardingStep,\n GenerationStatus,\n} from '@goodparty_org/contracts'\n\nexport { UserRole, WhyBrowsing, CampaignTier } from './enums'\n\nexport type {\n ElectedOffice,\n ListElectedOfficesOptions,\n UpdateElectedOfficeInput,\n} from './types/electedOffice'\n\nexport type {\n PathToVictory,\n PathToVictoryData,\n ViabilityScore,\n ListPathsToVictoryOptions,\n UpdatePathToVictoryInput,\n} from './types/pathToVictory'\n\nexport { P2VStatus, P2VSource } from './types/pathToVictory'\n","import {\n USER_ROLE_VALUES,\n type UserRole as UserRoleType,\n WHY_BROWSING_VALUES,\n type WhyBrowsing as WhyBrowsingType,\n CAMPAIGN_TIER_VALUES,\n type CampaignTier as CampaignTierType,\n} from '@goodparty_org/contracts'\n\ntype EnumObject<T extends readonly string[]> = { [K in T[number]]: K }\n\nconst toEnumObject = <T extends readonly string[]>(values: T): EnumObject<T> =>\n Object.fromEntries(values.map((v) => [v, v])) as EnumObject<T>\n\nexport type UserRole = UserRoleType\nexport const UserRole = toEnumObject(USER_ROLE_VALUES)\n\nexport type WhyBrowsing = WhyBrowsingType\nexport const WhyBrowsing = toEnumObject(WHY_BROWSING_VALUES)\n\nexport type CampaignTier = CampaignTierType\nexport const CampaignTier = toEnumObject(CAMPAIGN_TIER_VALUES)\n","import type { PaginationOptions } from '@goodparty_org/contracts'\n\nexport enum P2VStatus {\n complete = 'Complete',\n waiting = 'Waiting',\n failed = 'Failed',\n districtMatched = 'DistrictMatched',\n}\n\nexport enum P2VSource {\n GpApi = 'GpApi',\n ElectionApi = 'ElectionApi',\n}\n\nexport type ViabilityScore = {\n level: string\n isPartisan: boolean\n isIncumbent: boolean\n isUncontested: boolean\n candidates: number\n seats: number\n candidatesPerSeat: number\n score: number\n probOfWin: number\n}\n\nexport type PathToVictoryData = {\n p2vStatus?: P2VStatus\n p2vAttempts?: number\n p2vCompleteDate?: string\n completedBy?: number\n electionType?: string\n electionLocation?: string\n voterContactGoal?: number\n winNumber?: number\n p2vNotNeeded?: boolean\n totalRegisteredVoters?: number\n republicans?: number\n democrats?: number\n indies?: number\n women?: number\n men?: number\n white?: number\n asian?: number\n africanAmerican?: number\n hispanic?: number\n averageTurnout?: number\n projectedTurnout?: number\n viability?: ViabilityScore\n source?: P2VSource\n districtId?: string\n districtManuallySet?: boolean\n officeContextFingerprint?: string\n}\n\nexport type PathToVictory = {\n id: number\n createdAt: string\n updatedAt: string\n campaignId: number\n data: PathToVictoryData\n}\n\nexport type ListPathsToVictoryOptions = PaginationOptions & {\n userId?: number\n}\n\nexport type UpdatePathToVictoryInput = {\n data: PathToVictoryData\n}\n"],"mappings":";AAAA,SAAS,QAAQ,kBAAgC;;;ACA1C,IAAM,WAAN,cAAuB,MAAM;AAAA,EACzB;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,SAAiB,UAAqB;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AACF;;;ADLO,IAAM,aAAN,MAAiB;AAAA,EACd;AAAA,EACA;AAAA,EAER,YAAY,cAAsB,UAAiC;AACjE,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,UAAU,OACR,MACA,SACe;AACf,QAAI;AACF,aAAO,MAAM,OAAU,MAAM;AAAA,QAC3B,SAAS,KAAK;AAAA,QACd,SAAS;AAAA,UACP,eAAe,UAAU,MAAM,KAAK,SAAS,CAAC;AAAA,UAC9C,GAAI,MAAM,WAAW,CAAC;AAAA,QACxB;AAAA,QACA,GAAG;AAAA,MACL,CAAC;AAAA,IACH,SAAS,OAAgB;AACvB,UAAI,iBAAiB,YAAY;AAC/B,cAAM,IAAI,SAAS,MAAM,cAAc,GAAG,MAAM,SAAS,MAAM,QAAQ;AAAA,MACzE;AACA,YAAM,UAAU,iBA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,gBAAgB;AAG9C,IAAM,cAAc,aAAa,mBAAmB;AAGpD,IAAM,eAAe,aAAa,oBAAoB;;;ACnBtD,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,cAAW;AACX,EAAAA,WAAA,aAAU;AACV,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,qBAAkB;AAJR,SAAAA;AAAA,GAAA;AAOL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,iBAAc;AAFJ,SAAAA;AAAA,GAAA;","names":["USER_ROLE_VALUES","WHY_BROWSING_VALUES","CAMPAIGN_TIER_VALUES","P2VStatus","P2VSource"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodparty_org/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "TypeScript SDK for interacting with the GoodParty API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@clerk/backend": "^2.30.1",
|
|
52
|
+
"@goodparty_org/contracts": "^0.0.0-rc-develop.83110207c77a9c2f1eddffa0054163eb84a65f37",
|
|
52
53
|
"ofetch": "^1.5.1"
|
|
53
54
|
}
|
|
54
55
|
}
|