@goodparty_org/sdk 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/index.d.mts +72 -1
- package/dist/index.d.ts +72 -1
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,6 +55,18 @@ const updatedCampaign = await client.campaigns.update(1, {
|
|
|
55
55
|
details: { office: 'Mayor' },
|
|
56
56
|
})
|
|
57
57
|
|
|
58
|
+
const p2vs = await client.pathsToVictory.list({
|
|
59
|
+
userId: 42,
|
|
60
|
+
offset: 0,
|
|
61
|
+
limit: 20,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const p2v = await client.pathsToVictory.get(1)
|
|
65
|
+
|
|
66
|
+
const updatedP2v = await client.pathsToVictory.update(1, {
|
|
67
|
+
data: { p2vStatus: 'Complete', winNumber: 5000 },
|
|
68
|
+
})
|
|
69
|
+
|
|
58
70
|
client.destroy()
|
|
59
71
|
```
|
|
60
72
|
|
package/dist/index.d.mts
CHANGED
|
@@ -247,6 +247,76 @@ declare class CampaignsResource extends BaseResource {
|
|
|
247
247
|
update: (id: number, input: UpdateCampaignInput) => Promise<Campaign>;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
declare enum P2VStatus {
|
|
251
|
+
complete = "Complete",
|
|
252
|
+
waiting = "Waiting",
|
|
253
|
+
failed = "Failed",
|
|
254
|
+
districtMatched = "DistrictMatched"
|
|
255
|
+
}
|
|
256
|
+
declare enum P2VSource {
|
|
257
|
+
GpApi = "GpApi",
|
|
258
|
+
ElectionApi = "ElectionApi"
|
|
259
|
+
}
|
|
260
|
+
type ViabilityScore = {
|
|
261
|
+
level: string;
|
|
262
|
+
isPartisan: boolean;
|
|
263
|
+
isIncumbent: boolean;
|
|
264
|
+
isUncontested: boolean;
|
|
265
|
+
candidates: number;
|
|
266
|
+
seats: number;
|
|
267
|
+
candidatesPerSeat: number;
|
|
268
|
+
score: number;
|
|
269
|
+
probOfWin: number;
|
|
270
|
+
};
|
|
271
|
+
type PathToVictoryData = {
|
|
272
|
+
p2vStatus?: P2VStatus;
|
|
273
|
+
p2vAttempts?: number;
|
|
274
|
+
p2vCompleteDate?: string;
|
|
275
|
+
completedBy?: number;
|
|
276
|
+
electionType?: string;
|
|
277
|
+
electionLocation?: string;
|
|
278
|
+
voterContactGoal?: number;
|
|
279
|
+
winNumber?: number;
|
|
280
|
+
p2vNotNeeded?: boolean;
|
|
281
|
+
totalRegisteredVoters?: number;
|
|
282
|
+
republicans?: number;
|
|
283
|
+
democrats?: number;
|
|
284
|
+
indies?: number;
|
|
285
|
+
women?: number;
|
|
286
|
+
men?: number;
|
|
287
|
+
white?: number;
|
|
288
|
+
asian?: number;
|
|
289
|
+
africanAmerican?: number;
|
|
290
|
+
hispanic?: number;
|
|
291
|
+
averageTurnout?: number;
|
|
292
|
+
projectedTurnout?: number;
|
|
293
|
+
viability?: ViabilityScore;
|
|
294
|
+
source?: P2VSource;
|
|
295
|
+
districtId?: string;
|
|
296
|
+
districtManuallySet?: boolean;
|
|
297
|
+
officeContextFingerprint?: string;
|
|
298
|
+
};
|
|
299
|
+
type PathToVictory = {
|
|
300
|
+
id: number;
|
|
301
|
+
createdAt: string;
|
|
302
|
+
updatedAt: string;
|
|
303
|
+
campaignId: number;
|
|
304
|
+
data: PathToVictoryData;
|
|
305
|
+
};
|
|
306
|
+
type ListPathsToVictoryOptions = PaginationOptions & {
|
|
307
|
+
userId?: number;
|
|
308
|
+
};
|
|
309
|
+
type UpdatePathToVictoryInput = {
|
|
310
|
+
data: PathToVictoryData;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
declare class PathsToVictoryResource extends BaseResource {
|
|
314
|
+
protected resourceBasePath: string;
|
|
315
|
+
list: (options?: ListPathsToVictoryOptions) => Promise<PaginatedList<PathToVictory>>;
|
|
316
|
+
get: (id: number) => Promise<PathToVictory>;
|
|
317
|
+
update: (id: number, input: UpdatePathToVictoryInput) => Promise<PathToVictory>;
|
|
318
|
+
}
|
|
319
|
+
|
|
250
320
|
declare enum UserRole {
|
|
251
321
|
admin = "admin",
|
|
252
322
|
sales = "sales",
|
|
@@ -327,10 +397,11 @@ type GoodPartyClientConfig = {
|
|
|
327
397
|
declare class GoodPartyClient {
|
|
328
398
|
readonly users: UsersResource;
|
|
329
399
|
readonly campaigns: CampaignsResource;
|
|
400
|
+
readonly pathsToVictory: PathsToVictoryResource;
|
|
330
401
|
private clerkService;
|
|
331
402
|
private constructor();
|
|
332
403
|
static create: (config: GoodPartyClientConfig) => Promise<GoodPartyClient>;
|
|
333
404
|
destroy: () => void;
|
|
334
405
|
}
|
|
335
406
|
|
|
336
|
-
export { type AiChatMessage, type AiContentData, type AiContentGenerationStatus, type AiContentInputValues, BallotReadyPositionLevel, type Campaign, type CampaignAiContent, CampaignCreatedBy, type CampaignData, type CampaignDetails, CampaignLaunchStatus, CampaignTier, type CustomIssue, type CustomVoterFile, ElectionLevel, GenerationStatus, type GeoLocation, GoodPartyClient, type GoodPartyClientConfig, type HubSpotUpdates, type ListCampaignsOptions, type ListUsersOptions, OnboardingStep, type Opponent, type PaginatedList, type PaginationMeta, type PaginationOptions, SdkError, type UpdateCampaignInput, type UpdatePasswordInput, type UpdateUserInput, type User, type UserMetaData, UserRole, type VoterGoals, WhyBrowsing };
|
|
407
|
+
export { type AiChatMessage, type AiContentData, type AiContentGenerationStatus, type AiContentInputValues, BallotReadyPositionLevel, type Campaign, type CampaignAiContent, CampaignCreatedBy, type CampaignData, type CampaignDetails, CampaignLaunchStatus, CampaignTier, type CustomIssue, type CustomVoterFile, ElectionLevel, GenerationStatus, type GeoLocation, GoodPartyClient, type GoodPartyClientConfig, type HubSpotUpdates, type ListCampaignsOptions, type ListPathsToVictoryOptions, type ListUsersOptions, OnboardingStep, type Opponent, P2VSource, P2VStatus, type PaginatedList, type PaginationMeta, type PaginationOptions, type PathToVictory, type PathToVictoryData, SdkError, type UpdateCampaignInput, type UpdatePasswordInput, type UpdatePathToVictoryInput, type UpdateUserInput, type User, type UserMetaData, UserRole, type ViabilityScore, type VoterGoals, WhyBrowsing };
|
package/dist/index.d.ts
CHANGED
|
@@ -247,6 +247,76 @@ declare class CampaignsResource extends BaseResource {
|
|
|
247
247
|
update: (id: number, input: UpdateCampaignInput) => Promise<Campaign>;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
declare enum P2VStatus {
|
|
251
|
+
complete = "Complete",
|
|
252
|
+
waiting = "Waiting",
|
|
253
|
+
failed = "Failed",
|
|
254
|
+
districtMatched = "DistrictMatched"
|
|
255
|
+
}
|
|
256
|
+
declare enum P2VSource {
|
|
257
|
+
GpApi = "GpApi",
|
|
258
|
+
ElectionApi = "ElectionApi"
|
|
259
|
+
}
|
|
260
|
+
type ViabilityScore = {
|
|
261
|
+
level: string;
|
|
262
|
+
isPartisan: boolean;
|
|
263
|
+
isIncumbent: boolean;
|
|
264
|
+
isUncontested: boolean;
|
|
265
|
+
candidates: number;
|
|
266
|
+
seats: number;
|
|
267
|
+
candidatesPerSeat: number;
|
|
268
|
+
score: number;
|
|
269
|
+
probOfWin: number;
|
|
270
|
+
};
|
|
271
|
+
type PathToVictoryData = {
|
|
272
|
+
p2vStatus?: P2VStatus;
|
|
273
|
+
p2vAttempts?: number;
|
|
274
|
+
p2vCompleteDate?: string;
|
|
275
|
+
completedBy?: number;
|
|
276
|
+
electionType?: string;
|
|
277
|
+
electionLocation?: string;
|
|
278
|
+
voterContactGoal?: number;
|
|
279
|
+
winNumber?: number;
|
|
280
|
+
p2vNotNeeded?: boolean;
|
|
281
|
+
totalRegisteredVoters?: number;
|
|
282
|
+
republicans?: number;
|
|
283
|
+
democrats?: number;
|
|
284
|
+
indies?: number;
|
|
285
|
+
women?: number;
|
|
286
|
+
men?: number;
|
|
287
|
+
white?: number;
|
|
288
|
+
asian?: number;
|
|
289
|
+
africanAmerican?: number;
|
|
290
|
+
hispanic?: number;
|
|
291
|
+
averageTurnout?: number;
|
|
292
|
+
projectedTurnout?: number;
|
|
293
|
+
viability?: ViabilityScore;
|
|
294
|
+
source?: P2VSource;
|
|
295
|
+
districtId?: string;
|
|
296
|
+
districtManuallySet?: boolean;
|
|
297
|
+
officeContextFingerprint?: string;
|
|
298
|
+
};
|
|
299
|
+
type PathToVictory = {
|
|
300
|
+
id: number;
|
|
301
|
+
createdAt: string;
|
|
302
|
+
updatedAt: string;
|
|
303
|
+
campaignId: number;
|
|
304
|
+
data: PathToVictoryData;
|
|
305
|
+
};
|
|
306
|
+
type ListPathsToVictoryOptions = PaginationOptions & {
|
|
307
|
+
userId?: number;
|
|
308
|
+
};
|
|
309
|
+
type UpdatePathToVictoryInput = {
|
|
310
|
+
data: PathToVictoryData;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
declare class PathsToVictoryResource extends BaseResource {
|
|
314
|
+
protected resourceBasePath: string;
|
|
315
|
+
list: (options?: ListPathsToVictoryOptions) => Promise<PaginatedList<PathToVictory>>;
|
|
316
|
+
get: (id: number) => Promise<PathToVictory>;
|
|
317
|
+
update: (id: number, input: UpdatePathToVictoryInput) => Promise<PathToVictory>;
|
|
318
|
+
}
|
|
319
|
+
|
|
250
320
|
declare enum UserRole {
|
|
251
321
|
admin = "admin",
|
|
252
322
|
sales = "sales",
|
|
@@ -327,10 +397,11 @@ type GoodPartyClientConfig = {
|
|
|
327
397
|
declare class GoodPartyClient {
|
|
328
398
|
readonly users: UsersResource;
|
|
329
399
|
readonly campaigns: CampaignsResource;
|
|
400
|
+
readonly pathsToVictory: PathsToVictoryResource;
|
|
330
401
|
private clerkService;
|
|
331
402
|
private constructor();
|
|
332
403
|
static create: (config: GoodPartyClientConfig) => Promise<GoodPartyClient>;
|
|
333
404
|
destroy: () => void;
|
|
334
405
|
}
|
|
335
406
|
|
|
336
|
-
export { type AiChatMessage, type AiContentData, type AiContentGenerationStatus, type AiContentInputValues, BallotReadyPositionLevel, type Campaign, type CampaignAiContent, CampaignCreatedBy, type CampaignData, type CampaignDetails, CampaignLaunchStatus, CampaignTier, type CustomIssue, type CustomVoterFile, ElectionLevel, GenerationStatus, type GeoLocation, GoodPartyClient, type GoodPartyClientConfig, type HubSpotUpdates, type ListCampaignsOptions, type ListUsersOptions, OnboardingStep, type Opponent, type PaginatedList, type PaginationMeta, type PaginationOptions, SdkError, type UpdateCampaignInput, type UpdatePasswordInput, type UpdateUserInput, type User, type UserMetaData, UserRole, type VoterGoals, WhyBrowsing };
|
|
407
|
+
export { type AiChatMessage, type AiContentData, type AiContentGenerationStatus, type AiContentInputValues, BallotReadyPositionLevel, type Campaign, type CampaignAiContent, CampaignCreatedBy, type CampaignData, type CampaignDetails, CampaignLaunchStatus, CampaignTier, type CustomIssue, type CustomVoterFile, ElectionLevel, GenerationStatus, type GeoLocation, GoodPartyClient, type GoodPartyClientConfig, type HubSpotUpdates, type ListCampaignsOptions, type ListPathsToVictoryOptions, type ListUsersOptions, OnboardingStep, type Opponent, P2VSource, P2VStatus, type PaginatedList, type PaginationMeta, type PaginationOptions, type PathToVictory, type PathToVictoryData, SdkError, type UpdateCampaignInput, type UpdatePasswordInput, type UpdatePathToVictoryInput, type UpdateUserInput, type User, type UserMetaData, UserRole, type ViabilityScore, type VoterGoals, WhyBrowsing };
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,8 @@ __export(index_exports, {
|
|
|
28
28
|
GenerationStatus: () => GenerationStatus,
|
|
29
29
|
GoodPartyClient: () => GoodPartyClient,
|
|
30
30
|
OnboardingStep: () => OnboardingStep,
|
|
31
|
+
P2VSource: () => P2VSource,
|
|
32
|
+
P2VStatus: () => P2VStatus,
|
|
31
33
|
SdkError: () => SdkError,
|
|
32
34
|
UserRole: () => UserRole,
|
|
33
35
|
WhyBrowsing: () => WhyBrowsing
|
|
@@ -95,6 +97,17 @@ var CampaignsResource = class extends BaseResource {
|
|
|
95
97
|
update = (id, input) => this.putRequest(`/campaigns/${id}`, input);
|
|
96
98
|
};
|
|
97
99
|
|
|
100
|
+
// src/resources/PathsToVictoryResource.ts
|
|
101
|
+
var PathsToVictoryResource = class extends BaseResource {
|
|
102
|
+
resourceBasePath = "/path-to-victory";
|
|
103
|
+
list = (options) => this.getRequest(
|
|
104
|
+
`${this.resourceBasePath}/list`,
|
|
105
|
+
options
|
|
106
|
+
);
|
|
107
|
+
get = (id) => this.getRequest(`${this.resourceBasePath}/${id}`);
|
|
108
|
+
update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
|
|
109
|
+
};
|
|
110
|
+
|
|
98
111
|
// src/resources/UsersResource.ts
|
|
99
112
|
var UsersResource = class extends BaseResource {
|
|
100
113
|
list = (options) => this.getRequest("/users", options);
|
|
@@ -195,12 +208,14 @@ var ClerkService = class {
|
|
|
195
208
|
var GoodPartyClient = class _GoodPartyClient {
|
|
196
209
|
users;
|
|
197
210
|
campaigns;
|
|
211
|
+
pathsToVictory;
|
|
198
212
|
clerkService;
|
|
199
213
|
constructor(clerkService, gpApiRootUrl) {
|
|
200
214
|
this.clerkService = clerkService;
|
|
201
215
|
const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken);
|
|
202
216
|
this.users = new UsersResource(httpClient);
|
|
203
217
|
this.campaigns = new CampaignsResource(httpClient);
|
|
218
|
+
this.pathsToVictory = new PathsToVictoryResource(httpClient);
|
|
204
219
|
}
|
|
205
220
|
static create = async (config) => {
|
|
206
221
|
const { m2mSecret, gpApiRootUrl } = config;
|
|
@@ -272,6 +287,20 @@ var GenerationStatus = /* @__PURE__ */ ((GenerationStatus2) => {
|
|
|
272
287
|
GenerationStatus2["completed"] = "completed";
|
|
273
288
|
return GenerationStatus2;
|
|
274
289
|
})(GenerationStatus || {});
|
|
290
|
+
|
|
291
|
+
// src/types/pathToVictory.ts
|
|
292
|
+
var P2VStatus = /* @__PURE__ */ ((P2VStatus2) => {
|
|
293
|
+
P2VStatus2["complete"] = "Complete";
|
|
294
|
+
P2VStatus2["waiting"] = "Waiting";
|
|
295
|
+
P2VStatus2["failed"] = "Failed";
|
|
296
|
+
P2VStatus2["districtMatched"] = "DistrictMatched";
|
|
297
|
+
return P2VStatus2;
|
|
298
|
+
})(P2VStatus || {});
|
|
299
|
+
var P2VSource = /* @__PURE__ */ ((P2VSource2) => {
|
|
300
|
+
P2VSource2["GpApi"] = "GpApi";
|
|
301
|
+
P2VSource2["ElectionApi"] = "ElectionApi";
|
|
302
|
+
return P2VSource2;
|
|
303
|
+
})(P2VSource || {});
|
|
275
304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
276
305
|
0 && (module.exports = {
|
|
277
306
|
BallotReadyPositionLevel,
|
|
@@ -282,6 +311,8 @@ var GenerationStatus = /* @__PURE__ */ ((GenerationStatus2) => {
|
|
|
282
311
|
GenerationStatus,
|
|
283
312
|
GoodPartyClient,
|
|
284
313
|
OnboardingStep,
|
|
314
|
+
P2VSource,
|
|
315
|
+
P2VStatus,
|
|
285
316
|
SdkError,
|
|
286
317
|
UserRole,
|
|
287
318
|
WhyBrowsing
|
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/UsersResource.ts","../src/vendor/clerk/clerk.service.ts","../src/GoodPartyClient.ts","../src/types/user.ts","../src/types/campaign.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","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\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 list = (options?: ListCampaignsOptions): Promise<PaginatedList<Campaign>> =>\n this.getRequest<PaginatedList<Campaign>>('/campaigns/list', options)\n\n update = (id: number, input: UpdateCampaignInput): Promise<Campaign> =>\n this.putRequest<Campaign>(`/campaigns/${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 list = (options?: ListUsersOptions): Promise<PaginatedList<User>> =>\n this.getRequest<PaginatedList<User>>('/users', 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>(`/users/${id}`, input)\n\n delete = (id: number): Promise<void> =>\n this.deleteRequest<void>(`/users/${id}`)\n\n updatePassword = (id: number, input: UpdatePasswordInput): Promise<void> =>\n this.putRequest<void>(`/users/${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 { 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 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 }\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"],"mappings":";;;;;;;;;;;;;;;;;;;;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,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BAAa;AACb,EAAAA,kBAAA,eAAY;AAFF,SAAAA;AAAA,GAAA;","names":["UserRole","WhyBrowsing","CampaignTier","BallotReadyPositionLevel","ElectionLevel","CampaignCreatedBy","CampaignLaunchStatus","OnboardingStep","GenerationStatus"]}
|
|
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/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 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\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 list = (options?: ListCampaignsOptions): Promise<PaginatedList<Campaign>> =>\n this.getRequest<PaginatedList<Campaign>>('/campaigns/list', options)\n\n update = (id: number, input: UpdateCampaignInput): Promise<Campaign> =>\n this.putRequest<Campaign>(`/campaigns/${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 list = (options?: ListUsersOptions): Promise<PaginatedList<User>> =>\n this.getRequest<PaginatedList<User>>('/users', 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>(`/users/${id}`, input)\n\n delete = (id: number): Promise<void> =>\n this.deleteRequest<void>(`/users/${id}`)\n\n updatePassword = (id: number, input: UpdatePasswordInput): Promise<void> =>\n this.putRequest<void>(`/users/${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 { 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 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.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;AAAA,IACH,SAAS,OAAgB;AACvB,UAAI,iBAAiB,0BAAY;AAC/B,cAAM,IAAI,SAAS,MAAM,cAAc,GAAG,MAAM,SAAS,MAAM,QAAQ;AAAA,MACzE;AACA,YAAM,UAAU,iBAAiB,Q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BAAL,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"]}
|
package/dist/index.mjs
CHANGED
|
@@ -59,6 +59,17 @@ var CampaignsResource = class extends BaseResource {
|
|
|
59
59
|
update = (id, input) => this.putRequest(`/campaigns/${id}`, input);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
// src/resources/PathsToVictoryResource.ts
|
|
63
|
+
var PathsToVictoryResource = class extends BaseResource {
|
|
64
|
+
resourceBasePath = "/path-to-victory";
|
|
65
|
+
list = (options) => this.getRequest(
|
|
66
|
+
`${this.resourceBasePath}/list`,
|
|
67
|
+
options
|
|
68
|
+
);
|
|
69
|
+
get = (id) => this.getRequest(`${this.resourceBasePath}/${id}`);
|
|
70
|
+
update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
|
|
71
|
+
};
|
|
72
|
+
|
|
62
73
|
// src/resources/UsersResource.ts
|
|
63
74
|
var UsersResource = class extends BaseResource {
|
|
64
75
|
list = (options) => this.getRequest("/users", options);
|
|
@@ -159,12 +170,14 @@ var ClerkService = class {
|
|
|
159
170
|
var GoodPartyClient = class _GoodPartyClient {
|
|
160
171
|
users;
|
|
161
172
|
campaigns;
|
|
173
|
+
pathsToVictory;
|
|
162
174
|
clerkService;
|
|
163
175
|
constructor(clerkService, gpApiRootUrl) {
|
|
164
176
|
this.clerkService = clerkService;
|
|
165
177
|
const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken);
|
|
166
178
|
this.users = new UsersResource(httpClient);
|
|
167
179
|
this.campaigns = new CampaignsResource(httpClient);
|
|
180
|
+
this.pathsToVictory = new PathsToVictoryResource(httpClient);
|
|
168
181
|
}
|
|
169
182
|
static create = async (config) => {
|
|
170
183
|
const { m2mSecret, gpApiRootUrl } = config;
|
|
@@ -236,6 +249,20 @@ var GenerationStatus = /* @__PURE__ */ ((GenerationStatus2) => {
|
|
|
236
249
|
GenerationStatus2["completed"] = "completed";
|
|
237
250
|
return GenerationStatus2;
|
|
238
251
|
})(GenerationStatus || {});
|
|
252
|
+
|
|
253
|
+
// src/types/pathToVictory.ts
|
|
254
|
+
var P2VStatus = /* @__PURE__ */ ((P2VStatus2) => {
|
|
255
|
+
P2VStatus2["complete"] = "Complete";
|
|
256
|
+
P2VStatus2["waiting"] = "Waiting";
|
|
257
|
+
P2VStatus2["failed"] = "Failed";
|
|
258
|
+
P2VStatus2["districtMatched"] = "DistrictMatched";
|
|
259
|
+
return P2VStatus2;
|
|
260
|
+
})(P2VStatus || {});
|
|
261
|
+
var P2VSource = /* @__PURE__ */ ((P2VSource2) => {
|
|
262
|
+
P2VSource2["GpApi"] = "GpApi";
|
|
263
|
+
P2VSource2["ElectionApi"] = "ElectionApi";
|
|
264
|
+
return P2VSource2;
|
|
265
|
+
})(P2VSource || {});
|
|
239
266
|
export {
|
|
240
267
|
BallotReadyPositionLevel,
|
|
241
268
|
CampaignCreatedBy,
|
|
@@ -245,6 +272,8 @@ export {
|
|
|
245
272
|
GenerationStatus,
|
|
246
273
|
GoodPartyClient,
|
|
247
274
|
OnboardingStep,
|
|
275
|
+
P2VSource,
|
|
276
|
+
P2VStatus,
|
|
248
277
|
SdkError,
|
|
249
278
|
UserRole,
|
|
250
279
|
WhyBrowsing
|
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/UsersResource.ts","../src/vendor/clerk/clerk.service.ts","../src/GoodPartyClient.ts","../src/types/user.ts","../src/types/campaign.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\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 list = (options?: ListCampaignsOptions): Promise<PaginatedList<Campaign>> =>\n this.getRequest<PaginatedList<Campaign>>('/campaigns/list', options)\n\n update = (id: number, input: UpdateCampaignInput): Promise<Campaign> =>\n this.putRequest<Campaign>(`/campaigns/${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 list = (options?: ListUsersOptions): Promise<PaginatedList<User>> =>\n this.getRequest<PaginatedList<User>>('/users', 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>(`/users/${id}`, input)\n\n delete = (id: number): Promise<void> =>\n this.deleteRequest<void>(`/users/${id}`)\n\n updatePassword = (id: number, input: UpdatePasswordInput): Promise<void> =>\n this.putRequest<void>(`/users/${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 { 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 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 }\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"],"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;AAA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yBrowsing","CampaignTier","BallotReadyPositionLevel","ElectionLevel","CampaignCreatedBy","CampaignLaunchStatus","OnboardingStep","GenerationStatus"]}
|
|
1
|
+
{"version":3,"sources":["../src/http/HttpClient.ts","../src/types/result.ts","../src/resources/BaseResource.ts","../src/resources/CampaignsResource.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\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 list = (options?: ListCampaignsOptions): Promise<PaginatedList<Campaign>> =>\n this.getRequest<PaginatedList<Campaign>>('/campaigns/list', options)\n\n update = (id: number, input: UpdateCampaignInput): Promise<Campaign> =>\n this.putRequest<Campaign>(`/campaigns/${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 list = (options?: ListUsersOptions): Promise<PaginatedList<User>> =>\n this.getRequest<PaginatedList<User>>('/users', 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>(`/users/${id}`, input)\n\n delete = (id: number): Promise<void> =>\n this.deleteRequest<void>(`/users/${id}`)\n\n updatePassword = (id: number, input: UpdatePasswordInput): Promise<void> =>\n this.putRequest<void>(`/users/${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 { 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 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.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,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C,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"]}
|