@goodparty_org/sdk 1.13.0 → 2.0.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
@@ -70,16 +70,23 @@ const updatedOffice = await client.electedOffices.update('some-uuid', {
70
70
  isActive: true,
71
71
  })
72
72
 
73
- const p2vs = await client.pathsToVictory.list({
74
- userId: 42,
75
- offset: 0,
76
- limit: 20,
77
- })
78
-
79
- const p2v = await client.pathsToVictory.get(1)
80
-
81
- const updatedP2v = await client.pathsToVictory.update(1, {
82
- data: { p2vStatus: 'Complete', winNumber: 5000 },
73
+ const officeWithDistrict = await client.electedOffices.updateDistrict(
74
+ 'some-uuid',
75
+ {
76
+ state: 'CA',
77
+ L2DistrictType: 'CITY',
78
+ L2DistrictName: 'OAKLAND',
79
+ },
80
+ )
81
+
82
+ // Organizations (admin / M2M)
83
+ const org = await client.organizations.get('campaign-123')
84
+
85
+ const orgs = await client.organizations.list({ email: 'owner@example.com' })
86
+
87
+ const patched = await client.organizations.patch('campaign-123', {
88
+ customPositionName: 'Mayor',
89
+ overrideDistrictId: 'district-uuid',
83
90
  })
84
91
 
85
92
  // Ecanvasser
package/dist/index.d.mts CHANGED
@@ -1,6 +1,60 @@
1
+ import { FetchOptions } from 'ofetch';
1
2
  import { ReadCampaignOutput, ListCampaignsPagination, PaginatedList, UpdateCampaignM2MInput, SetDistrictOutput, 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
3
  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, SetDistrictOutput, USER_ROLE_VALUES, UpdateCampaignM2MInput as UpdateCampaignInput, UpdatePasswordInput, UpdateUserInput, ReadUserOutput as User, UserMetaData, VoterGoals, WHY_BROWSING_VALUES } from '@goodparty_org/contracts';
3
- import { FetchOptions } from 'ofetch';
4
+
5
+ type ImpersonateUserInput = {
6
+ actorClerkId: string;
7
+ };
8
+ type ImpersonateUserOutput = {
9
+ token: string;
10
+ };
11
+
12
+ type OfetchRequestBody = FetchOptions<'json'>['body'];
13
+ declare class HttpClient {
14
+ private baseUrl;
15
+ private getToken;
16
+ constructor(gpApiRootUrl: string, getToken: () => Promise<string>);
17
+ request: <T>(path: string, init?: FetchOptions<"json">) => Promise<T>;
18
+ }
19
+
20
+ declare abstract class BaseResource {
21
+ protected httpClient: HttpClient;
22
+ protected abstract readonly resourceBasePath: string;
23
+ constructor(httpClient: HttpClient);
24
+ protected getRequest: <T>(path: string, query?: FetchOptions<"json">["query"]) => Promise<T>;
25
+ protected postRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
26
+ protected putRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
27
+ protected patchRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
28
+ protected deleteRequest: <T>(path: string) => Promise<T>;
29
+ }
30
+
31
+ declare class AdminResource extends BaseResource {
32
+ protected readonly resourceBasePath = "/admin";
33
+ impersonateUser: (targetUserId: number, actorClerkId: string) => Promise<ImpersonateUserOutput>;
34
+ }
35
+
36
+ type RaceTargetMetrics = {
37
+ winNumber: number;
38
+ voterContactGoal: number;
39
+ projectedTurnout: number;
40
+ };
41
+ /**
42
+ * The full single-campaign read shape (e.g. `GET /campaigns/:id`),
43
+ * enriched with both `positionName` and live race-target metrics.
44
+ */
45
+ type CampaignWithLiveContext = ReadCampaignOutput & {
46
+ positionName: string | null;
47
+ raceTargetMetrics: RaceTargetMetrics | null;
48
+ };
49
+ /**
50
+ * The list-campaign read shape (e.g. `GET /campaigns/list`), enriched
51
+ * only with `positionName`. Live race-target metrics are intentionally
52
+ * excluded from list responses to avoid expensive per-row external
53
+ * lookups.
54
+ */
55
+ type CampaignWithPositionName = ReadCampaignOutput & {
56
+ positionName: string | null;
57
+ };
4
58
 
5
59
  type DistrictTypeItem = {
6
60
  id: string;
@@ -26,28 +80,10 @@ type UpdateDistrictInput = {
26
80
  L2DistrictName: string;
27
81
  };
28
82
 
29
- type OfetchRequestBody = FetchOptions<'json'>['body'];
30
- declare class HttpClient {
31
- private baseUrl;
32
- private getToken;
33
- constructor(gpApiRootUrl: string, getToken: () => Promise<string>);
34
- request: <T>(path: string, init?: FetchOptions<"json">) => Promise<T>;
35
- }
36
-
37
- declare abstract class BaseResource {
38
- protected httpClient: HttpClient;
39
- protected abstract readonly resourceBasePath: string;
40
- constructor(httpClient: HttpClient);
41
- protected getRequest: <T>(path: string, query?: FetchOptions<"json">["query"]) => Promise<T>;
42
- protected postRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
43
- protected putRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
44
- protected deleteRequest: <T>(path: string) => Promise<T>;
45
- }
46
-
47
83
  declare class CampaignsResource extends BaseResource {
48
84
  protected readonly resourceBasePath = "/campaigns";
49
- get: (id: number) => Promise<ReadCampaignOutput>;
50
- list: (options?: ListCampaignsPagination) => Promise<PaginatedList<ReadCampaignOutput>>;
85
+ get: (id: number) => Promise<CampaignWithLiveContext>;
86
+ list: (options?: ListCampaignsPagination) => Promise<PaginatedList<CampaignWithPositionName>>;
51
87
  update: (id: number, input: UpdateCampaignM2MInput) => Promise<ReadCampaignOutput>;
52
88
  updateDistrict: (id: number, input: UpdateDistrictInput) => Promise<SetDistrictOutput>;
53
89
  }
@@ -84,12 +120,22 @@ type UpdateElectedOfficeInput = {
84
120
  termLengthDays?: number | null;
85
121
  isActive?: boolean;
86
122
  };
123
+ type UpdateElectedOfficeDistrictInput = {
124
+ state: string;
125
+ L2DistrictType: string;
126
+ L2DistrictName: string;
127
+ };
128
+ type SetElectedOfficeDistrictOutput = {
129
+ electedOfficeId: string;
130
+ overrideDistrictId: string | null;
131
+ };
87
132
 
88
133
  declare class ElectedOfficesResource extends BaseResource {
89
134
  protected readonly resourceBasePath = "/elected-office";
90
135
  list: (options?: ListElectedOfficesOptions) => Promise<PaginatedList<ElectedOffice>>;
91
136
  get: (id: string) => Promise<ElectedOffice>;
92
137
  update: (id: string, input: UpdateElectedOfficeInput) => Promise<ElectedOffice>;
138
+ updateDistrict: (id: string, input: UpdateElectedOfficeDistrictInput) => Promise<SetElectedOfficeDistrictOutput>;
93
139
  }
94
140
 
95
141
  declare class ElectionsResource extends BaseResource {
@@ -98,74 +144,61 @@ declare class ElectionsResource extends BaseResource {
98
144
  listDistrictNames: (options: ListDistrictNamesOptions) => Promise<DistrictNameItem[]>;
99
145
  }
100
146
 
101
- declare enum P2VStatus {
102
- complete = "Complete",
103
- waiting = "Waiting",
104
- failed = "Failed",
105
- districtMatched = "DistrictMatched"
106
- }
107
- declare enum P2VSource {
108
- GpApi = "GpApi",
109
- ElectionApi = "ElectionApi"
110
- }
111
- type ViabilityScore = {
112
- level: string;
113
- isPartisan: boolean;
114
- isIncumbent: boolean;
115
- isUncontested: boolean;
116
- candidates: number;
117
- seats: number;
118
- candidatesPerSeat: number;
119
- score: number;
120
- probOfWin: number;
121
- };
122
- type PathToVictoryData = {
123
- p2vStatus?: P2VStatus;
124
- p2vAttempts?: number;
125
- p2vCompleteDate?: string;
126
- completedBy?: number;
127
- electionType?: string;
128
- electionLocation?: string;
129
- voterContactGoal?: number;
130
- winNumber?: number;
131
- p2vNotNeeded?: boolean;
132
- totalRegisteredVoters?: number;
133
- republicans?: number;
134
- democrats?: number;
135
- indies?: number;
136
- women?: number;
137
- men?: number;
138
- white?: number;
139
- asian?: number;
140
- africanAmerican?: number;
141
- hispanic?: number;
142
- averageTurnout?: number;
143
- projectedTurnout?: number;
144
- viability?: ViabilityScore;
145
- source?: P2VSource;
146
- districtId?: string;
147
- districtManuallySet?: boolean;
148
- officeContextFingerprint?: string;
149
- };
150
- type PathToVictory = {
147
+ type OrgDistrict = {
148
+ id: string;
149
+ l2Type: string;
150
+ l2Name: string;
151
+ };
152
+ type OrgPosition = {
153
+ id: string;
154
+ state: string;
155
+ brPositionId: string;
156
+ };
157
+ type Organization = {
158
+ slug: string;
159
+ name: string | null;
160
+ positionName: string | null;
161
+ position: OrgPosition | null;
162
+ district: OrgDistrict | null;
163
+ electedOfficeId: string | null;
164
+ campaignId: number | null;
165
+ };
166
+ type ListOrganizationsOptions = {
167
+ slug?: string;
168
+ email?: string;
169
+ };
170
+ type OrganizationOwnerSummary = {
151
171
  id: number;
152
- createdAt: string;
153
- updatedAt: string;
154
- campaignId: number;
155
- data: PathToVictoryData;
172
+ email: string | null;
173
+ firstName: string | null;
174
+ lastName: string | null;
175
+ phone: string | null;
156
176
  };
157
- type ListPathsToVictoryOptions = PaginationOptions & {
158
- userId?: number;
177
+ type OrganizationListItem = Organization & {
178
+ extra: {
179
+ positionName: string | null;
180
+ hasDistrictOverride: boolean;
181
+ owner: OrganizationOwnerSummary;
182
+ campaign: {
183
+ id: number;
184
+ slug: string;
185
+ details: unknown;
186
+ } | null;
187
+ };
159
188
  };
160
- type UpdatePathToVictoryInput = {
161
- data: PathToVictoryData;
189
+ type PatchOrganizationInput = {
190
+ ballotReadyPositionId?: string | null;
191
+ overrideDistrictId?: string | null;
192
+ customPositionName?: string | null;
162
193
  };
163
194
 
164
- declare class PathsToVictoryResource extends BaseResource {
165
- protected resourceBasePath: string;
166
- list: (options?: ListPathsToVictoryOptions) => Promise<PaginatedList<PathToVictory>>;
167
- get: (id: number) => Promise<PathToVictory>;
168
- update: (id: number, input: UpdatePathToVictoryInput) => Promise<PathToVictory>;
195
+ declare class OrganizationsResource extends BaseResource {
196
+ protected readonly resourceBasePath = "/organizations";
197
+ get: (slug: string) => Promise<Organization>;
198
+ list: (options?: ListOrganizationsOptions) => Promise<{
199
+ organizations: OrganizationListItem[];
200
+ }>;
201
+ patch: (slug: string, input: PatchOrganizationInput) => Promise<Organization>;
169
202
  }
170
203
 
171
204
  declare class UsersResource extends BaseResource {
@@ -182,12 +215,13 @@ type GoodPartyClientConfig = {
182
215
  gpApiRootUrl: string;
183
216
  };
184
217
  declare class GoodPartyClient {
218
+ readonly admin: AdminResource;
185
219
  readonly users: UsersResource;
186
220
  readonly campaigns: CampaignsResource;
187
221
  readonly ecanvasser: EcanvasserResource;
188
222
  readonly electedOffices: ElectedOfficesResource;
189
223
  readonly elections: ElectionsResource;
190
- readonly pathsToVictory: PathsToVictoryResource;
224
+ readonly organizations: OrganizationsResource;
191
225
  private clerkService;
192
226
  private constructor();
193
227
  static create: (config: GoodPartyClientConfig) => Promise<GoodPartyClient>;
@@ -210,4 +244,4 @@ declare const WhyBrowsing: EnumObject<readonly ["considering", "learning", "test
210
244
  type CampaignTier = CampaignTier$1;
211
245
  declare const CampaignTier: EnumObject<readonly ["WIN", "LOSE", "TOSSUP"]>;
212
246
 
213
- export { CampaignTier, type DistrictNameItem, type DistrictTypeItem, type ElectedOffice, GoodPartyClient, type GoodPartyClientConfig, type ListDistrictNamesOptions, type ListDistrictTypesOptions, type ListElectedOfficesOptions, type ListPathsToVictoryOptions, P2VSource, P2VStatus, type PathToVictory, type PathToVictoryData, SdkError, type UpdateDistrictInput, type UpdateElectedOfficeInput, type UpdatePathToVictoryInput, UserRole, type ViabilityScore, WhyBrowsing };
247
+ export { CampaignTier, type CampaignWithLiveContext, type CampaignWithPositionName, type DistrictNameItem, type DistrictTypeItem, type ElectedOffice, GoodPartyClient, type GoodPartyClientConfig, type ImpersonateUserInput, type ImpersonateUserOutput, type ListDistrictNamesOptions, type ListDistrictTypesOptions, type ListElectedOfficesOptions, type ListOrganizationsOptions, type OrgDistrict, type OrgPosition, type Organization, type OrganizationListItem, type OrganizationOwnerSummary, type PatchOrganizationInput, type RaceTargetMetrics, SdkError, type SetElectedOfficeDistrictOutput, type UpdateDistrictInput, type UpdateElectedOfficeDistrictInput, type UpdateElectedOfficeInput, UserRole, WhyBrowsing };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,60 @@
1
+ import { FetchOptions } from 'ofetch';
1
2
  import { ReadCampaignOutput, ListCampaignsPagination, PaginatedList, UpdateCampaignM2MInput, SetDistrictOutput, 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
3
  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, SetDistrictOutput, USER_ROLE_VALUES, UpdateCampaignM2MInput as UpdateCampaignInput, UpdatePasswordInput, UpdateUserInput, ReadUserOutput as User, UserMetaData, VoterGoals, WHY_BROWSING_VALUES } from '@goodparty_org/contracts';
3
- import { FetchOptions } from 'ofetch';
4
+
5
+ type ImpersonateUserInput = {
6
+ actorClerkId: string;
7
+ };
8
+ type ImpersonateUserOutput = {
9
+ token: string;
10
+ };
11
+
12
+ type OfetchRequestBody = FetchOptions<'json'>['body'];
13
+ declare class HttpClient {
14
+ private baseUrl;
15
+ private getToken;
16
+ constructor(gpApiRootUrl: string, getToken: () => Promise<string>);
17
+ request: <T>(path: string, init?: FetchOptions<"json">) => Promise<T>;
18
+ }
19
+
20
+ declare abstract class BaseResource {
21
+ protected httpClient: HttpClient;
22
+ protected abstract readonly resourceBasePath: string;
23
+ constructor(httpClient: HttpClient);
24
+ protected getRequest: <T>(path: string, query?: FetchOptions<"json">["query"]) => Promise<T>;
25
+ protected postRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
26
+ protected putRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
27
+ protected patchRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
28
+ protected deleteRequest: <T>(path: string) => Promise<T>;
29
+ }
30
+
31
+ declare class AdminResource extends BaseResource {
32
+ protected readonly resourceBasePath = "/admin";
33
+ impersonateUser: (targetUserId: number, actorClerkId: string) => Promise<ImpersonateUserOutput>;
34
+ }
35
+
36
+ type RaceTargetMetrics = {
37
+ winNumber: number;
38
+ voterContactGoal: number;
39
+ projectedTurnout: number;
40
+ };
41
+ /**
42
+ * The full single-campaign read shape (e.g. `GET /campaigns/:id`),
43
+ * enriched with both `positionName` and live race-target metrics.
44
+ */
45
+ type CampaignWithLiveContext = ReadCampaignOutput & {
46
+ positionName: string | null;
47
+ raceTargetMetrics: RaceTargetMetrics | null;
48
+ };
49
+ /**
50
+ * The list-campaign read shape (e.g. `GET /campaigns/list`), enriched
51
+ * only with `positionName`. Live race-target metrics are intentionally
52
+ * excluded from list responses to avoid expensive per-row external
53
+ * lookups.
54
+ */
55
+ type CampaignWithPositionName = ReadCampaignOutput & {
56
+ positionName: string | null;
57
+ };
4
58
 
5
59
  type DistrictTypeItem = {
6
60
  id: string;
@@ -26,28 +80,10 @@ type UpdateDistrictInput = {
26
80
  L2DistrictName: string;
27
81
  };
28
82
 
29
- type OfetchRequestBody = FetchOptions<'json'>['body'];
30
- declare class HttpClient {
31
- private baseUrl;
32
- private getToken;
33
- constructor(gpApiRootUrl: string, getToken: () => Promise<string>);
34
- request: <T>(path: string, init?: FetchOptions<"json">) => Promise<T>;
35
- }
36
-
37
- declare abstract class BaseResource {
38
- protected httpClient: HttpClient;
39
- protected abstract readonly resourceBasePath: string;
40
- constructor(httpClient: HttpClient);
41
- protected getRequest: <T>(path: string, query?: FetchOptions<"json">["query"]) => Promise<T>;
42
- protected postRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
43
- protected putRequest: <T>(path: string, body: OfetchRequestBody) => Promise<T>;
44
- protected deleteRequest: <T>(path: string) => Promise<T>;
45
- }
46
-
47
83
  declare class CampaignsResource extends BaseResource {
48
84
  protected readonly resourceBasePath = "/campaigns";
49
- get: (id: number) => Promise<ReadCampaignOutput>;
50
- list: (options?: ListCampaignsPagination) => Promise<PaginatedList<ReadCampaignOutput>>;
85
+ get: (id: number) => Promise<CampaignWithLiveContext>;
86
+ list: (options?: ListCampaignsPagination) => Promise<PaginatedList<CampaignWithPositionName>>;
51
87
  update: (id: number, input: UpdateCampaignM2MInput) => Promise<ReadCampaignOutput>;
52
88
  updateDistrict: (id: number, input: UpdateDistrictInput) => Promise<SetDistrictOutput>;
53
89
  }
@@ -84,12 +120,22 @@ type UpdateElectedOfficeInput = {
84
120
  termLengthDays?: number | null;
85
121
  isActive?: boolean;
86
122
  };
123
+ type UpdateElectedOfficeDistrictInput = {
124
+ state: string;
125
+ L2DistrictType: string;
126
+ L2DistrictName: string;
127
+ };
128
+ type SetElectedOfficeDistrictOutput = {
129
+ electedOfficeId: string;
130
+ overrideDistrictId: string | null;
131
+ };
87
132
 
88
133
  declare class ElectedOfficesResource extends BaseResource {
89
134
  protected readonly resourceBasePath = "/elected-office";
90
135
  list: (options?: ListElectedOfficesOptions) => Promise<PaginatedList<ElectedOffice>>;
91
136
  get: (id: string) => Promise<ElectedOffice>;
92
137
  update: (id: string, input: UpdateElectedOfficeInput) => Promise<ElectedOffice>;
138
+ updateDistrict: (id: string, input: UpdateElectedOfficeDistrictInput) => Promise<SetElectedOfficeDistrictOutput>;
93
139
  }
94
140
 
95
141
  declare class ElectionsResource extends BaseResource {
@@ -98,74 +144,61 @@ declare class ElectionsResource extends BaseResource {
98
144
  listDistrictNames: (options: ListDistrictNamesOptions) => Promise<DistrictNameItem[]>;
99
145
  }
100
146
 
101
- declare enum P2VStatus {
102
- complete = "Complete",
103
- waiting = "Waiting",
104
- failed = "Failed",
105
- districtMatched = "DistrictMatched"
106
- }
107
- declare enum P2VSource {
108
- GpApi = "GpApi",
109
- ElectionApi = "ElectionApi"
110
- }
111
- type ViabilityScore = {
112
- level: string;
113
- isPartisan: boolean;
114
- isIncumbent: boolean;
115
- isUncontested: boolean;
116
- candidates: number;
117
- seats: number;
118
- candidatesPerSeat: number;
119
- score: number;
120
- probOfWin: number;
121
- };
122
- type PathToVictoryData = {
123
- p2vStatus?: P2VStatus;
124
- p2vAttempts?: number;
125
- p2vCompleteDate?: string;
126
- completedBy?: number;
127
- electionType?: string;
128
- electionLocation?: string;
129
- voterContactGoal?: number;
130
- winNumber?: number;
131
- p2vNotNeeded?: boolean;
132
- totalRegisteredVoters?: number;
133
- republicans?: number;
134
- democrats?: number;
135
- indies?: number;
136
- women?: number;
137
- men?: number;
138
- white?: number;
139
- asian?: number;
140
- africanAmerican?: number;
141
- hispanic?: number;
142
- averageTurnout?: number;
143
- projectedTurnout?: number;
144
- viability?: ViabilityScore;
145
- source?: P2VSource;
146
- districtId?: string;
147
- districtManuallySet?: boolean;
148
- officeContextFingerprint?: string;
149
- };
150
- type PathToVictory = {
147
+ type OrgDistrict = {
148
+ id: string;
149
+ l2Type: string;
150
+ l2Name: string;
151
+ };
152
+ type OrgPosition = {
153
+ id: string;
154
+ state: string;
155
+ brPositionId: string;
156
+ };
157
+ type Organization = {
158
+ slug: string;
159
+ name: string | null;
160
+ positionName: string | null;
161
+ position: OrgPosition | null;
162
+ district: OrgDistrict | null;
163
+ electedOfficeId: string | null;
164
+ campaignId: number | null;
165
+ };
166
+ type ListOrganizationsOptions = {
167
+ slug?: string;
168
+ email?: string;
169
+ };
170
+ type OrganizationOwnerSummary = {
151
171
  id: number;
152
- createdAt: string;
153
- updatedAt: string;
154
- campaignId: number;
155
- data: PathToVictoryData;
172
+ email: string | null;
173
+ firstName: string | null;
174
+ lastName: string | null;
175
+ phone: string | null;
156
176
  };
157
- type ListPathsToVictoryOptions = PaginationOptions & {
158
- userId?: number;
177
+ type OrganizationListItem = Organization & {
178
+ extra: {
179
+ positionName: string | null;
180
+ hasDistrictOverride: boolean;
181
+ owner: OrganizationOwnerSummary;
182
+ campaign: {
183
+ id: number;
184
+ slug: string;
185
+ details: unknown;
186
+ } | null;
187
+ };
159
188
  };
160
- type UpdatePathToVictoryInput = {
161
- data: PathToVictoryData;
189
+ type PatchOrganizationInput = {
190
+ ballotReadyPositionId?: string | null;
191
+ overrideDistrictId?: string | null;
192
+ customPositionName?: string | null;
162
193
  };
163
194
 
164
- declare class PathsToVictoryResource extends BaseResource {
165
- protected resourceBasePath: string;
166
- list: (options?: ListPathsToVictoryOptions) => Promise<PaginatedList<PathToVictory>>;
167
- get: (id: number) => Promise<PathToVictory>;
168
- update: (id: number, input: UpdatePathToVictoryInput) => Promise<PathToVictory>;
195
+ declare class OrganizationsResource extends BaseResource {
196
+ protected readonly resourceBasePath = "/organizations";
197
+ get: (slug: string) => Promise<Organization>;
198
+ list: (options?: ListOrganizationsOptions) => Promise<{
199
+ organizations: OrganizationListItem[];
200
+ }>;
201
+ patch: (slug: string, input: PatchOrganizationInput) => Promise<Organization>;
169
202
  }
170
203
 
171
204
  declare class UsersResource extends BaseResource {
@@ -182,12 +215,13 @@ type GoodPartyClientConfig = {
182
215
  gpApiRootUrl: string;
183
216
  };
184
217
  declare class GoodPartyClient {
218
+ readonly admin: AdminResource;
185
219
  readonly users: UsersResource;
186
220
  readonly campaigns: CampaignsResource;
187
221
  readonly ecanvasser: EcanvasserResource;
188
222
  readonly electedOffices: ElectedOfficesResource;
189
223
  readonly elections: ElectionsResource;
190
- readonly pathsToVictory: PathsToVictoryResource;
224
+ readonly organizations: OrganizationsResource;
191
225
  private clerkService;
192
226
  private constructor();
193
227
  static create: (config: GoodPartyClientConfig) => Promise<GoodPartyClient>;
@@ -210,4 +244,4 @@ declare const WhyBrowsing: EnumObject<readonly ["considering", "learning", "test
210
244
  type CampaignTier = CampaignTier$1;
211
245
  declare const CampaignTier: EnumObject<readonly ["WIN", "LOSE", "TOSSUP"]>;
212
246
 
213
- export { CampaignTier, type DistrictNameItem, type DistrictTypeItem, type ElectedOffice, GoodPartyClient, type GoodPartyClientConfig, type ListDistrictNamesOptions, type ListDistrictTypesOptions, type ListElectedOfficesOptions, type ListPathsToVictoryOptions, P2VSource, P2VStatus, type PathToVictory, type PathToVictoryData, SdkError, type UpdateDistrictInput, type UpdateElectedOfficeInput, type UpdatePathToVictoryInput, UserRole, type ViabilityScore, WhyBrowsing };
247
+ export { CampaignTier, type CampaignWithLiveContext, type CampaignWithPositionName, type DistrictNameItem, type DistrictTypeItem, type ElectedOffice, GoodPartyClient, type GoodPartyClientConfig, type ImpersonateUserInput, type ImpersonateUserOutput, type ListDistrictNamesOptions, type ListDistrictTypesOptions, type ListElectedOfficesOptions, type ListOrganizationsOptions, type OrgDistrict, type OrgPosition, type Organization, type OrganizationListItem, type OrganizationOwnerSummary, type PatchOrganizationInput, type RaceTargetMetrics, SdkError, type SetElectedOfficeDistrictOutput, type UpdateDistrictInput, type UpdateElectedOfficeDistrictInput, type UpdateElectedOfficeInput, UserRole, WhyBrowsing };
package/dist/index.js CHANGED
@@ -37,8 +37,6 @@ __export(index_exports, {
37
37
  GoodPartyClient: () => GoodPartyClient,
38
38
  ONBOARDING_STEP_VALUES: () => import_contracts2.ONBOARDING_STEP_VALUES,
39
39
  OnboardingStep: () => import_contracts2.OnboardingStep,
40
- P2VSource: () => P2VSource,
41
- P2VStatus: () => P2VStatus,
42
40
  SdkError: () => SdkError,
43
41
  USER_ROLE_VALUES: () => import_contracts2.USER_ROLE_VALUES,
44
42
  UserRole: () => UserRole,
@@ -99,9 +97,19 @@ var BaseResource = class {
99
97
  getRequest = (path, query) => this.httpClient.request(path, { method: "GET", query });
100
98
  postRequest = (path, body) => this.httpClient.request(path, { method: "POST", body });
101
99
  putRequest = (path, body) => this.httpClient.request(path, { method: "PUT", body });
100
+ patchRequest = (path, body) => this.httpClient.request(path, { method: "PATCH", body });
102
101
  deleteRequest = (path) => this.httpClient.request(path, { method: "DELETE" });
103
102
  };
104
103
 
104
+ // src/resources/AdminResource.ts
105
+ var AdminResource = class extends BaseResource {
106
+ resourceBasePath = "/admin";
107
+ impersonateUser = (targetUserId, actorClerkId) => this.postRequest(
108
+ `${this.resourceBasePath}/users/impersonate/${targetUserId}`,
109
+ { actorClerkId }
110
+ );
111
+ };
112
+
105
113
  // src/resources/CampaignsResource.ts
106
114
  var CampaignsResource = class extends BaseResource {
107
115
  resourceBasePath = "/campaigns";
@@ -135,6 +143,10 @@ var ElectedOfficesResource = class extends BaseResource {
135
143
  );
136
144
  get = (id) => this.getRequest(`${this.resourceBasePath}/${id}`);
137
145
  update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
146
+ updateDistrict = (id, input) => this.putRequest(
147
+ `${this.resourceBasePath}/${id}/district`,
148
+ input
149
+ );
138
150
  };
139
151
 
140
152
  // src/resources/ElectionsResource.ts
@@ -150,15 +162,18 @@ var ElectionsResource = class extends BaseResource {
150
162
  );
151
163
  };
152
164
 
153
- // src/resources/PathsToVictoryResource.ts
154
- var PathsToVictoryResource = class extends BaseResource {
155
- resourceBasePath = "/path-to-victory";
165
+ // src/resources/OrganizationsResource.ts
166
+ var OrganizationsResource = class extends BaseResource {
167
+ resourceBasePath = "/organizations";
168
+ get = (slug) => this.getRequest(`${this.resourceBasePath}/admin/${slug}`);
156
169
  list = (options) => this.getRequest(
157
- `${this.resourceBasePath}/list`,
170
+ `${this.resourceBasePath}/admin/list`,
158
171
  options
159
172
  );
160
- get = (id) => this.getRequest(`${this.resourceBasePath}/${id}`);
161
- update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
173
+ patch = (slug, input) => this.patchRequest(
174
+ `${this.resourceBasePath}/admin/${slug}`,
175
+ input
176
+ );
162
177
  };
163
178
 
164
179
  // src/resources/UsersResource.ts
@@ -263,22 +278,24 @@ var ClerkService = class {
263
278
 
264
279
  // src/GoodPartyClient.ts
265
280
  var GoodPartyClient = class _GoodPartyClient {
281
+ admin;
266
282
  users;
267
283
  campaigns;
268
284
  ecanvasser;
269
285
  electedOffices;
270
286
  elections;
271
- pathsToVictory;
287
+ organizations;
272
288
  clerkService;
273
289
  constructor(clerkService, gpApiRootUrl) {
274
290
  this.clerkService = clerkService;
275
291
  const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken);
292
+ this.admin = new AdminResource(httpClient);
276
293
  this.users = new UsersResource(httpClient);
277
294
  this.campaigns = new CampaignsResource(httpClient);
278
295
  this.ecanvasser = new EcanvasserResource(httpClient);
279
296
  this.electedOffices = new ElectedOfficesResource(httpClient);
280
297
  this.elections = new ElectionsResource(httpClient);
281
- this.pathsToVictory = new PathsToVictoryResource(httpClient);
298
+ this.organizations = new OrganizationsResource(httpClient);
282
299
  }
283
300
  static create = async (config) => {
284
301
  const { m2mSecret, gpApiRootUrl } = config;
@@ -300,20 +317,6 @@ var toEnumObject = (values) => Object.fromEntries(values.map((v) => [v, v]));
300
317
  var UserRole = toEnumObject(import_contracts.USER_ROLE_VALUES);
301
318
  var WhyBrowsing = toEnumObject(import_contracts.WHY_BROWSING_VALUES);
302
319
  var CampaignTier = toEnumObject(import_contracts.CAMPAIGN_TIER_VALUES);
303
-
304
- // src/types/pathToVictory.ts
305
- var P2VStatus = /* @__PURE__ */ ((P2VStatus2) => {
306
- P2VStatus2["complete"] = "Complete";
307
- P2VStatus2["waiting"] = "Waiting";
308
- P2VStatus2["failed"] = "Failed";
309
- P2VStatus2["districtMatched"] = "DistrictMatched";
310
- return P2VStatus2;
311
- })(P2VStatus || {});
312
- var P2VSource = /* @__PURE__ */ ((P2VSource2) => {
313
- P2VSource2["GpApi"] = "GpApi";
314
- P2VSource2["ElectionApi"] = "ElectionApi";
315
- return P2VSource2;
316
- })(P2VSource || {});
317
320
  // Annotate the CommonJS export names for ESM import in node:
318
321
  0 && (module.exports = {
319
322
  BALLOT_READY_POSITION_LEVEL_VALUES,
@@ -333,8 +336,6 @@ var P2VSource = /* @__PURE__ */ ((P2VSource2) => {
333
336
  GoodPartyClient,
334
337
  ONBOARDING_STEP_VALUES,
335
338
  OnboardingStep,
336
- P2VSource,
337
- P2VStatus,
338
339
  SdkError,
339
340
  USER_ROLE_VALUES,
340
341
  UserRole,
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/EcanvasserResource.ts","../src/resources/ElectedOfficesResource.ts","../src/resources/ElectionsResource.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 SetDistrictOutput,\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\nexport type {\n DistrictTypeItem,\n DistrictNameItem,\n ListDistrictTypesOptions,\n ListDistrictNamesOptions,\n UpdateDistrictInput,\n} from './types/district'\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 SetDistrictOutput,\n UpdateCampaignM2MInput,\n} from '@goodparty_org/contracts'\nimport type { UpdateDistrictInput } from '../types/district'\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 updateDistrict = (\n id: number,\n input: UpdateDistrictInput,\n ): Promise<SetDistrictOutput> =>\n this.putRequest<SetDistrictOutput>(\n `${this.resourceBasePath}/${id}/district`,\n input,\n )\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 {\n DistrictTypeItem,\n DistrictNameItem,\n ListDistrictTypesOptions,\n ListDistrictNamesOptions,\n} from '../types/district'\nimport { BaseResource } from './BaseResource'\n\nexport class ElectionsResource extends BaseResource {\n protected readonly resourceBasePath = '/elections'\n\n listDistrictTypes = (\n options: ListDistrictTypesOptions,\n ): Promise<DistrictTypeItem[]> =>\n this.getRequest<DistrictTypeItem[]>(\n `${this.resourceBasePath}/districts/types`,\n options,\n )\n\n listDistrictNames = (\n options: ListDistrictNamesOptions,\n ): Promise<DistrictNameItem[]> =>\n this.getRequest<DistrictNameItem[]>(\n `${this.resourceBasePath}/districts/names`,\n options,\n )\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 { ElectionsResource } from './resources/ElectionsResource'\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 elections: ElectionsResource\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.elections = new ElectionsResource(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,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,CAA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IAAI,WAAW,cAAc,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,YAAY,IAAI,kBAAkB,UAAU;AACjD,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;;;AXLA,IAAAA,oBAkBO;;;AY3DP,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/AdminResource.ts","../src/resources/CampaignsResource.ts","../src/resources/EcanvasserResource.ts","../src/resources/ElectedOfficesResource.ts","../src/resources/ElectionsResource.ts","../src/resources/OrganizationsResource.ts","../src/resources/UsersResource.ts","../src/vendor/clerk/clerk.service.ts","../src/GoodPartyClient.ts","../src/enums.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 SetDistrictOutput,\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 SetElectedOfficeDistrictOutput,\n UpdateElectedOfficeDistrictInput,\n UpdateElectedOfficeInput,\n} from './types/electedOffice'\n\nexport type {\n DistrictTypeItem,\n DistrictNameItem,\n ListDistrictTypesOptions,\n ListDistrictNamesOptions,\n UpdateDistrictInput,\n} from './types/district'\n\nexport type {\n CampaignWithLiveContext,\n CampaignWithPositionName,\n RaceTargetMetrics,\n} from './types/campaign'\n\nexport type { ImpersonateUserInput, ImpersonateUserOutput } from './types/admin'\n\nexport type {\n Organization,\n OrgDistrict,\n OrgPosition,\n OrganizationListItem,\n OrganizationOwnerSummary,\n ListOrganizationsOptions,\n PatchOrganizationInput,\n} from './types/organization'\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 patchRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'PATCH', body })\n\n protected deleteRequest = <T>(path: string): Promise<T> =>\n this.httpClient.request<T>(path, { method: 'DELETE' })\n}\n","import type { ImpersonateUserOutput } from '../types/admin'\nimport { BaseResource } from './BaseResource'\n\nexport class AdminResource extends BaseResource {\n protected readonly resourceBasePath = '/admin'\n\n impersonateUser = (\n targetUserId: number,\n actorClerkId: string,\n ): Promise<ImpersonateUserOutput> =>\n this.postRequest<ImpersonateUserOutput>(\n `${this.resourceBasePath}/users/impersonate/${targetUserId}`,\n { actorClerkId },\n )\n}\n","import type {\n ListCampaignsPagination,\n PaginatedList,\n ReadCampaignOutput,\n SetDistrictOutput,\n UpdateCampaignM2MInput,\n} from '@goodparty_org/contracts'\nimport type {\n CampaignWithLiveContext,\n CampaignWithPositionName,\n} from '../types/campaign'\nimport type { UpdateDistrictInput } from '../types/district'\nimport { BaseResource } from './BaseResource'\n\nexport class CampaignsResource extends BaseResource {\n protected readonly resourceBasePath = '/campaigns'\n\n get = (id: number): Promise<CampaignWithLiveContext> =>\n this.getRequest<CampaignWithLiveContext>(`${this.resourceBasePath}/${id}`)\n\n list = (\n options?: ListCampaignsPagination,\n ): Promise<PaginatedList<CampaignWithPositionName>> =>\n this.getRequest<PaginatedList<CampaignWithPositionName>>(\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 updateDistrict = (\n id: number,\n input: UpdateDistrictInput,\n ): Promise<SetDistrictOutput> =>\n this.putRequest<SetDistrictOutput>(\n `${this.resourceBasePath}/${id}/district`,\n input,\n )\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 SetElectedOfficeDistrictOutput,\n UpdateElectedOfficeDistrictInput,\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 updateDistrict = (\n id: string,\n input: UpdateElectedOfficeDistrictInput,\n ): Promise<SetElectedOfficeDistrictOutput> =>\n this.putRequest<SetElectedOfficeDistrictOutput>(\n `${this.resourceBasePath}/${id}/district`,\n input,\n )\n}\n","import type {\n DistrictTypeItem,\n DistrictNameItem,\n ListDistrictTypesOptions,\n ListDistrictNamesOptions,\n} from '../types/district'\nimport { BaseResource } from './BaseResource'\n\nexport class ElectionsResource extends BaseResource {\n protected readonly resourceBasePath = '/elections'\n\n listDistrictTypes = (\n options: ListDistrictTypesOptions,\n ): Promise<DistrictTypeItem[]> =>\n this.getRequest<DistrictTypeItem[]>(\n `${this.resourceBasePath}/districts/types`,\n options,\n )\n\n listDistrictNames = (\n options: ListDistrictNamesOptions,\n ): Promise<DistrictNameItem[]> =>\n this.getRequest<DistrictNameItem[]>(\n `${this.resourceBasePath}/districts/names`,\n options,\n )\n}\n","import type {\n ListOrganizationsOptions,\n Organization,\n OrganizationListItem,\n PatchOrganizationInput,\n} from '../types/organization'\nimport { BaseResource } from './BaseResource'\n\nexport class OrganizationsResource extends BaseResource {\n protected readonly resourceBasePath = '/organizations'\n\n get = (slug: string): Promise<Organization> =>\n this.getRequest<Organization>(`${this.resourceBasePath}/admin/${slug}`)\n\n list = (\n options?: ListOrganizationsOptions,\n ): Promise<{ organizations: OrganizationListItem[] }> =>\n this.getRequest<{ organizations: OrganizationListItem[] }>(\n `${this.resourceBasePath}/admin/list`,\n options,\n )\n\n patch = (\n slug: string,\n input: PatchOrganizationInput,\n ): Promise<Organization> =>\n this.patchRequest<Organization>(\n `${this.resourceBasePath}/admin/${slug}`,\n input,\n )\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 { AdminResource } from './resources/AdminResource'\nimport { CampaignsResource } from './resources/CampaignsResource'\nimport { EcanvasserResource } from './resources/EcanvasserResource'\nimport { ElectedOfficesResource } from './resources/ElectedOfficesResource'\nimport { ElectionsResource } from './resources/ElectionsResource'\nimport { OrganizationsResource } from './resources/OrganizationsResource'\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 admin: AdminResource\n readonly users: UsersResource\n readonly campaigns: CampaignsResource\n readonly ecanvasser: EcanvasserResource\n readonly electedOffices: ElectedOfficesResource\n readonly elections: ElectionsResource\n readonly organizations: OrganizationsResource\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.admin = new AdminResource(httpClient)\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.elections = new ElectionsResource(httpClient)\n this.organizations = new OrganizationsResource(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"],"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;;;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,aAA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AAe,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;","names":["import_contracts"]}
package/dist/index.mjs CHANGED
@@ -50,9 +50,19 @@ var BaseResource = class {
50
50
  getRequest = (path, query) => this.httpClient.request(path, { method: "GET", query });
51
51
  postRequest = (path, body) => this.httpClient.request(path, { method: "POST", body });
52
52
  putRequest = (path, body) => this.httpClient.request(path, { method: "PUT", body });
53
+ patchRequest = (path, body) => this.httpClient.request(path, { method: "PATCH", body });
53
54
  deleteRequest = (path) => this.httpClient.request(path, { method: "DELETE" });
54
55
  };
55
56
 
57
+ // src/resources/AdminResource.ts
58
+ var AdminResource = class extends BaseResource {
59
+ resourceBasePath = "/admin";
60
+ impersonateUser = (targetUserId, actorClerkId) => this.postRequest(
61
+ `${this.resourceBasePath}/users/impersonate/${targetUserId}`,
62
+ { actorClerkId }
63
+ );
64
+ };
65
+
56
66
  // src/resources/CampaignsResource.ts
57
67
  var CampaignsResource = class extends BaseResource {
58
68
  resourceBasePath = "/campaigns";
@@ -86,6 +96,10 @@ var ElectedOfficesResource = class extends BaseResource {
86
96
  );
87
97
  get = (id) => this.getRequest(`${this.resourceBasePath}/${id}`);
88
98
  update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
99
+ updateDistrict = (id, input) => this.putRequest(
100
+ `${this.resourceBasePath}/${id}/district`,
101
+ input
102
+ );
89
103
  };
90
104
 
91
105
  // src/resources/ElectionsResource.ts
@@ -101,15 +115,18 @@ var ElectionsResource = class extends BaseResource {
101
115
  );
102
116
  };
103
117
 
104
- // src/resources/PathsToVictoryResource.ts
105
- var PathsToVictoryResource = class extends BaseResource {
106
- resourceBasePath = "/path-to-victory";
118
+ // src/resources/OrganizationsResource.ts
119
+ var OrganizationsResource = class extends BaseResource {
120
+ resourceBasePath = "/organizations";
121
+ get = (slug) => this.getRequest(`${this.resourceBasePath}/admin/${slug}`);
107
122
  list = (options) => this.getRequest(
108
- `${this.resourceBasePath}/list`,
123
+ `${this.resourceBasePath}/admin/list`,
109
124
  options
110
125
  );
111
- get = (id) => this.getRequest(`${this.resourceBasePath}/${id}`);
112
- update = (id, input) => this.putRequest(`${this.resourceBasePath}/${id}`, input);
126
+ patch = (slug, input) => this.patchRequest(
127
+ `${this.resourceBasePath}/admin/${slug}`,
128
+ input
129
+ );
113
130
  };
114
131
 
115
132
  // src/resources/UsersResource.ts
@@ -214,22 +231,24 @@ var ClerkService = class {
214
231
 
215
232
  // src/GoodPartyClient.ts
216
233
  var GoodPartyClient = class _GoodPartyClient {
234
+ admin;
217
235
  users;
218
236
  campaigns;
219
237
  ecanvasser;
220
238
  electedOffices;
221
239
  elections;
222
- pathsToVictory;
240
+ organizations;
223
241
  clerkService;
224
242
  constructor(clerkService, gpApiRootUrl) {
225
243
  this.clerkService = clerkService;
226
244
  const httpClient = new HttpClient(gpApiRootUrl, clerkService.getToken);
245
+ this.admin = new AdminResource(httpClient);
227
246
  this.users = new UsersResource(httpClient);
228
247
  this.campaigns = new CampaignsResource(httpClient);
229
248
  this.ecanvasser = new EcanvasserResource(httpClient);
230
249
  this.electedOffices = new ElectedOfficesResource(httpClient);
231
250
  this.elections = new ElectionsResource(httpClient);
232
- this.pathsToVictory = new PathsToVictoryResource(httpClient);
251
+ this.organizations = new OrganizationsResource(httpClient);
233
252
  }
234
253
  static create = async (config) => {
235
254
  const { m2mSecret, gpApiRootUrl } = config;
@@ -273,20 +292,6 @@ var toEnumObject = (values) => Object.fromEntries(values.map((v) => [v, v]));
273
292
  var UserRole = toEnumObject(USER_ROLE_VALUES);
274
293
  var WhyBrowsing = toEnumObject(WHY_BROWSING_VALUES);
275
294
  var CampaignTier = toEnumObject(CAMPAIGN_TIER_VALUES);
276
-
277
- // src/types/pathToVictory.ts
278
- var P2VStatus = /* @__PURE__ */ ((P2VStatus2) => {
279
- P2VStatus2["complete"] = "Complete";
280
- P2VStatus2["waiting"] = "Waiting";
281
- P2VStatus2["failed"] = "Failed";
282
- P2VStatus2["districtMatched"] = "DistrictMatched";
283
- return P2VStatus2;
284
- })(P2VStatus || {});
285
- var P2VSource = /* @__PURE__ */ ((P2VSource2) => {
286
- P2VSource2["GpApi"] = "GpApi";
287
- P2VSource2["ElectionApi"] = "ElectionApi";
288
- return P2VSource2;
289
- })(P2VSource || {});
290
295
  export {
291
296
  BALLOT_READY_POSITION_LEVEL_VALUES,
292
297
  BallotReadyPositionLevel,
@@ -305,8 +310,6 @@ export {
305
310
  GoodPartyClient,
306
311
  ONBOARDING_STEP_VALUES,
307
312
  OnboardingStep,
308
- P2VSource,
309
- P2VStatus,
310
313
  SdkError,
311
314
  USER_ROLE_VALUES2 as USER_ROLE_VALUES,
312
315
  UserRole,
@@ -1 +1 @@
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/ElectionsResource.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 SetDistrictOutput,\n UpdateCampaignM2MInput,\n} from '@goodparty_org/contracts'\nimport type { UpdateDistrictInput } from '../types/district'\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 updateDistrict = (\n id: number,\n input: UpdateDistrictInput,\n ): Promise<SetDistrictOutput> =>\n this.putRequest<SetDistrictOutput>(\n `${this.resourceBasePath}/${id}/district`,\n input,\n )\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 {\n DistrictTypeItem,\n DistrictNameItem,\n ListDistrictTypesOptions,\n ListDistrictNamesOptions,\n} from '../types/district'\nimport { BaseResource } from './BaseResource'\n\nexport class ElectionsResource extends BaseResource {\n protected readonly resourceBasePath = '/elections'\n\n listDistrictTypes = (\n options: ListDistrictTypesOptions,\n ): Promise<DistrictTypeItem[]> =>\n this.getRequest<DistrictTypeItem[]>(\n `${this.resourceBasePath}/districts/types`,\n options,\n )\n\n listDistrictNames = (\n options: ListDistrictNamesOptions,\n ): Promise<DistrictNameItem[]> =>\n this.getRequest<DistrictNameItem[]>(\n `${this.resourceBasePath}/districts/names`,\n options,\n )\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 { ElectionsResource } from './resources/ElectionsResource'\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 elections: ElectionsResource\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.elections = new ElectionsResource(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 SetDistrictOutput,\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\nexport type {\n DistrictTypeItem,\n DistrictNameItem,\n ListDistrictTypesOptions,\n ListDistrictNamesOptions,\n UpdateDistrictInput,\n} from './types/district'\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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AAI,iBAAgB,cAAc,YAAY;AAAA,EACvD;AAAA,EAEA,UAAU,MAAY;AACpB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;;;ACLA;AAAA,EACE,oBAAAA;AAAA,EACA,uBAAAC;AAAA,EACA,wBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;AC3DP;AAAA,EACE;AAAA,EAEA;AAAA,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"]}
1
+ {"version":3,"sources":["../src/http/HttpClient.ts","../src/types/result.ts","../src/resources/BaseResource.ts","../src/resources/AdminResource.ts","../src/resources/CampaignsResource.ts","../src/resources/EcanvasserResource.ts","../src/resources/ElectedOfficesResource.ts","../src/resources/ElectionsResource.ts","../src/resources/OrganizationsResource.ts","../src/resources/UsersResource.ts","../src/vendor/clerk/clerk.service.ts","../src/GoodPartyClient.ts","../src/index.ts","../src/enums.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 patchRequest = <T>(\n path: string,\n body: OfetchRequestBody,\n ): Promise<T> => this.httpClient.request<T>(path, { method: 'PATCH', body })\n\n protected deleteRequest = <T>(path: string): Promise<T> =>\n this.httpClient.request<T>(path, { method: 'DELETE' })\n}\n","import type { ImpersonateUserOutput } from '../types/admin'\nimport { BaseResource } from './BaseResource'\n\nexport class AdminResource extends BaseResource {\n protected readonly resourceBasePath = '/admin'\n\n impersonateUser = (\n targetUserId: number,\n actorClerkId: string,\n ): Promise<ImpersonateUserOutput> =>\n this.postRequest<ImpersonateUserOutput>(\n `${this.resourceBasePath}/users/impersonate/${targetUserId}`,\n { actorClerkId },\n )\n}\n","import type {\n ListCampaignsPagination,\n PaginatedList,\n ReadCampaignOutput,\n SetDistrictOutput,\n UpdateCampaignM2MInput,\n} from '@goodparty_org/contracts'\nimport type {\n CampaignWithLiveContext,\n CampaignWithPositionName,\n} from '../types/campaign'\nimport type { UpdateDistrictInput } from '../types/district'\nimport { BaseResource } from './BaseResource'\n\nexport class CampaignsResource extends BaseResource {\n protected readonly resourceBasePath = '/campaigns'\n\n get = (id: number): Promise<CampaignWithLiveContext> =>\n this.getRequest<CampaignWithLiveContext>(`${this.resourceBasePath}/${id}`)\n\n list = (\n options?: ListCampaignsPagination,\n ): Promise<PaginatedList<CampaignWithPositionName>> =>\n this.getRequest<PaginatedList<CampaignWithPositionName>>(\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 updateDistrict = (\n id: number,\n input: UpdateDistrictInput,\n ): Promise<SetDistrictOutput> =>\n this.putRequest<SetDistrictOutput>(\n `${this.resourceBasePath}/${id}/district`,\n input,\n )\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 SetElectedOfficeDistrictOutput,\n UpdateElectedOfficeDistrictInput,\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 updateDistrict = (\n id: string,\n input: UpdateElectedOfficeDistrictInput,\n ): Promise<SetElectedOfficeDistrictOutput> =>\n this.putRequest<SetElectedOfficeDistrictOutput>(\n `${this.resourceBasePath}/${id}/district`,\n input,\n )\n}\n","import type {\n DistrictTypeItem,\n DistrictNameItem,\n ListDistrictTypesOptions,\n ListDistrictNamesOptions,\n} from '../types/district'\nimport { BaseResource } from './BaseResource'\n\nexport class ElectionsResource extends BaseResource {\n protected readonly resourceBasePath = '/elections'\n\n listDistrictTypes = (\n options: ListDistrictTypesOptions,\n ): Promise<DistrictTypeItem[]> =>\n this.getRequest<DistrictTypeItem[]>(\n `${this.resourceBasePath}/districts/types`,\n options,\n )\n\n listDistrictNames = (\n options: ListDistrictNamesOptions,\n ): Promise<DistrictNameItem[]> =>\n this.getRequest<DistrictNameItem[]>(\n `${this.resourceBasePath}/districts/names`,\n options,\n )\n}\n","import type {\n ListOrganizationsOptions,\n Organization,\n OrganizationListItem,\n PatchOrganizationInput,\n} from '../types/organization'\nimport { BaseResource } from './BaseResource'\n\nexport class OrganizationsResource extends BaseResource {\n protected readonly resourceBasePath = '/organizations'\n\n get = (slug: string): Promise<Organization> =>\n this.getRequest<Organization>(`${this.resourceBasePath}/admin/${slug}`)\n\n list = (\n options?: ListOrganizationsOptions,\n ): Promise<{ organizations: OrganizationListItem[] }> =>\n this.getRequest<{ organizations: OrganizationListItem[] }>(\n `${this.resourceBasePath}/admin/list`,\n options,\n )\n\n patch = (\n slug: string,\n input: PatchOrganizationInput,\n ): Promise<Organization> =>\n this.patchRequest<Organization>(\n `${this.resourceBasePath}/admin/${slug}`,\n input,\n )\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 { AdminResource } from './resources/AdminResource'\nimport { CampaignsResource } from './resources/CampaignsResource'\nimport { EcanvasserResource } from './resources/EcanvasserResource'\nimport { ElectedOfficesResource } from './resources/ElectedOfficesResource'\nimport { ElectionsResource } from './resources/ElectionsResource'\nimport { OrganizationsResource } from './resources/OrganizationsResource'\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 admin: AdminResource\n readonly users: UsersResource\n readonly campaigns: CampaignsResource\n readonly ecanvasser: EcanvasserResource\n readonly electedOffices: ElectedOfficesResource\n readonly elections: ElectionsResource\n readonly organizations: OrganizationsResource\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.admin = new AdminResource(httpClient)\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.elections = new ElectionsResource(httpClient)\n this.organizations = new OrganizationsResource(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 SetDistrictOutput,\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 SetElectedOfficeDistrictOutput,\n UpdateElectedOfficeDistrictInput,\n UpdateElectedOfficeInput,\n} from './types/electedOffice'\n\nexport type {\n DistrictTypeItem,\n DistrictNameItem,\n ListDistrictTypesOptions,\n ListDistrictNamesOptions,\n UpdateDistrictInput,\n} from './types/district'\n\nexport type {\n CampaignWithLiveContext,\n CampaignWithPositionName,\n RaceTargetMetrics,\n} from './types/campaign'\n\nexport type { ImpersonateUserInput, ImpersonateUserOutput } from './types/admin'\n\nexport type {\n Organization,\n OrgDistrict,\n OrgPosition,\n OrganizationListItem,\n OrganizationOwnerSummary,\n ListOrganizationsOptions,\n PatchOrganizationInput,\n} from './types/organization'\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"],"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,Q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GAAG,CAAC,CAAC,CAAC;AAGvC,IAAM,WAAW,aAAa,gBAAgB;AAG9C,IAAM,cAAc,aAAa,mBAAmB;AAGpD,IAAM,eAAe,aAAa,oBAAoB;","names":["USER_ROLE_VALUES","WHY_BROWSING_VALUES","CAMPAIGN_TIER_VALUES"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodparty_org/sdk",
3
- "version": "1.13.0",
3
+ "version": "2.0.0",
4
4
  "description": "TypeScript SDK for interacting with the GoodParty API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",