@goodparty_org/sdk 1.11.2 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -82,6 +82,18 @@ const updatedP2v = await client.pathsToVictory.update(1, {
82
82
  data: { p2vStatus: 'Complete', winNumber: 5000 },
83
83
  })
84
84
 
85
+ // Ecanvasser
86
+ const ecanvasser = await client.ecanvasser.create({
87
+ apiKey: 'ecanvasser-api-key',
88
+ email: 'user@example.com',
89
+ })
90
+
91
+ const allEcanvassers = await client.ecanvasser.list()
92
+
93
+ await client.ecanvasser.syncAll()
94
+
95
+ await client.ecanvasser.delete(campaignId)
96
+
85
97
  client.destroy()
86
98
  ```
87
99
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
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 as UpdateCampaignInput, UpdatePasswordInput, UpdateUserInput, ReadUserOutput as User, UserMetaData, VoterGoals, WHY_BROWSING_VALUES } from '@goodparty_org/contracts';
1
+ import { ReadCampaignOutput, ListCampaignsPagination, PaginatedList, UpdateCampaignM2MInput, CreateEcanvasserInput, Ecanvasser, EcanvasserSummary, 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, CreateEcanvasserInput, CustomIssue, CustomVoterFile, ELECTION_LEVEL_VALUES, Ecanvasser, EcanvasserSummary, ElectionLevel, GENERATION_STATUS_VALUES, GenerationStatus, GeoLocation, HubSpotUpdates, ListCampaignsPagination, ListUsersPagination, ONBOARDING_STEP_VALUES, OnboardingStep, Opponent, PaginatedList, PaginationMeta, PaginationOptions, ReadCampaignOutput, ReadUserOutput, USER_ROLE_VALUES, UpdateCampaignM2MInput as UpdateCampaignInput, UpdatePasswordInput, UpdateUserInput, ReadUserOutput as User, UserMetaData, VoterGoals, WHY_BROWSING_VALUES } from '@goodparty_org/contracts';
3
3
  import { FetchOptions } from 'ofetch';
4
4
 
5
5
  type OfetchRequestBody = FetchOptions<'json'>['body'];
@@ -27,6 +27,14 @@ declare class CampaignsResource extends BaseResource {
27
27
  update: (id: number, input: UpdateCampaignM2MInput) => Promise<ReadCampaignOutput>;
28
28
  }
29
29
 
30
+ declare class EcanvasserResource extends BaseResource {
31
+ protected readonly resourceBasePath = "/ecanvasser";
32
+ create: (input: CreateEcanvasserInput) => Promise<Ecanvasser>;
33
+ list: () => Promise<EcanvasserSummary[]>;
34
+ syncAll: () => Promise<void>;
35
+ delete: (campaignId: number) => Promise<void>;
36
+ }
37
+
30
38
  type ElectedOffice = {
31
39
  id: string;
32
40
  electedDate: string | null;
@@ -145,6 +153,7 @@ type GoodPartyClientConfig = {
145
153
  declare class GoodPartyClient {
146
154
  readonly users: UsersResource;
147
155
  readonly campaigns: CampaignsResource;
156
+ readonly ecanvasser: EcanvasserResource;
148
157
  readonly electedOffices: ElectedOfficesResource;
149
158
  readonly pathsToVictory: PathsToVictoryResource;
150
159
  private clerkService;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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 as UpdateCampaignInput, UpdatePasswordInput, UpdateUserInput, ReadUserOutput as User, UserMetaData, VoterGoals, WHY_BROWSING_VALUES } from '@goodparty_org/contracts';
1
+ import { ReadCampaignOutput, ListCampaignsPagination, PaginatedList, UpdateCampaignM2MInput, CreateEcanvasserInput, Ecanvasser, EcanvasserSummary, 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, CreateEcanvasserInput, CustomIssue, CustomVoterFile, ELECTION_LEVEL_VALUES, Ecanvasser, EcanvasserSummary, ElectionLevel, GENERATION_STATUS_VALUES, GenerationStatus, GeoLocation, HubSpotUpdates, ListCampaignsPagination, ListUsersPagination, ONBOARDING_STEP_VALUES, OnboardingStep, Opponent, PaginatedList, PaginationMeta, PaginationOptions, ReadCampaignOutput, ReadUserOutput, USER_ROLE_VALUES, UpdateCampaignM2MInput as UpdateCampaignInput, UpdatePasswordInput, UpdateUserInput, ReadUserOutput as User, UserMetaData, VoterGoals, WHY_BROWSING_VALUES } from '@goodparty_org/contracts';
3
3
  import { FetchOptions } from 'ofetch';
4
4
 
5
5
  type OfetchRequestBody = FetchOptions<'json'>['body'];
@@ -27,6 +27,14 @@ declare class CampaignsResource extends BaseResource {
27
27
  update: (id: number, input: UpdateCampaignM2MInput) => Promise<ReadCampaignOutput>;
28
28
  }
29
29
 
30
+ declare class EcanvasserResource extends BaseResource {
31
+ protected readonly resourceBasePath = "/ecanvasser";
32
+ create: (input: CreateEcanvasserInput) => Promise<Ecanvasser>;
33
+ list: () => Promise<EcanvasserSummary[]>;
34
+ syncAll: () => Promise<void>;
35
+ delete: (campaignId: number) => Promise<void>;
36
+ }
37
+
30
38
  type ElectedOffice = {
31
39
  id: string;
32
40
  electedDate: string | null;
@@ -145,6 +153,7 @@ type GoodPartyClientConfig = {
145
153
  declare class GoodPartyClient {
146
154
  readonly users: UsersResource;
147
155
  readonly campaigns: CampaignsResource;
156
+ readonly ecanvasser: EcanvasserResource;
148
157
  readonly electedOffices: ElectedOfficesResource;
149
158
  readonly pathsToVictory: PathsToVictoryResource;
150
159
  private clerkService;
package/dist/index.js CHANGED
@@ -113,6 +113,15 @@ var CampaignsResource = class extends BaseResource {
113
113
  update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
114
114
  };
115
115
 
116
+ // src/resources/EcanvasserResource.ts
117
+ var EcanvasserResource = class extends BaseResource {
118
+ resourceBasePath = "/ecanvasser";
119
+ create = (input) => this.postRequest(this.resourceBasePath, input);
120
+ list = () => this.getRequest(`${this.resourceBasePath}/list`);
121
+ syncAll = () => this.getRequest(`${this.resourceBasePath}/sync-all`);
122
+ delete = (campaignId) => this.deleteRequest(`${this.resourceBasePath}/${campaignId}`);
123
+ };
124
+
116
125
  // src/resources/ElectedOfficesResource.ts
117
126
  var ElectedOfficesResource = class extends BaseResource {
118
127
  resourceBasePath = "/elected-office";
@@ -239,6 +248,7 @@ var ClerkService = class {
239
248
  var GoodPartyClient = class _GoodPartyClient {
240
249
  users;
241
250
  campaigns;
251
+ ecanvasser;
242
252
  electedOffices;
243
253
  pathsToVictory;
244
254
  clerkService;
@@ -247,6 +257,7 @@ var GoodPartyClient = class _GoodPartyClient {
247
257
  const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken);
248
258
  this.users = new UsersResource(httpClient);
249
259
  this.campaigns = new CampaignsResource(httpClient);
260
+ this.ecanvasser = new EcanvasserResource(httpClient);
250
261
  this.electedOffices = new ElectedOfficesResource(httpClient);
251
262
  this.pathsToVictory = new PathsToVictoryResource(httpClient);
252
263
  }
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/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 as UpdateCampaignInput,\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,S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C,UAAM,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"]}
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/EcanvasserResource.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 as UpdateCampaignInput,\n CreateEcanvasserInput,\n Ecanvasser,\n EcanvasserSummary,\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 {\n CreateEcanvasserInput,\n Ecanvasser,\n EcanvasserSummary,\n} from '@goodparty_org/contracts'\nimport { BaseResource } from './BaseResource'\n\nexport class EcanvasserResource extends BaseResource {\n protected readonly resourceBasePath = '/ecanvasser'\n\n create = (input: CreateEcanvasserInput): Promise<Ecanvasser> =>\n this.postRequest<Ecanvasser>(this.resourceBasePath, input)\n\n list = (): Promise<EcanvasserSummary[]> =>\n this.getRequest<EcanvasserSummary[]>(`${this.resourceBasePath}/list`)\n\n syncAll = (): Promise<void> =>\n this.getRequest<void>(`${this.resourceBasePath}/sync-all`)\n\n delete = (campaignId: number): Promise<void> =>\n this.deleteRequest<void>(`${this.resourceBasePath}/${campaignId}`)\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 { EcanvasserResource } from './resources/EcanvasserResource'\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 ecanvasser: EcanvasserResource\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.ecanvasser = new EcanvasserResource(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,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AACF;;;ADLO,IAAM,a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AAc,aAAa,QAAQ;AACrE,SAAK,QAAQ,IAAI,cAAc,UAAU;AACzC,SAAK,YAAY,IAAI,kBAAkB,UAAU;AACjD,SAAK,aAAa,IAAI,mBAAmB,UAAU;AACnD,SAAK,iBAAiB,IAAI,uBAAuB,UAAU;AAC3D,SAAK,iBAAiB,IAAI,uBAAuB,UAAU;AAAA,EAC7D;AAAA,EAEA,OAAO,SAAS,OACd,WAC6B;AAC7B,UAAM,EAAE,WAAW,aAAa,IAAI;AACpC,UAAM,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;;;AVHA,IAAAA,oBAkBO;;;AW1DP,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
@@ -64,6 +64,15 @@ var CampaignsResource = class extends BaseResource {
64
64
  update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
65
65
  };
66
66
 
67
+ // src/resources/EcanvasserResource.ts
68
+ var EcanvasserResource = class extends BaseResource {
69
+ resourceBasePath = "/ecanvasser";
70
+ create = (input) => this.postRequest(this.resourceBasePath, input);
71
+ list = () => this.getRequest(`${this.resourceBasePath}/list`);
72
+ syncAll = () => this.getRequest(`${this.resourceBasePath}/sync-all`);
73
+ delete = (campaignId) => this.deleteRequest(`${this.resourceBasePath}/${campaignId}`);
74
+ };
75
+
67
76
  // src/resources/ElectedOfficesResource.ts
68
77
  var ElectedOfficesResource = class extends BaseResource {
69
78
  resourceBasePath = "/elected-office";
@@ -190,6 +199,7 @@ var ClerkService = class {
190
199
  var GoodPartyClient = class _GoodPartyClient {
191
200
  users;
192
201
  campaigns;
202
+ ecanvasser;
193
203
  electedOffices;
194
204
  pathsToVictory;
195
205
  clerkService;
@@ -198,6 +208,7 @@ var GoodPartyClient = class _GoodPartyClient {
198
208
  const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken);
199
209
  this.users = new UsersResource(httpClient);
200
210
  this.campaigns = new CampaignsResource(httpClient);
211
+ this.ecanvasser = new EcanvasserResource(httpClient);
201
212
  this.electedOffices = new ElectedOfficesResource(httpClient);
202
213
  this.pathsToVictory = new PathsToVictoryResource(httpClient);
203
214
  }
@@ -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/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 as UpdateCampaignInput,\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,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,QAAQ,OAAO,MAAM,CAAC;AAAA,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A,WAAA,WAAQ;AACR,EAAAA,WAAA,iBAAc;AAFJ,SAAAA;AAAA,GAAA;","names":["USER_ROLE_VALUES","WHY_BROWSING_VALUES","CAMPAIGN_TIER_VALUES","P2VStatus","P2VSource"]}
1
+ {"version":3,"sources":["../src/http/HttpClient.ts","../src/types/result.ts","../src/resources/BaseResource.ts","../src/resources/CampaignsResource.ts","../src/resources/EcanvasserResource.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 {\n CreateEcanvasserInput,\n Ecanvasser,\n EcanvasserSummary,\n} from '@goodparty_org/contracts'\nimport { BaseResource } from './BaseResource'\n\nexport class EcanvasserResource extends BaseResource {\n protected readonly resourceBasePath = '/ecanvasser'\n\n create = (input: CreateEcanvasserInput): Promise<Ecanvasser> =>\n this.postRequest<Ecanvasser>(this.resourceBasePath, input)\n\n list = (): Promise<EcanvasserSummary[]> =>\n this.getRequest<EcanvasserSummary[]>(`${this.resourceBasePath}/list`)\n\n syncAll = (): Promise<void> =>\n this.getRequest<void>(`${this.resourceBasePath}/sync-all`)\n\n delete = (campaignId: number): Promise<void> =>\n this.deleteRequest<void>(`${this.resourceBasePath}/${campaignId}`)\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 { EcanvasserResource } from './resources/EcanvasserResource'\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 ecanvasser: EcanvasserResource\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.ecanvasser = new EcanvasserResource(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 as UpdateCampaignInput,\n CreateEcanvasserInput,\n Ecanvasser,\n EcanvasserSummary,\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,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,E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EAEA;AAAA,OAEK;AAIP,IAAM,eAAe,CAA8B,WACjD,OAAO,YAAY,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAGvC,IAAM,WAAW,aAAa,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.11.2",
3
+ "version": "1.12.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,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@clerk/backend": "^2.30.1",
52
- "@goodparty_org/contracts": "^0.0.0-rc-develop.6d7d232bf7de0048b9949ce45b6287aa54d3773a",
52
+ "@goodparty_org/contracts": "0.0.0-rc-develop.ae674d1852a1ef63798d7da64e74ed68c9851827",
53
53
  "ofetch": "^1.5.1"
54
54
  }
55
55
  }