@axcode/axcloud-sdk 0.1.7-dev.cc5cc69 → 0.2.0-dev.03fb26c

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
@@ -30,7 +30,7 @@ npm install --save-exact @axcode/axcloud-sdk@latest
30
30
  ```json
31
31
  {
32
32
  "dependencies": {
33
- "@axcode/axcloud-sdk": "0.1.6"
33
+ "@axcode/axcloud-sdk": "0.2.0"
34
34
  }
35
35
  }
36
36
  ```
@@ -353,25 +353,25 @@ function Dashboard() {
353
353
 
354
354
  ### Hooks
355
355
 
356
- | Hook | Description |
357
- | --------------------------------- | -------------------------------------------------------------------------------------------- |
358
- | `useAuth()` | Login/logout, email-verification state, resend, and profile refresh |
359
- | `useUser()` | Fetch the normalized user and verified organization membership |
360
- | `useUpdateMyProfile()` | Update the signed-in user's name, phone, and address |
361
- | `useOrg()` | Fetch organization info and check modules |
362
- | `useNews(options?)` | Fetch the published news collection visible to the current visitor |
363
- | `useContent(type, options?)` | Fetch a published `news`, `pages`, or `events` collection |
364
- | `useContentItem(type, id, opts?)` | Fetch one published item directly by ID or slug |
365
- | `usePageContent(slug, options?)` | Fetch a page and read structured template slots |
366
- | `useMySection()` | Fetch current user's section with members |
367
- | `useSections()` | Fetch all organization sections |
368
- | `useBranding()` | Fetch organization branding (logo, colors) |
369
- | `useLogo()` | Fetch organization logo URL |
370
- | `useMedia(mediaId)` | Fetch specific media file URL |
371
- | `useAvatar(userId)` | Fetch user avatar URL |
372
- | `useMediaList(type)` | List media files |
373
- | `useDocuments(options?)` | List published public documents |
374
- | `useDocumentDownload(documentId)` | Fetch a signed document download URL |
356
+ | Hook | Description |
357
+ | --------------------------------- | ------------------------------------------------------------------- |
358
+ | `useAuth()` | Login/logout, email-verification state, resend, and profile refresh |
359
+ | `useUser()` | Fetch the normalized user and verified organization membership |
360
+ | `useUpdateMyProfile()` | Update the signed-in user's name, phone, and address |
361
+ | `useOrg()` | Fetch organization info and check modules |
362
+ | `useNews(options?)` | Fetch the published news collection visible to the current visitor |
363
+ | `useContent(type, options?)` | Fetch a published `news`, `pages`, or `events` collection |
364
+ | `useContentItem(type, id, opts?)` | Fetch one published item directly by ID or slug |
365
+ | `usePageContent(slug, options?)` | Fetch a page and read structured template slots |
366
+ | `useMySection()` | Fetch current user's section with members |
367
+ | `useSections()` | Fetch all organization sections |
368
+ | `useBranding()` | Fetch organization branding (logo, colors) |
369
+ | `useLogo()` | Fetch organization logo URL |
370
+ | `useMedia(mediaId)` | Fetch specific media file URL |
371
+ | `useAvatar(userId)` | Fetch user avatar URL |
372
+ | `useMediaList(type)` | List media files |
373
+ | `useDocuments(options?)` | List published public documents |
374
+ | `useDocumentDownload(documentId)` | Fetch a signed document download URL |
375
375
 
376
376
  Profile self-service is deliberately limited to personal contact fields. Organization title,
377
377
  email, roles, status, organization, and section assignments remain administrator-managed.
@@ -384,14 +384,18 @@ const {
384
384
  user,
385
385
  roleInOrg,
386
386
  title,
387
- section, // { id, name, role } | null
388
- sections, // all verified section memberships
387
+ section, // { id, name, role } | null
388
+ sections, // all verified section memberships
389
389
  sectionId,
390
390
  sectionIds,
391
- memberSince, // normalized from joined_at
391
+ memberSince, // normalized from joined_at
392
392
  } = useUser();
393
393
 
394
- return <p>{section?.name ?? 'No section'} · member since {memberSince}</p>;
394
+ return (
395
+ <p>
396
+ {section?.name ?? 'No section'} · member since {memberSince}
397
+ </p>
398
+ );
395
399
  ```
396
400
 
397
401
  ```tsx
@@ -400,14 +404,19 @@ import { useUpdateMyProfile } from '@axcode/axcloud-sdk';
400
404
  function ProfileForm() {
401
405
  const updateProfile = useUpdateMyProfile();
402
406
 
403
- const save = () => updateProfile.mutateAsync({
404
- firstName: 'Anna',
405
- lastName: 'Pilot',
406
- phone: '+46701234567',
407
- address: 'Flyggatan 1',
408
- });
407
+ const save = () =>
408
+ updateProfile.mutateAsync({
409
+ firstName: 'Anna',
410
+ lastName: 'Pilot',
411
+ phone: '+46701234567',
412
+ address: 'Flyggatan 1',
413
+ });
409
414
 
410
- return <button onClick={save} disabled={updateProfile.isPending}>Save profile</button>;
415
+ return (
416
+ <button onClick={save} disabled={updateProfile.isPending}>
417
+ Save profile
418
+ </button>
419
+ );
411
420
  }
412
421
  ```
413
422
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import React from 'react';
3
2
  import * as _tanstack_react_query from '@tanstack/react-query';
4
3
  import { QueryClient } from '@tanstack/react-query';
@@ -1032,7 +1031,7 @@ interface AxCloudProviderProps {
1032
1031
  * </AxCloudProvider>
1033
1032
  * ```
1034
1033
  */
1035
- declare function AxCloudProvider({ children, orgId, apiUrl, stage, apiKey, analytics, auth0, queryClient: providedQueryClient, timeout, }: AxCloudProviderProps): react_jsx_runtime.JSX.Element;
1034
+ declare function AxCloudProvider({ children, orgId, apiUrl, stage, apiKey, analytics, auth0, queryClient: providedQueryClient, timeout, }: AxCloudProviderProps): React.JSX.Element;
1036
1035
 
1037
1036
  interface AxCloudContextValue {
1038
1037
  config: AxCloudConfig;
@@ -1985,7 +1984,7 @@ interface LoginButtonProps {
1985
1984
  * <LoginButton className="btn btn-primary">Sign In</LoginButton>
1986
1985
  * ```
1987
1986
  */
1988
- declare function LoginButton({ children, returnTo, className, style, }: LoginButtonProps): react_jsx_runtime.JSX.Element;
1987
+ declare function LoginButton({ children, returnTo, className, style, }: LoginButtonProps): React.JSX.Element;
1989
1988
  interface LogoutButtonProps {
1990
1989
  /**
1991
1990
  * Button text
@@ -2012,7 +2011,7 @@ interface LogoutButtonProps {
2012
2011
  * <LogoutButton>Sign Out</LogoutButton>
2013
2012
  * ```
2014
2013
  */
2015
- declare function LogoutButton({ children, returnTo, className, style, }: LogoutButtonProps): react_jsx_runtime.JSX.Element;
2014
+ declare function LogoutButton({ children, returnTo, className, style, }: LogoutButtonProps): React.JSX.Element;
2016
2015
 
2017
2016
  interface ProtectedRouteProps {
2018
2017
  /**
@@ -2080,7 +2079,7 @@ interface ProtectedRouteProps {
2080
2079
  * </ProtectedRoute>
2081
2080
  * ```
2082
2081
  */
2083
- declare function ProtectedRoute({ children, roles, loadingComponent, unauthenticatedComponent, unauthorizedComponent, redirectToLogin, returnTo, }: ProtectedRouteProps): react_jsx_runtime.JSX.Element;
2082
+ declare function ProtectedRoute({ children, roles, loadingComponent, unauthenticatedComponent, unauthorizedComponent, redirectToLogin, returnTo, }: ProtectedRouteProps): React.JSX.Element;
2084
2083
 
2085
2084
  interface ModuleGateProps {
2086
2085
  /**
@@ -2129,7 +2128,7 @@ interface ModuleGateProps {
2129
2128
  * </ModuleGate>
2130
2129
  * ```
2131
2130
  */
2132
- declare function ModuleGate({ module, children, fallback, requireAll, }: ModuleGateProps): react_jsx_runtime.JSX.Element | null;
2131
+ declare function ModuleGate({ module, children, fallback, requireAll, }: ModuleGateProps): React.JSX.Element | null;
2133
2132
  /**
2134
2133
  * useModuleAccess - Hook for programmatic module checks
2135
2134
  *
@@ -2154,6 +2153,31 @@ declare function useModuleAccess(): {
2154
2153
  isLoading: boolean;
2155
2154
  };
2156
2155
 
2156
+ /**
2157
+ * LinkedAccountsList Component
2158
+ *
2159
+ * Ready-to-use component for displaying and managing linked social accounts.
2160
+ * Can be used in customer frontends (SPF "mina sidor" etc.).
2161
+ *
2162
+ * Import the CSS file for default styling:
2163
+ * import '@axcode/axcloud-sdk/styles/linked-accounts.css'
2164
+ *
2165
+ * @example
2166
+ * ```tsx
2167
+ * import { LinkedAccountsList } from '@axcode/axcloud-sdk'
2168
+ * import '@axcode/axcloud-sdk/styles/linked-accounts.css'
2169
+ *
2170
+ * function MinProfil() {
2171
+ * return (
2172
+ * <div>
2173
+ * <h2>Kopplade konton</h2>
2174
+ * <LinkedAccountsList providers={['google', 'microsoft']} />
2175
+ * </div>
2176
+ * )
2177
+ * }
2178
+ * ```
2179
+ */
2180
+
2157
2181
  interface LinkedAccountsListProps {
2158
2182
  /** Which providers to show (default: all available) */
2159
2183
  providers?: ('google' | 'microsoft' | 'apple')[];
@@ -2176,6 +2200,6 @@ interface LinkedAccountsListProps {
2176
2200
  * Uses CSS classes for styling. Import the CSS file for default styles:
2177
2201
  * import '@axcode/axcloud-sdk/styles/linked-accounts.css'
2178
2202
  */
2179
- declare function LinkedAccountsList({ providers, showConnectButtons, className, onUnlink, onLinkInitiated, renderIdentity, renderAvailableProvider, }: LinkedAccountsListProps): react_jsx_runtime.JSX.Element;
2203
+ declare function LinkedAccountsList({ providers, showConnectButtons, className, onUnlink, onLinkInitiated, renderIdentity, renderAvailableProvider, }: LinkedAccountsListProps): React.JSX.Element;
2180
2204
 
2181
2205
  export { type AnalyticsEventData, type AnalyticsEventValue, type AnalyticsPublicConfig, type AnalyticsRuntime, type AnalyticsRuntimeConfig, type Auth0ClientState, type AuthUser, type AvailableProvider, type AxCloudAnalyticsOptions, AxCloudClient, type AxCloudConfig, AxCloudError, type AxCloudErrorCode, type AxCloudModule, AxCloudProvider, type Ballot, type BallotCandidate, type BallotOption, type BallotSeat, type BarnsportActivitiesFilter, type BarnsportActivity, type BarnsportActivityListItem, type BarnsportActivityLocation, type BarnsportActivityResponse, type BarnsportActivitySchedule, type BarnsportInterestSubmissionRequest, type BarnsportInterestSubmissionResponse, type BarnsportListResponse, type BarnsportMunicipality, type BarnsportRegistrationMethod, type BarnsportSitemapResponse, type BarnsportSitemapUrl, type BarnsportSport, type BaseRole, type CastVoteResult, type CodeEligibility, type ContentCollectionType, type ContentDetailType, type ContentItem, type ContentListResponse, type ContentQueryOptions, type ContentSlotImage, type ContentSlotMap, type ContentSlotReader, type ContentSlotValue, type CustomRole, type DocumentAudience, type DocumentFolder, type DocumentFolderListResponse, type DocumentItem, type DocumentListResponse, type DocumentQueryOptions, type DocumentSourceProvider, type DocumentStatus, type EmailVerificationResult, type FormStatsResponse, type FormSubmission, type FormSubmissionRecord, type FormSubmissionResponse, type FormSubmissionsResponse, LinkedAccountsList, type LinkedAccountsListProps, type LinkedIdentity, LoginButton, LogoutButton, type MediaItem, type MediaListResponse, type Membership, ModuleGate, type MyProfileResponse, type NewsItem, type Organization, type OrganizationBranding, type OrganizationSettings, type Page, type PageContentState, type PaginatedResponse, ProtectedRoute, type Section, type SectionPermissions, type SignedDocumentUrl, type SignedMediaUrl, type SystemRole, type UpdateMyProfileInput, type UseAuthReturn, type UseLinkedAccountsReturn, type User, type UserApiResponse, type UserOrganizationMembership, type UserOrganizationSection, type UserRole, type VoteReceipt, castVote, castVoteWithCode, checkEligibility, checkVotingCode, createClient, createContentSlotReader, createFormHelper, fetchAnalyticsPublicConfig, getBallot, getClient, getContentSlotMap, getVotingReceipt, isAllowedAnalyticsEvent, isAxCloudError, isLocalAnalyticsHostname, sanitizeAnalyticsEventData, sanitizeAnalyticsPath, submitForm, useAnalytics, useAnalyticsRuntime, useAuth, useAvatar, useAxCloudContext, useBarnsportActivities, useBarnsportActivity, useBarnsportMunicipalities, useBarnsportSitemap, useBarnsportSport, useBarnsportSports, useBranding, useCodeBallot, useContent, useContentItem, useDocumentDownload, useDocuments, useFormStats, useForms, useLinkedAccounts, useLogo, useMedia, useMediaList, useMemberDocumentDownload, useMemberDocumentFolders, useMemberDocuments, useModuleAccess, useMySection, useNews, useOrg, usePageContent, useSections, useSubmitBarnsportInterest, useUpdateFormSubmission, useUpdateMyProfile, useUser, userHasAllPermissions, userHasAnyPermission, userHasPermission };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import React from 'react';
3
2
  import * as _tanstack_react_query from '@tanstack/react-query';
4
3
  import { QueryClient } from '@tanstack/react-query';
@@ -1032,7 +1031,7 @@ interface AxCloudProviderProps {
1032
1031
  * </AxCloudProvider>
1033
1032
  * ```
1034
1033
  */
1035
- declare function AxCloudProvider({ children, orgId, apiUrl, stage, apiKey, analytics, auth0, queryClient: providedQueryClient, timeout, }: AxCloudProviderProps): react_jsx_runtime.JSX.Element;
1034
+ declare function AxCloudProvider({ children, orgId, apiUrl, stage, apiKey, analytics, auth0, queryClient: providedQueryClient, timeout, }: AxCloudProviderProps): React.JSX.Element;
1036
1035
 
1037
1036
  interface AxCloudContextValue {
1038
1037
  config: AxCloudConfig;
@@ -1985,7 +1984,7 @@ interface LoginButtonProps {
1985
1984
  * <LoginButton className="btn btn-primary">Sign In</LoginButton>
1986
1985
  * ```
1987
1986
  */
1988
- declare function LoginButton({ children, returnTo, className, style, }: LoginButtonProps): react_jsx_runtime.JSX.Element;
1987
+ declare function LoginButton({ children, returnTo, className, style, }: LoginButtonProps): React.JSX.Element;
1989
1988
  interface LogoutButtonProps {
1990
1989
  /**
1991
1990
  * Button text
@@ -2012,7 +2011,7 @@ interface LogoutButtonProps {
2012
2011
  * <LogoutButton>Sign Out</LogoutButton>
2013
2012
  * ```
2014
2013
  */
2015
- declare function LogoutButton({ children, returnTo, className, style, }: LogoutButtonProps): react_jsx_runtime.JSX.Element;
2014
+ declare function LogoutButton({ children, returnTo, className, style, }: LogoutButtonProps): React.JSX.Element;
2016
2015
 
2017
2016
  interface ProtectedRouteProps {
2018
2017
  /**
@@ -2080,7 +2079,7 @@ interface ProtectedRouteProps {
2080
2079
  * </ProtectedRoute>
2081
2080
  * ```
2082
2081
  */
2083
- declare function ProtectedRoute({ children, roles, loadingComponent, unauthenticatedComponent, unauthorizedComponent, redirectToLogin, returnTo, }: ProtectedRouteProps): react_jsx_runtime.JSX.Element;
2082
+ declare function ProtectedRoute({ children, roles, loadingComponent, unauthenticatedComponent, unauthorizedComponent, redirectToLogin, returnTo, }: ProtectedRouteProps): React.JSX.Element;
2084
2083
 
2085
2084
  interface ModuleGateProps {
2086
2085
  /**
@@ -2129,7 +2128,7 @@ interface ModuleGateProps {
2129
2128
  * </ModuleGate>
2130
2129
  * ```
2131
2130
  */
2132
- declare function ModuleGate({ module, children, fallback, requireAll, }: ModuleGateProps): react_jsx_runtime.JSX.Element | null;
2131
+ declare function ModuleGate({ module, children, fallback, requireAll, }: ModuleGateProps): React.JSX.Element | null;
2133
2132
  /**
2134
2133
  * useModuleAccess - Hook for programmatic module checks
2135
2134
  *
@@ -2154,6 +2153,31 @@ declare function useModuleAccess(): {
2154
2153
  isLoading: boolean;
2155
2154
  };
2156
2155
 
2156
+ /**
2157
+ * LinkedAccountsList Component
2158
+ *
2159
+ * Ready-to-use component for displaying and managing linked social accounts.
2160
+ * Can be used in customer frontends (SPF "mina sidor" etc.).
2161
+ *
2162
+ * Import the CSS file for default styling:
2163
+ * import '@axcode/axcloud-sdk/styles/linked-accounts.css'
2164
+ *
2165
+ * @example
2166
+ * ```tsx
2167
+ * import { LinkedAccountsList } from '@axcode/axcloud-sdk'
2168
+ * import '@axcode/axcloud-sdk/styles/linked-accounts.css'
2169
+ *
2170
+ * function MinProfil() {
2171
+ * return (
2172
+ * <div>
2173
+ * <h2>Kopplade konton</h2>
2174
+ * <LinkedAccountsList providers={['google', 'microsoft']} />
2175
+ * </div>
2176
+ * )
2177
+ * }
2178
+ * ```
2179
+ */
2180
+
2157
2181
  interface LinkedAccountsListProps {
2158
2182
  /** Which providers to show (default: all available) */
2159
2183
  providers?: ('google' | 'microsoft' | 'apple')[];
@@ -2176,6 +2200,6 @@ interface LinkedAccountsListProps {
2176
2200
  * Uses CSS classes for styling. Import the CSS file for default styles:
2177
2201
  * import '@axcode/axcloud-sdk/styles/linked-accounts.css'
2178
2202
  */
2179
- declare function LinkedAccountsList({ providers, showConnectButtons, className, onUnlink, onLinkInitiated, renderIdentity, renderAvailableProvider, }: LinkedAccountsListProps): react_jsx_runtime.JSX.Element;
2203
+ declare function LinkedAccountsList({ providers, showConnectButtons, className, onUnlink, onLinkInitiated, renderIdentity, renderAvailableProvider, }: LinkedAccountsListProps): React.JSX.Element;
2180
2204
 
2181
2205
  export { type AnalyticsEventData, type AnalyticsEventValue, type AnalyticsPublicConfig, type AnalyticsRuntime, type AnalyticsRuntimeConfig, type Auth0ClientState, type AuthUser, type AvailableProvider, type AxCloudAnalyticsOptions, AxCloudClient, type AxCloudConfig, AxCloudError, type AxCloudErrorCode, type AxCloudModule, AxCloudProvider, type Ballot, type BallotCandidate, type BallotOption, type BallotSeat, type BarnsportActivitiesFilter, type BarnsportActivity, type BarnsportActivityListItem, type BarnsportActivityLocation, type BarnsportActivityResponse, type BarnsportActivitySchedule, type BarnsportInterestSubmissionRequest, type BarnsportInterestSubmissionResponse, type BarnsportListResponse, type BarnsportMunicipality, type BarnsportRegistrationMethod, type BarnsportSitemapResponse, type BarnsportSitemapUrl, type BarnsportSport, type BaseRole, type CastVoteResult, type CodeEligibility, type ContentCollectionType, type ContentDetailType, type ContentItem, type ContentListResponse, type ContentQueryOptions, type ContentSlotImage, type ContentSlotMap, type ContentSlotReader, type ContentSlotValue, type CustomRole, type DocumentAudience, type DocumentFolder, type DocumentFolderListResponse, type DocumentItem, type DocumentListResponse, type DocumentQueryOptions, type DocumentSourceProvider, type DocumentStatus, type EmailVerificationResult, type FormStatsResponse, type FormSubmission, type FormSubmissionRecord, type FormSubmissionResponse, type FormSubmissionsResponse, LinkedAccountsList, type LinkedAccountsListProps, type LinkedIdentity, LoginButton, LogoutButton, type MediaItem, type MediaListResponse, type Membership, ModuleGate, type MyProfileResponse, type NewsItem, type Organization, type OrganizationBranding, type OrganizationSettings, type Page, type PageContentState, type PaginatedResponse, ProtectedRoute, type Section, type SectionPermissions, type SignedDocumentUrl, type SignedMediaUrl, type SystemRole, type UpdateMyProfileInput, type UseAuthReturn, type UseLinkedAccountsReturn, type User, type UserApiResponse, type UserOrganizationMembership, type UserOrganizationSection, type UserRole, type VoteReceipt, castVote, castVoteWithCode, checkEligibility, checkVotingCode, createClient, createContentSlotReader, createFormHelper, fetchAnalyticsPublicConfig, getBallot, getClient, getContentSlotMap, getVotingReceipt, isAllowedAnalyticsEvent, isAxCloudError, isLocalAnalyticsHostname, sanitizeAnalyticsEventData, sanitizeAnalyticsPath, submitForm, useAnalytics, useAnalyticsRuntime, useAuth, useAvatar, useAxCloudContext, useBarnsportActivities, useBarnsportActivity, useBarnsportMunicipalities, useBarnsportSitemap, useBarnsportSport, useBarnsportSports, useBranding, useCodeBallot, useContent, useContentItem, useDocumentDownload, useDocuments, useFormStats, useForms, useLinkedAccounts, useLogo, useMedia, useMediaList, useMemberDocumentDownload, useMemberDocumentFolders, useMemberDocuments, useModuleAccess, useMySection, useNews, useOrg, usePageContent, useSections, useSubmitBarnsportInterest, useUpdateFormSubmission, useUpdateMyProfile, useUser, userHasAllPermissions, userHasAnyPermission, userHasPermission };
package/dist/index.js CHANGED
@@ -2155,7 +2155,7 @@ function ProtectedRoute({
2155
2155
  returnTo
2156
2156
  }) {
2157
2157
  const { isAuthenticated, isLoading: isAuthLoading, login } = useAuth();
2158
- const { user, role, isLoading: isUserLoading } = useUser();
2158
+ const { role, isLoading: isUserLoading } = useUser();
2159
2159
  const isLoading = isAuthLoading || isAuthenticated && isUserLoading;
2160
2160
  if (isLoading) {
2161
2161
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: loadingComponent ?? /* @__PURE__ */ jsxRuntime.jsx(DefaultLoadingComponent, {}) });
@@ -2167,9 +2167,9 @@ function ProtectedRoute({
2167
2167
  }
2168
2168
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: unauthenticatedComponent ?? /* @__PURE__ */ jsxRuntime.jsx(DefaultUnauthenticatedComponent, {}) });
2169
2169
  }
2170
- if (roles && role) {
2170
+ if (roles) {
2171
2171
  const requiredRoles = Array.isArray(roles) ? roles : [roles];
2172
- const hasRequiredRole = requiredRoles.includes(role);
2172
+ const hasRequiredRole = role !== null && role !== void 0 && requiredRoles.includes(role);
2173
2173
  if (!hasRequiredRole) {
2174
2174
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: unauthorizedComponent ?? /* @__PURE__ */ jsxRuntime.jsx(DefaultUnauthorizedComponent, {}) });
2175
2175
  }