@axcode/axcloud-sdk 0.4.0-dev.bf5c2c0 → 0.4.0-dev.dc40cc8
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 +27 -1
- package/dist/barnsport.d.mts +5 -4
- package/dist/barnsport.d.ts +5 -4
- package/dist/index.d.mts +63 -10
- package/dist/index.d.ts +63 -10
- package/dist/index.js +42 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -10
- package/dist/index.mjs.map +1 -1
- package/dist/public.d.mts +4 -3
- package/dist/public.d.ts +4 -3
- package/dist/{useBarnsport-DHyNF9GM.d.mts → useBarnsport-3NwAFn3h.d.mts} +2 -1
- package/dist/{useBarnsport-DHyNF9GM.d.ts → useBarnsport-3NwAFn3h.d.ts} +2 -1
- package/dist/{useContent-CGI1l3Gs.d.ts → useContent-BULNVLEx.d.ts} +2 -1
- package/dist/{useContent-DLoyqAWH.d.mts → useContent-qNaQd8Xi.d.mts} +2 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -441,6 +441,32 @@ function Dashboard() {
|
|
|
441
441
|
}
|
|
442
442
|
```
|
|
443
443
|
|
|
444
|
+
### 8. Membership applications with a section choice
|
|
445
|
+
|
|
446
|
+
```tsx
|
|
447
|
+
import { createFormHelper } from '@axcode/axcloud-sdk';
|
|
448
|
+
|
|
449
|
+
const forms = createFormHelper({
|
|
450
|
+
apiUrl: 'https://api.axcloud.app/forms',
|
|
451
|
+
apiKey: import.meta.env.VITE_AXCLOUD_FORMS_API_KEY, // forms:submit only
|
|
452
|
+
site: 'example.org',
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// Sections the organization ticked as selectable, e.g. [{ id: 'section_x', name: 'SAS' }]
|
|
456
|
+
const sections = await forms.getMembershipSections();
|
|
457
|
+
|
|
458
|
+
// Either the chosen section…
|
|
459
|
+
await forms.submitMembership(email, { firstName, lastName, sectionId: sections[0].id });
|
|
460
|
+
// …or a company without a section of its own.
|
|
461
|
+
await forms.submitMembership(email, { firstName, lastName, company: 'Example Air' });
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
The API refuses a `sectionId` that is not in the list. The approval in the console invites
|
|
465
|
+
the applicant into the chosen section. `getMembershipSections` throws when the API refuses
|
|
466
|
+
(for example when the membership form is not enabled), so a site can fall back to a free-text
|
|
467
|
+
company field. The call is checked with the forms key like a submission but does not count toward
|
|
468
|
+
the key's rate limit, and browsers may keep the answer for five minutes.
|
|
469
|
+
|
|
444
470
|
## API Reference
|
|
445
471
|
|
|
446
472
|
### Provider
|
|
@@ -617,7 +643,7 @@ The SDK uses two types of credentials:
|
|
|
617
643
|
| Public content | API key (x-api-key header) | `/content/public/{orgId}/news` |
|
|
618
644
|
| Member content | JWT Bearer token | `/content/members/{orgId}/news` |
|
|
619
645
|
| User data | JWT Bearer token | `/api/users/me` |
|
|
620
|
-
| Admin | JWT Bearer token + role | `/
|
|
646
|
+
| Admin | JWT Bearer token + role | `/forms/admin/submissions` |
|
|
621
647
|
|
|
622
648
|
## Error Handling
|
|
623
649
|
|
package/dist/barnsport.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { AxCloudClient } from './index.mjs';
|
|
2
|
+
import { B as BarnsportListResponse, a as BarnsportMunicipality, b as BarnsportSport, c as BarnsportActivitiesFilter, d as BarnsportActivityListItem, e as BarnsportActivityResponse, f as BarnsportSitemapResponse, g as BarnsportProvidersFilter, h as BarnsportCollectionResponse, i as BarnsportProvider, j as BarnsportItemResponse, k as BarnsportProviderProfile, l as BarnsportActivityOffersFilter, m as BarnsportActivityOffer, n as BarnsportInterestSubmissionRequest, o as BarnsportInterestSubmissionResponse, p as BarnsportFeedbackRequest, q as BarnsportFeedbackResponse, r as BarnsportReviewSubmissionRequest, s as BarnsportReviewSubmissionResponse, t as BarnsportEventRequest, u as BarnsportEventResponse, v as BarnsportClubRemovalRequest, w as BarnsportClubRemovalResponse, x as BarnsportProviderUpdateRequest, y as BarnsportProviderUpdateResponse } from './useBarnsport-3NwAFn3h.mjs';
|
|
3
|
+
export { z as BarnsportActivity, A as BarnsportActivityEnvironment, C as BarnsportActivityLocation, D as BarnsportActivitySchedule, E as BarnsportCourseCandidate, F as BarnsportEventType, G as BarnsportInquiryDelivery, H as BarnsportInquiryResponse, I as BarnsportInquirySubmissionRequest, J as BarnsportMunicipalitySummary, K as BarnsportProviderSummary, L as BarnsportRegistrationMethod, M as BarnsportReview, N as BarnsportReviewsSummary, O as BarnsportSitemapUrl, P as BarnsportSourceConfidence, Q as BarnsportSportArticle, R as BarnsportSportArticleBlock, S as BarnsportSportArticleImage, T as BarnsportSportArticleRichTextMark, U as BarnsportSportArticleRichTextNode, V as BarnsportSportSummary, W as BarnsportStats, X as BarnsportVerificationStatus, Y as BarnsportYouthStatus, Z as useBarnsportActivities, _ as useBarnsportActivity, $ as useBarnsportActivityOffers, a0 as useBarnsportMunicipalities, a1 as useBarnsportProvider, a2 as useBarnsportProviderSearch, a3 as useBarnsportSitemap, a4 as useBarnsportSport, a5 as useBarnsportSports, a6 as useSubmitBarnsportFeedback, a7 as useSubmitBarnsportInterest, a8 as useSubmitBarnsportReview, a9 as useTrackBarnsportEvent } from './useBarnsport-3NwAFn3h.mjs';
|
|
4
4
|
import '@tanstack/react-query';
|
|
5
5
|
|
|
6
6
|
declare class BarnsportClient {
|
|
@@ -36,4 +36,5 @@ interface PublicBarnsportClientConfig {
|
|
|
36
36
|
/** Create a browser-safe Barnsport client without importing the authenticated SDK entrypoint. */
|
|
37
37
|
declare function createPublicBarnsportClient({ apiUrl, apiKey, orgId, timeout, }: PublicBarnsportClientConfig): BarnsportClient;
|
|
38
38
|
|
|
39
|
-
export { BarnsportActivitiesFilter, BarnsportActivityListItem, BarnsportActivityOffer, BarnsportActivityOffersFilter, BarnsportActivityResponse, BarnsportClient, BarnsportClubRemovalRequest, BarnsportClubRemovalResponse, BarnsportCollectionResponse, BarnsportEventRequest, BarnsportEventResponse, BarnsportFeedbackRequest, BarnsportFeedbackResponse, BarnsportInterestSubmissionRequest, BarnsportInterestSubmissionResponse, BarnsportItemResponse, BarnsportListResponse, BarnsportMunicipality, BarnsportProvider, BarnsportProviderProfile, BarnsportProviderUpdateRequest, BarnsportProviderUpdateResponse, BarnsportProvidersFilter, BarnsportReviewSubmissionRequest, BarnsportReviewSubmissionResponse, BarnsportSitemapResponse, BarnsportSport,
|
|
39
|
+
export { BarnsportActivitiesFilter, BarnsportActivityListItem, BarnsportActivityOffer, BarnsportActivityOffersFilter, BarnsportActivityResponse, BarnsportClient, BarnsportClubRemovalRequest, BarnsportClubRemovalResponse, BarnsportCollectionResponse, BarnsportEventRequest, BarnsportEventResponse, BarnsportFeedbackRequest, BarnsportFeedbackResponse, BarnsportInterestSubmissionRequest, BarnsportInterestSubmissionResponse, BarnsportItemResponse, BarnsportListResponse, BarnsportMunicipality, BarnsportProvider, BarnsportProviderProfile, BarnsportProviderUpdateRequest, BarnsportProviderUpdateResponse, BarnsportProvidersFilter, BarnsportReviewSubmissionRequest, BarnsportReviewSubmissionResponse, BarnsportSitemapResponse, BarnsportSport, createBarnsportClient, createPublicBarnsportClient };
|
|
40
|
+
export type { PublicBarnsportClientConfig };
|
package/dist/barnsport.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { AxCloudClient } from './index.js';
|
|
2
|
+
import { B as BarnsportListResponse, a as BarnsportMunicipality, b as BarnsportSport, c as BarnsportActivitiesFilter, d as BarnsportActivityListItem, e as BarnsportActivityResponse, f as BarnsportSitemapResponse, g as BarnsportProvidersFilter, h as BarnsportCollectionResponse, i as BarnsportProvider, j as BarnsportItemResponse, k as BarnsportProviderProfile, l as BarnsportActivityOffersFilter, m as BarnsportActivityOffer, n as BarnsportInterestSubmissionRequest, o as BarnsportInterestSubmissionResponse, p as BarnsportFeedbackRequest, q as BarnsportFeedbackResponse, r as BarnsportReviewSubmissionRequest, s as BarnsportReviewSubmissionResponse, t as BarnsportEventRequest, u as BarnsportEventResponse, v as BarnsportClubRemovalRequest, w as BarnsportClubRemovalResponse, x as BarnsportProviderUpdateRequest, y as BarnsportProviderUpdateResponse } from './useBarnsport-3NwAFn3h.js';
|
|
3
|
+
export { z as BarnsportActivity, A as BarnsportActivityEnvironment, C as BarnsportActivityLocation, D as BarnsportActivitySchedule, E as BarnsportCourseCandidate, F as BarnsportEventType, G as BarnsportInquiryDelivery, H as BarnsportInquiryResponse, I as BarnsportInquirySubmissionRequest, J as BarnsportMunicipalitySummary, K as BarnsportProviderSummary, L as BarnsportRegistrationMethod, M as BarnsportReview, N as BarnsportReviewsSummary, O as BarnsportSitemapUrl, P as BarnsportSourceConfidence, Q as BarnsportSportArticle, R as BarnsportSportArticleBlock, S as BarnsportSportArticleImage, T as BarnsportSportArticleRichTextMark, U as BarnsportSportArticleRichTextNode, V as BarnsportSportSummary, W as BarnsportStats, X as BarnsportVerificationStatus, Y as BarnsportYouthStatus, Z as useBarnsportActivities, _ as useBarnsportActivity, $ as useBarnsportActivityOffers, a0 as useBarnsportMunicipalities, a1 as useBarnsportProvider, a2 as useBarnsportProviderSearch, a3 as useBarnsportSitemap, a4 as useBarnsportSport, a5 as useBarnsportSports, a6 as useSubmitBarnsportFeedback, a7 as useSubmitBarnsportInterest, a8 as useSubmitBarnsportReview, a9 as useTrackBarnsportEvent } from './useBarnsport-3NwAFn3h.js';
|
|
4
4
|
import '@tanstack/react-query';
|
|
5
5
|
|
|
6
6
|
declare class BarnsportClient {
|
|
@@ -36,4 +36,5 @@ interface PublicBarnsportClientConfig {
|
|
|
36
36
|
/** Create a browser-safe Barnsport client without importing the authenticated SDK entrypoint. */
|
|
37
37
|
declare function createPublicBarnsportClient({ apiUrl, apiKey, orgId, timeout, }: PublicBarnsportClientConfig): BarnsportClient;
|
|
38
38
|
|
|
39
|
-
export { BarnsportActivitiesFilter, BarnsportActivityListItem, BarnsportActivityOffer, BarnsportActivityOffersFilter, BarnsportActivityResponse, BarnsportClient, BarnsportClubRemovalRequest, BarnsportClubRemovalResponse, BarnsportCollectionResponse, BarnsportEventRequest, BarnsportEventResponse, BarnsportFeedbackRequest, BarnsportFeedbackResponse, BarnsportInterestSubmissionRequest, BarnsportInterestSubmissionResponse, BarnsportItemResponse, BarnsportListResponse, BarnsportMunicipality, BarnsportProvider, BarnsportProviderProfile, BarnsportProviderUpdateRequest, BarnsportProviderUpdateResponse, BarnsportProvidersFilter, BarnsportReviewSubmissionRequest, BarnsportReviewSubmissionResponse, BarnsportSitemapResponse, BarnsportSport,
|
|
39
|
+
export { BarnsportActivitiesFilter, BarnsportActivityListItem, BarnsportActivityOffer, BarnsportActivityOffersFilter, BarnsportActivityResponse, BarnsportClient, BarnsportClubRemovalRequest, BarnsportClubRemovalResponse, BarnsportCollectionResponse, BarnsportEventRequest, BarnsportEventResponse, BarnsportFeedbackRequest, BarnsportFeedbackResponse, BarnsportInterestSubmissionRequest, BarnsportInterestSubmissionResponse, BarnsportItemResponse, BarnsportListResponse, BarnsportMunicipality, BarnsportProvider, BarnsportProviderProfile, BarnsportProviderUpdateRequest, BarnsportProviderUpdateResponse, BarnsportProvidersFilter, BarnsportReviewSubmissionRequest, BarnsportReviewSubmissionResponse, BarnsportSitemapResponse, BarnsportSport, createBarnsportClient, createPublicBarnsportClient };
|
|
40
|
+
export type { PublicBarnsportClientConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { A as AxCloudClient, c as createClient, g as getClient } from './client-FOpKwe3e.mjs';
|
|
2
|
-
import { A as AxCloudAnalyticsOptions, U as User$1, a as UserRole, O as Organization, b as AxCloudModule, C as ContentQueryOptions, N as NewsItem, c as ContentListResponse, S as Section, d as SignedMediaUrl, e as OrganizationBranding, M as MediaItem, f as MediaListResponse, g as SignedDocumentUrl, D as DocumentQueryOptions, h as DocumentItem, i as DocumentListResponse, j as DocumentFolder, k as DocumentFolderListResponse } from './useContent-
|
|
3
|
-
export { l as AnalyticsEventData, m as AnalyticsEventValue, n as AnalyticsPublicConfig, o as AnalyticsRuntime, p as AnalyticsRuntimeConfig, q as AxCloudConfig, B as BaseRole, r as ContentCollectionType, s as ContentDetailType, t as ContentItem, u as ContentSlotImage, v as ContentSlotMap, w as ContentSlotReader, x as ContentSlotValue, y as CustomRole, z as DocumentAudience, E as DocumentSourceProvider, F as DocumentStatus, G as Membership, H as OrganizationSettings, P as Page, I as PageContentState, J as PaginatedResponse, K as SectionPermissions, L as SystemRole, Q as createContentSlotReader, R as fetchAnalyticsPublicConfig, T as getContentSlotMap, V as isAllowedAnalyticsEvent, W as isLocalAnalyticsHostname, X as sanitizeAnalyticsEventData, Y as sanitizeAnalyticsPath, Z as useAnalytics, _ as useAnalyticsRuntime, $ as useAxCloudContext, a0 as useContent, a1 as useContentItem, a2 as usePageContent, a3 as userHasAllPermissions, a4 as userHasAnyPermission, a5 as userHasPermission } from './useContent-
|
|
4
|
-
export {
|
|
2
|
+
import { A as AxCloudAnalyticsOptions, U as User$1, a as UserRole, O as Organization, b as AxCloudModule, C as ContentQueryOptions, N as NewsItem, c as ContentListResponse, S as Section, d as SignedMediaUrl, e as OrganizationBranding, M as MediaItem, f as MediaListResponse, g as SignedDocumentUrl, D as DocumentQueryOptions, h as DocumentItem, i as DocumentListResponse, j as DocumentFolder, k as DocumentFolderListResponse } from './useContent-qNaQd8Xi.mjs';
|
|
3
|
+
export { l as AnalyticsEventData, m as AnalyticsEventValue, n as AnalyticsPublicConfig, o as AnalyticsRuntime, p as AnalyticsRuntimeConfig, q as AxCloudConfig, B as BaseRole, r as ContentCollectionType, s as ContentDetailType, t as ContentItem, u as ContentSlotImage, v as ContentSlotMap, w as ContentSlotReader, x as ContentSlotValue, y as CustomRole, z as DocumentAudience, E as DocumentSourceProvider, F as DocumentStatus, G as Membership, H as OrganizationSettings, P as Page, I as PageContentState, J as PaginatedResponse, K as SectionPermissions, L as SystemRole, Q as createContentSlotReader, R as fetchAnalyticsPublicConfig, T as getContentSlotMap, V as isAllowedAnalyticsEvent, W as isLocalAnalyticsHostname, X as sanitizeAnalyticsEventData, Y as sanitizeAnalyticsPath, Z as useAnalytics, _ as useAnalyticsRuntime, $ as useAxCloudContext, a0 as useContent, a1 as useContentItem, a2 as usePageContent, a3 as userHasAllPermissions, a4 as userHasAnyPermission, a5 as userHasPermission } from './useContent-qNaQd8Xi.mjs';
|
|
4
|
+
export { c as BarnsportActivitiesFilter, z as BarnsportActivity, d as BarnsportActivityListItem, C as BarnsportActivityLocation, e as BarnsportActivityResponse, D as BarnsportActivitySchedule, I as BarnsportInquirySubmissionRequest, n as BarnsportInterestSubmissionRequest, o as BarnsportInterestSubmissionResponse, B as BarnsportListResponse, a as BarnsportMunicipality, L as BarnsportRegistrationMethod, f as BarnsportSitemapResponse, O as BarnsportSitemapUrl, b as BarnsportSport, Z as useBarnsportActivities, _ as useBarnsportActivity, a0 as useBarnsportMunicipalities, a3 as useBarnsportSitemap, a4 as useBarnsportSport, a5 as useBarnsportSports, a7 as useSubmitBarnsportInterest } from './useBarnsport-3NwAFn3h.mjs';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import { QueryClient } from '@tanstack/react-query';
|
|
@@ -55,6 +55,29 @@ interface FormSubmissionResponse {
|
|
|
55
55
|
/** Unique submission ID */
|
|
56
56
|
submissionId: string;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A section an organization offers in its public membership application,
|
|
60
|
+
* typically an airline or other employer with a section of its own
|
|
61
|
+
*/
|
|
62
|
+
interface MembershipSection {
|
|
63
|
+
/** Send as `sectionId` in the membership application data */
|
|
64
|
+
id: string;
|
|
65
|
+
/** The name to show the applicant */
|
|
66
|
+
name: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Membership application data. Name the applicant's section with `sectionId`
|
|
70
|
+
* (one of {@link getMembershipSections}); for a company without a section of
|
|
71
|
+
* its own, send its name as `company` instead.
|
|
72
|
+
*/
|
|
73
|
+
interface MembershipApplicationData {
|
|
74
|
+
firstName?: string;
|
|
75
|
+
lastName?: string;
|
|
76
|
+
phone?: string;
|
|
77
|
+
sectionId?: string;
|
|
78
|
+
company?: string;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
58
81
|
/**
|
|
59
82
|
* Form submission stored in database
|
|
60
83
|
*/
|
|
@@ -138,6 +161,34 @@ interface FormSubmissionsResponse {
|
|
|
138
161
|
* ```
|
|
139
162
|
*/
|
|
140
163
|
declare function submitForm(apiUrl: string, submission: FormSubmission): Promise<FormSubmissionResponse>;
|
|
164
|
+
/**
|
|
165
|
+
* List the sections an organization offers in its public membership application
|
|
166
|
+
*
|
|
167
|
+
* Uses the same public forms API key and site as a submission, but does not
|
|
168
|
+
* count toward the key's rate limit, so asking on every page view never uses
|
|
169
|
+
* up what submissions need. Only sections the organization has made
|
|
170
|
+
* selectable are returned; the list is empty when there are none.
|
|
171
|
+
* Throws when the API refuses, for example when the membership form is not
|
|
172
|
+
* enabled, so a site can fall back to a free-text company field.
|
|
173
|
+
*
|
|
174
|
+
* @param apiUrl - AxCloud Forms API base URL (e.g., 'https://api.axcloud.app/forms')
|
|
175
|
+
* @param options - The public forms API key and the site domain
|
|
176
|
+
* @returns The sections, sorted by the name the applicant sees
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```tsx
|
|
180
|
+
* const sections = await getMembershipSections('https://api.axcloud.app/forms', {
|
|
181
|
+
* apiKey: 'your-org-forms-key',
|
|
182
|
+
* site: 'example.org'
|
|
183
|
+
* })
|
|
184
|
+
* // [{ id: 'section_x', name: 'SAS' }, ...]
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
declare function getMembershipSections(apiUrl: string, options: {
|
|
188
|
+
apiKey: string;
|
|
189
|
+
site: string;
|
|
190
|
+
signal?: AbortSignal;
|
|
191
|
+
}): Promise<MembershipSection[]>;
|
|
141
192
|
/**
|
|
142
193
|
* Create a form submission helper with pre-configured API URL, API key, and site
|
|
143
194
|
*
|
|
@@ -178,12 +229,13 @@ declare function createFormHelper(config: {
|
|
|
178
229
|
/**
|
|
179
230
|
* Submit a membership application
|
|
180
231
|
*/
|
|
181
|
-
submitMembership: (email: string, data:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
232
|
+
submitMembership: (email: string, data: MembershipApplicationData) => Promise<FormSubmissionResponse>;
|
|
233
|
+
/**
|
|
234
|
+
* List the sections offered in the membership application
|
|
235
|
+
*/
|
|
236
|
+
getMembershipSections: (options?: {
|
|
237
|
+
signal?: AbortSignal;
|
|
238
|
+
}) => Promise<MembershipSection[]>;
|
|
187
239
|
/**
|
|
188
240
|
* Generic submit function
|
|
189
241
|
*/
|
|
@@ -1408,4 +1460,5 @@ interface LinkedAccountsListProps {
|
|
|
1408
1460
|
*/
|
|
1409
1461
|
declare function LinkedAccountsList({ providers, showConnectButtons, className, onUnlink, onLinkInitiated, renderIdentity, renderAvailableProvider, }: LinkedAccountsListProps): React.JSX.Element;
|
|
1410
1462
|
|
|
1411
|
-
export {
|
|
1463
|
+
export { AxCloudAnalyticsOptions, AxCloudError, AxCloudModule, AxCloudProvider, ContentListResponse, ContentQueryOptions, DocumentFolder, DocumentFolderListResponse, DocumentItem, DocumentListResponse, DocumentQueryOptions, LinkedAccountsList, LoginButton, LogoutButton, MediaItem, MediaListResponse, ModuleGate, NewsItem, Organization, OrganizationBranding, ProtectedRoute, Section, SignedDocumentUrl, SignedMediaUrl, User$1 as User, UserRole, castVote, castVoteWithCode, checkEligibility, checkVotingCode, createFormHelper, getBallot, getMembershipSections, getVotingReceipt, isAxCloudError, submitForm, useAuth, useAvatar, useBranding, useCodeBallot, useDocumentDownload, useDocuments, useFormStats, useForms, useLinkedAccounts, useLogo, useMedia, useMediaList, useMemberDocumentDownload, useMemberDocumentFolders, useMemberDocuments, useModuleAccess, useMySection, useNews, useOrg, useSections, useUpdateFormSubmission, useUpdateMyProfile, useUser };
|
|
1464
|
+
export type { Auth0ClientState, AuthUser, AvailableProvider, AxCloudErrorCode, Ballot, BallotCandidate, BallotOption, BallotSeat, CastVoteResult, CodeEligibility, EmailVerificationResult, FormStatsResponse, FormSubmission, FormSubmissionRecord, FormSubmissionResponse, FormSubmissionsResponse, LinkedAccountsListProps, LinkedIdentity, MembershipApplicationData, MembershipSection, MyProfileResponse, UpdateMyProfileInput, UseAuthReturn, UseLinkedAccountsReturn, UserApiResponse, UserOrganizationMembership, UserOrganizationSection, VoteReceipt };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { A as AxCloudClient, c as createClient, g as getClient } from './client-FOpKwe3e.js';
|
|
2
|
-
import { A as AxCloudAnalyticsOptions, U as User$1, a as UserRole, O as Organization, b as AxCloudModule, C as ContentQueryOptions, N as NewsItem, c as ContentListResponse, S as Section, d as SignedMediaUrl, e as OrganizationBranding, M as MediaItem, f as MediaListResponse, g as SignedDocumentUrl, D as DocumentQueryOptions, h as DocumentItem, i as DocumentListResponse, j as DocumentFolder, k as DocumentFolderListResponse } from './useContent-
|
|
3
|
-
export { l as AnalyticsEventData, m as AnalyticsEventValue, n as AnalyticsPublicConfig, o as AnalyticsRuntime, p as AnalyticsRuntimeConfig, q as AxCloudConfig, B as BaseRole, r as ContentCollectionType, s as ContentDetailType, t as ContentItem, u as ContentSlotImage, v as ContentSlotMap, w as ContentSlotReader, x as ContentSlotValue, y as CustomRole, z as DocumentAudience, E as DocumentSourceProvider, F as DocumentStatus, G as Membership, H as OrganizationSettings, P as Page, I as PageContentState, J as PaginatedResponse, K as SectionPermissions, L as SystemRole, Q as createContentSlotReader, R as fetchAnalyticsPublicConfig, T as getContentSlotMap, V as isAllowedAnalyticsEvent, W as isLocalAnalyticsHostname, X as sanitizeAnalyticsEventData, Y as sanitizeAnalyticsPath, Z as useAnalytics, _ as useAnalyticsRuntime, $ as useAxCloudContext, a0 as useContent, a1 as useContentItem, a2 as usePageContent, a3 as userHasAllPermissions, a4 as userHasAnyPermission, a5 as userHasPermission } from './useContent-
|
|
4
|
-
export {
|
|
2
|
+
import { A as AxCloudAnalyticsOptions, U as User$1, a as UserRole, O as Organization, b as AxCloudModule, C as ContentQueryOptions, N as NewsItem, c as ContentListResponse, S as Section, d as SignedMediaUrl, e as OrganizationBranding, M as MediaItem, f as MediaListResponse, g as SignedDocumentUrl, D as DocumentQueryOptions, h as DocumentItem, i as DocumentListResponse, j as DocumentFolder, k as DocumentFolderListResponse } from './useContent-BULNVLEx.js';
|
|
3
|
+
export { l as AnalyticsEventData, m as AnalyticsEventValue, n as AnalyticsPublicConfig, o as AnalyticsRuntime, p as AnalyticsRuntimeConfig, q as AxCloudConfig, B as BaseRole, r as ContentCollectionType, s as ContentDetailType, t as ContentItem, u as ContentSlotImage, v as ContentSlotMap, w as ContentSlotReader, x as ContentSlotValue, y as CustomRole, z as DocumentAudience, E as DocumentSourceProvider, F as DocumentStatus, G as Membership, H as OrganizationSettings, P as Page, I as PageContentState, J as PaginatedResponse, K as SectionPermissions, L as SystemRole, Q as createContentSlotReader, R as fetchAnalyticsPublicConfig, T as getContentSlotMap, V as isAllowedAnalyticsEvent, W as isLocalAnalyticsHostname, X as sanitizeAnalyticsEventData, Y as sanitizeAnalyticsPath, Z as useAnalytics, _ as useAnalyticsRuntime, $ as useAxCloudContext, a0 as useContent, a1 as useContentItem, a2 as usePageContent, a3 as userHasAllPermissions, a4 as userHasAnyPermission, a5 as userHasPermission } from './useContent-BULNVLEx.js';
|
|
4
|
+
export { c as BarnsportActivitiesFilter, z as BarnsportActivity, d as BarnsportActivityListItem, C as BarnsportActivityLocation, e as BarnsportActivityResponse, D as BarnsportActivitySchedule, I as BarnsportInquirySubmissionRequest, n as BarnsportInterestSubmissionRequest, o as BarnsportInterestSubmissionResponse, B as BarnsportListResponse, a as BarnsportMunicipality, L as BarnsportRegistrationMethod, f as BarnsportSitemapResponse, O as BarnsportSitemapUrl, b as BarnsportSport, Z as useBarnsportActivities, _ as useBarnsportActivity, a0 as useBarnsportMunicipalities, a3 as useBarnsportSitemap, a4 as useBarnsportSport, a5 as useBarnsportSports, a7 as useSubmitBarnsportInterest } from './useBarnsport-3NwAFn3h.js';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import { QueryClient } from '@tanstack/react-query';
|
|
@@ -55,6 +55,29 @@ interface FormSubmissionResponse {
|
|
|
55
55
|
/** Unique submission ID */
|
|
56
56
|
submissionId: string;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A section an organization offers in its public membership application,
|
|
60
|
+
* typically an airline or other employer with a section of its own
|
|
61
|
+
*/
|
|
62
|
+
interface MembershipSection {
|
|
63
|
+
/** Send as `sectionId` in the membership application data */
|
|
64
|
+
id: string;
|
|
65
|
+
/** The name to show the applicant */
|
|
66
|
+
name: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Membership application data. Name the applicant's section with `sectionId`
|
|
70
|
+
* (one of {@link getMembershipSections}); for a company without a section of
|
|
71
|
+
* its own, send its name as `company` instead.
|
|
72
|
+
*/
|
|
73
|
+
interface MembershipApplicationData {
|
|
74
|
+
firstName?: string;
|
|
75
|
+
lastName?: string;
|
|
76
|
+
phone?: string;
|
|
77
|
+
sectionId?: string;
|
|
78
|
+
company?: string;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
58
81
|
/**
|
|
59
82
|
* Form submission stored in database
|
|
60
83
|
*/
|
|
@@ -138,6 +161,34 @@ interface FormSubmissionsResponse {
|
|
|
138
161
|
* ```
|
|
139
162
|
*/
|
|
140
163
|
declare function submitForm(apiUrl: string, submission: FormSubmission): Promise<FormSubmissionResponse>;
|
|
164
|
+
/**
|
|
165
|
+
* List the sections an organization offers in its public membership application
|
|
166
|
+
*
|
|
167
|
+
* Uses the same public forms API key and site as a submission, but does not
|
|
168
|
+
* count toward the key's rate limit, so asking on every page view never uses
|
|
169
|
+
* up what submissions need. Only sections the organization has made
|
|
170
|
+
* selectable are returned; the list is empty when there are none.
|
|
171
|
+
* Throws when the API refuses, for example when the membership form is not
|
|
172
|
+
* enabled, so a site can fall back to a free-text company field.
|
|
173
|
+
*
|
|
174
|
+
* @param apiUrl - AxCloud Forms API base URL (e.g., 'https://api.axcloud.app/forms')
|
|
175
|
+
* @param options - The public forms API key and the site domain
|
|
176
|
+
* @returns The sections, sorted by the name the applicant sees
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```tsx
|
|
180
|
+
* const sections = await getMembershipSections('https://api.axcloud.app/forms', {
|
|
181
|
+
* apiKey: 'your-org-forms-key',
|
|
182
|
+
* site: 'example.org'
|
|
183
|
+
* })
|
|
184
|
+
* // [{ id: 'section_x', name: 'SAS' }, ...]
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
declare function getMembershipSections(apiUrl: string, options: {
|
|
188
|
+
apiKey: string;
|
|
189
|
+
site: string;
|
|
190
|
+
signal?: AbortSignal;
|
|
191
|
+
}): Promise<MembershipSection[]>;
|
|
141
192
|
/**
|
|
142
193
|
* Create a form submission helper with pre-configured API URL, API key, and site
|
|
143
194
|
*
|
|
@@ -178,12 +229,13 @@ declare function createFormHelper(config: {
|
|
|
178
229
|
/**
|
|
179
230
|
* Submit a membership application
|
|
180
231
|
*/
|
|
181
|
-
submitMembership: (email: string, data:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
232
|
+
submitMembership: (email: string, data: MembershipApplicationData) => Promise<FormSubmissionResponse>;
|
|
233
|
+
/**
|
|
234
|
+
* List the sections offered in the membership application
|
|
235
|
+
*/
|
|
236
|
+
getMembershipSections: (options?: {
|
|
237
|
+
signal?: AbortSignal;
|
|
238
|
+
}) => Promise<MembershipSection[]>;
|
|
187
239
|
/**
|
|
188
240
|
* Generic submit function
|
|
189
241
|
*/
|
|
@@ -1408,4 +1460,5 @@ interface LinkedAccountsListProps {
|
|
|
1408
1460
|
*/
|
|
1409
1461
|
declare function LinkedAccountsList({ providers, showConnectButtons, className, onUnlink, onLinkInitiated, renderIdentity, renderAvailableProvider, }: LinkedAccountsListProps): React.JSX.Element;
|
|
1410
1462
|
|
|
1411
|
-
export {
|
|
1463
|
+
export { AxCloudAnalyticsOptions, AxCloudError, AxCloudModule, AxCloudProvider, ContentListResponse, ContentQueryOptions, DocumentFolder, DocumentFolderListResponse, DocumentItem, DocumentListResponse, DocumentQueryOptions, LinkedAccountsList, LoginButton, LogoutButton, MediaItem, MediaListResponse, ModuleGate, NewsItem, Organization, OrganizationBranding, ProtectedRoute, Section, SignedDocumentUrl, SignedMediaUrl, User$1 as User, UserRole, castVote, castVoteWithCode, checkEligibility, checkVotingCode, createFormHelper, getBallot, getMembershipSections, getVotingReceipt, isAxCloudError, submitForm, useAuth, useAvatar, useBranding, useCodeBallot, useDocumentDownload, useDocuments, useFormStats, useForms, useLinkedAccounts, useLogo, useMedia, useMediaList, useMemberDocumentDownload, useMemberDocumentFolders, useMemberDocuments, useModuleAccess, useMySection, useNews, useOrg, useSections, useUpdateFormSubmission, useUpdateMyProfile, useUser };
|
|
1464
|
+
export type { Auth0ClientState, AuthUser, AvailableProvider, AxCloudErrorCode, Ballot, BallotCandidate, BallotOption, BallotSeat, CastVoteResult, CodeEligibility, EmailVerificationResult, FormStatsResponse, FormSubmission, FormSubmissionRecord, FormSubmissionResponse, FormSubmissionsResponse, LinkedAccountsListProps, LinkedIdentity, MembershipApplicationData, MembershipSection, MyProfileResponse, UpdateMyProfileInput, UseAuthReturn, UseLinkedAccountsReturn, UserApiResponse, UserOrganizationMembership, UserOrganizationSection, VoteReceipt };
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,26 @@ async function submitForm(apiUrl, submission) {
|
|
|
77
77
|
throw primaryError;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
async function getMembershipSections(apiUrl, options) {
|
|
81
|
+
const baseUrl = apiUrl.replace(/\/$/, "");
|
|
82
|
+
const response = await fetch(
|
|
83
|
+
`${baseUrl}/public/membership-sections?site=${encodeURIComponent(options.site)}`,
|
|
84
|
+
{
|
|
85
|
+
method: "GET",
|
|
86
|
+
headers: { "X-Api-Key": options.apiKey },
|
|
87
|
+
signal: options.signal
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
const error = await response.json().catch(() => ({}));
|
|
92
|
+
throw new Error(error.message || `Membership sections request failed (${response.status})`);
|
|
93
|
+
}
|
|
94
|
+
const result = await response.json().catch(() => ({}));
|
|
95
|
+
const sections = Array.isArray(result?.sections) ? result.sections : [];
|
|
96
|
+
return sections.filter(
|
|
97
|
+
(section) => !!section && typeof section.id === "string" && typeof section.name === "string"
|
|
98
|
+
).map(({ id, name }) => ({ id, name }));
|
|
99
|
+
}
|
|
80
100
|
function createFormHelper(config) {
|
|
81
101
|
return {
|
|
82
102
|
/**
|
|
@@ -109,6 +129,14 @@ function createFormHelper(config) {
|
|
|
109
129
|
email,
|
|
110
130
|
data
|
|
111
131
|
}),
|
|
132
|
+
/**
|
|
133
|
+
* List the sections offered in the membership application
|
|
134
|
+
*/
|
|
135
|
+
getMembershipSections: (options = {}) => getMembershipSections(config.apiUrl, {
|
|
136
|
+
apiKey: config.apiKey,
|
|
137
|
+
site: config.site,
|
|
138
|
+
signal: options.signal
|
|
139
|
+
}),
|
|
112
140
|
/**
|
|
113
141
|
* Generic submit function
|
|
114
142
|
*/
|
|
@@ -859,17 +887,18 @@ function useSections() {
|
|
|
859
887
|
refetch: query.refetch
|
|
860
888
|
};
|
|
861
889
|
}
|
|
890
|
+
var FORMS_ADMIN_PATH = "/forms/admin";
|
|
862
891
|
function useForms(options = {}) {
|
|
863
|
-
const { client,
|
|
892
|
+
const { client, orgId } = chunk7K5N3DQ4_js.useAxCloudContext();
|
|
864
893
|
const { formType, status, limit = 50, cursor } = options;
|
|
865
894
|
const query = reactQuery.useQuery({
|
|
866
|
-
queryKey: ["axcloud", "forms", "submissions",
|
|
895
|
+
queryKey: ["axcloud", "forms", "submissions", orgId, formType, status, limit, cursor],
|
|
867
896
|
queryFn: async () => {
|
|
868
|
-
const params = { limit };
|
|
897
|
+
const params = { org_id: orgId, limit };
|
|
869
898
|
if (formType) params.form_type = formType;
|
|
870
899
|
if (status) params.status = status;
|
|
871
900
|
if (cursor) params.cursor = cursor;
|
|
872
|
-
return client.get(
|
|
901
|
+
return client.get(`${FORMS_ADMIN_PATH}/submissions`, params);
|
|
873
902
|
},
|
|
874
903
|
staleTime: 1e3 * 30
|
|
875
904
|
// 30 seconds
|
|
@@ -886,12 +915,12 @@ function useForms(options = {}) {
|
|
|
886
915
|
};
|
|
887
916
|
}
|
|
888
917
|
function useFormStats(options = {}) {
|
|
889
|
-
const { client,
|
|
918
|
+
const { client, orgId } = chunk7K5N3DQ4_js.useAxCloudContext();
|
|
890
919
|
const { days = 30 } = options;
|
|
891
920
|
const query = reactQuery.useQuery({
|
|
892
|
-
queryKey: ["axcloud", "forms", "stats",
|
|
921
|
+
queryKey: ["axcloud", "forms", "stats", orgId, days],
|
|
893
922
|
queryFn: async () => {
|
|
894
|
-
return client.get(
|
|
923
|
+
return client.get(`${FORMS_ADMIN_PATH}/stats`, { org_id: orgId, days });
|
|
895
924
|
},
|
|
896
925
|
staleTime: 1e3 * 60 * 5
|
|
897
926
|
// 5 minutes
|
|
@@ -907,7 +936,7 @@ function useFormStats(options = {}) {
|
|
|
907
936
|
};
|
|
908
937
|
}
|
|
909
938
|
function useUpdateFormSubmission() {
|
|
910
|
-
const { client,
|
|
939
|
+
const { client, orgId } = chunk7K5N3DQ4_js.useAxCloudContext();
|
|
911
940
|
const queryClient = reactQuery.useQueryClient();
|
|
912
941
|
return reactQuery.useMutation({
|
|
913
942
|
mutationFn: async ({
|
|
@@ -915,7 +944,10 @@ function useUpdateFormSubmission() {
|
|
|
915
944
|
status,
|
|
916
945
|
notes
|
|
917
946
|
}) => {
|
|
918
|
-
return client.patch(
|
|
947
|
+
return client.patch(
|
|
948
|
+
`${FORMS_ADMIN_PATH}/submissions/${encodeURIComponent(submissionId)}?org_id=${encodeURIComponent(orgId)}`,
|
|
949
|
+
{ status, notes }
|
|
950
|
+
);
|
|
919
951
|
},
|
|
920
952
|
onSuccess: () => {
|
|
921
953
|
queryClient.invalidateQueries({ queryKey: ["axcloud", "forms"] });
|
|
@@ -1645,6 +1677,7 @@ exports.checkEligibility = checkEligibility;
|
|
|
1645
1677
|
exports.checkVotingCode = checkVotingCode;
|
|
1646
1678
|
exports.createFormHelper = createFormHelper;
|
|
1647
1679
|
exports.getBallot = getBallot;
|
|
1680
|
+
exports.getMembershipSections = getMembershipSections;
|
|
1648
1681
|
exports.getVotingReceipt = getVotingReceipt;
|
|
1649
1682
|
exports.submitForm = submitForm;
|
|
1650
1683
|
exports.useAuth = useAuth;
|