@axcode/axcloud-sdk 0.1.7-dev.bf490b9 → 0.1.7-dev.cc5cc69

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/dist/index.d.ts CHANGED
@@ -209,6 +209,10 @@ interface User {
209
209
  name: string;
210
210
  firstName?: string;
211
211
  lastName?: string;
212
+ /** Organization-specific title/position. Managed by organization administrators. */
213
+ title?: string | null;
214
+ phone?: string | null;
215
+ address?: string | null;
212
216
  avatar?: string;
213
217
  organizationId: string;
214
218
  sectionId?: string;
@@ -237,6 +241,8 @@ interface Membership {
237
241
  sectionId?: string;
238
242
  section?: Section;
239
243
  role: UserRole;
244
+ /** Organization-specific title/position, separate from the access role. */
245
+ title?: string | null;
240
246
  status: 'active' | 'pending' | 'suspended' | 'expired';
241
247
  joinedAt: string;
242
248
  expiresAt?: string;
@@ -271,7 +277,8 @@ type ContentPublicationState = 'draft' | 'published' | 'archived';
271
277
  type ContentAudience = 'public' | 'internal' | 'members' | 'section';
272
278
  interface ContentItem {
273
279
  id: string;
274
- organizationId: string;
280
+ /** Present when a consumer needs to distinguish organizations outside its configured provider. */
281
+ organizationId?: string;
275
282
  type: string;
276
283
  title: string;
277
284
  slug: string;
@@ -290,6 +297,7 @@ interface ContentItem {
290
297
  };
291
298
  status?: ContentPublicationState;
292
299
  visibility?: ContentPublicationState;
300
+ /** @deprecated Delivery access is derived from publication metadata and the verified visitor. */
293
301
  audience?: ContentAudience;
294
302
  sectionId?: string;
295
303
  tags?: string[];
@@ -323,13 +331,19 @@ interface Page extends ContentItem {
323
331
  template?: string;
324
332
  order?: number;
325
333
  }
326
- interface PaginatedResponse<T> {
334
+ interface ContentListResponse<T> {
327
335
  items: T[];
336
+ count: number;
328
337
  total: number;
329
338
  page: number;
330
339
  pageSize: number;
331
340
  hasMore: boolean;
341
+ nextCursor?: string;
332
342
  }
343
+ /** @deprecated Use ContentListResponse. */
344
+ type PaginatedResponse<T> = ContentListResponse<T>;
345
+ type ContentCollectionType = 'news' | 'pages' | 'events';
346
+ type ContentDetailType = 'news' | 'page' | 'event';
333
347
  interface AxCloudConfig {
334
348
  orgId: string;
335
349
  apiUrl: string;
@@ -353,13 +367,17 @@ interface AxCloudConfig {
353
367
  interface ContentQueryOptions {
354
368
  page?: number;
355
369
  pageSize?: number;
370
+ /** @deprecated Delivery endpoints always return the published snapshot. */
356
371
  status?: ContentPublicationState;
372
+ /** @deprecated Delivery endpoints always return the published snapshot. */
357
373
  visibility?: ContentPublicationState;
358
374
  audience?: ContentAudience;
375
+ /** @deprecated Member section access is derived from the verified token. */
359
376
  sectionId?: string;
360
377
  search?: string;
361
- sortBy?: string;
378
+ sortBy?: 'publishedAt' | 'createdAt' | 'updatedAt' | 'title';
362
379
  sortOrder?: 'asc' | 'desc';
380
+ tags?: string[];
363
381
  /** Return the requested translation when content has language variants. */
364
382
  lang?: string;
365
383
  /** Force public endpoint even when authenticated (for public pages) */
@@ -668,7 +686,10 @@ interface ContentSlotReader {
668
686
  fields: ContentSlotMap;
669
687
  value<T = ContentSlotValue>(key: string, fallback?: T): ContentSlotValue | T;
670
688
  text(key: string, fallback?: string): string;
689
+ /** @deprecated HTML is untrusted. Prefer text(), or unsafeHtml() with sanitization. */
671
690
  html(key: string, fallback?: string): string;
691
+ /** Returns untrusted CMS HTML. Sanitize it before inserting it into the DOM. */
692
+ unsafeHtml(key: string, fallback?: string): string;
672
693
  list(key: string, fallback?: string[]): string[];
673
694
  image(key: string, fallback?: ContentSlotImage): ContentSlotImage | undefined;
674
695
  }
@@ -1011,7 +1032,7 @@ interface AxCloudProviderProps {
1011
1032
  * </AxCloudProvider>
1012
1033
  * ```
1013
1034
  */
1014
- declare function AxCloudProvider({ children, orgId, apiUrl, stage, apiKey, analytics, auth0, queryClient, timeout, }: AxCloudProviderProps): react_jsx_runtime.JSX.Element;
1035
+ declare function AxCloudProvider({ children, orgId, apiUrl, stage, apiKey, analytics, auth0, queryClient: providedQueryClient, timeout, }: AxCloudProviderProps): react_jsx_runtime.JSX.Element;
1015
1036
 
1016
1037
  interface AxCloudContextValue {
1017
1038
  config: AxCloudConfig;
@@ -1021,6 +1042,14 @@ interface AxCloudContextValue {
1021
1042
  stage: string;
1022
1043
  /** Whether using public API mode (API key, no auth) */
1023
1044
  isPublicMode: boolean;
1045
+ /** Auth0 has completed its initial session check. */
1046
+ isAuthLoading?: boolean;
1047
+ /** Whether the current browser session is authenticated. */
1048
+ isAuthenticated?: boolean;
1049
+ /** Auth0 subject used to isolate member-only query caches. */
1050
+ authSubject?: string;
1051
+ /** Remove identity-bound AxCloud query data before logout or account changes. */
1052
+ clearContentCache?: () => void;
1024
1053
  analytics: AnalyticsRuntime;
1025
1054
  }
1026
1055
  declare function useAxCloudContext(): AxCloudContextValue;
@@ -1114,13 +1143,45 @@ interface Auth0ClientState {
1114
1143
  */
1115
1144
  declare function useAuth(): UseAuthReturn;
1116
1145
 
1146
+ interface UserOrganizationSection {
1147
+ id: string;
1148
+ name: string;
1149
+ role: string;
1150
+ }
1151
+ interface UserOrganizationMembership {
1152
+ role: string;
1153
+ roles: string[];
1154
+ title: string | null;
1155
+ status: string | null;
1156
+ joinedAt: string | null;
1157
+ memberSince: string | null;
1158
+ sectionId: string | null;
1159
+ sectionIds: string[];
1160
+ sections: UserOrganizationSection[];
1161
+ }
1117
1162
  interface UserApiResponse extends User {
1118
- all_org_ids?: string[];
1119
- organization_memberships?: Record<string, {
1120
- role: string;
1121
- sections?: string[];
1122
- }>;
1123
- isSuperAdmin?: boolean;
1163
+ allOrgIds: string[];
1164
+ organizationMemberships: Record<string, UserOrganizationMembership>;
1165
+ effectiveOrganizationId: string | null;
1166
+ isSuperAdmin: boolean;
1167
+ }
1168
+ interface UpdateMyProfileInput {
1169
+ firstName?: string;
1170
+ lastName?: string;
1171
+ phone?: string | null;
1172
+ address?: string | null;
1173
+ }
1174
+ interface MyProfileResponse {
1175
+ user_id: string;
1176
+ email: string;
1177
+ given_name: string;
1178
+ family_name: string;
1179
+ name: string;
1180
+ phone_number: string | null;
1181
+ phone: string | null;
1182
+ address: string | null;
1183
+ location: string | null;
1184
+ updated_at: string;
1124
1185
  }
1125
1186
  /**
1126
1187
  * useUser - Fetch the current authenticated user from AxCloud
@@ -1156,7 +1217,14 @@ declare function useUser(): {
1156
1217
  error: Error | null;
1157
1218
  refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<UserApiResponse, Error>>;
1158
1219
  hasOrgAccess: boolean;
1159
- roleInOrg: string | null;
1220
+ roleInOrg: UserRole | null;
1221
+ organizationMembership: UserOrganizationMembership | null;
1222
+ title: string | null;
1223
+ section: UserOrganizationSection;
1224
+ sections: UserOrganizationSection[];
1225
+ sectionIds: string[];
1226
+ joinedAt: string | null;
1227
+ memberSince: string | null;
1160
1228
  isAuthenticated: boolean;
1161
1229
  role: UserRole | null;
1162
1230
  organizationId: string | null;
@@ -1164,6 +1232,11 @@ declare function useUser(): {
1164
1232
  permissions: string[];
1165
1233
  isSuperAdmin: boolean;
1166
1234
  };
1235
+ /**
1236
+ * Updates the authenticated user's self-service profile fields.
1237
+ * Organization title, email, roles and membership data are intentionally not writable here.
1238
+ */
1239
+ declare function useUpdateMyProfile(): _tanstack_react_query.UseMutationResult<MyProfileResponse, Error, UpdateMyProfileInput, unknown>;
1167
1240
 
1168
1241
  /**
1169
1242
  * Public organization response from /content/public/{orgId}/org
@@ -1248,112 +1321,58 @@ declare function useOrg(): {
1248
1321
  };
1249
1322
 
1250
1323
  /**
1251
- * useNews - Fetch news articles for the organization
1252
- *
1253
- * When authenticated (isPublicMode = false), fetches news visible to members
1254
- * including public, internal, and members-only content.
1255
- *
1256
- * When not authenticated (isPublicMode = true), fetches only public news.
1257
- *
1258
- * @example
1259
- * ```tsx
1260
- * function NewsPage() {
1261
- * const { data: news, isLoading, isError, error } = useNews()
1262
- *
1263
- * if (isLoading) return <Spinner />
1264
- * if (isError) return <Error message={error.message} />
1265
- *
1266
- * return (
1267
- * <ul>
1268
- * {news.map(item => (
1269
- * <li key={item.id}>{item.title}</li>
1270
- * ))}
1271
- * </ul>
1272
- * )
1273
- * }
1274
- * ```
1324
+ * Fetch published news visible to the current visitor.
1275
1325
  *
1276
- * @example
1277
- * // With pagination
1278
- * ```tsx
1279
- * const { data, hasMore, refetch } = useNews({
1280
- * pageSize: 10,
1281
- * status: 'published'
1282
- * })
1283
- * ```
1326
+ * This typed convenience wrapper shares access, cache and pagination behavior
1327
+ * with the generic content hook.
1284
1328
  */
1285
1329
  declare function useNews(options?: ContentQueryOptions): {
1286
1330
  data: NewsItem[];
1331
+ count: number;
1287
1332
  total: number;
1333
+ page: number;
1334
+ pageSize: number;
1288
1335
  hasMore: boolean;
1336
+ nextCursor: string | undefined;
1289
1337
  isLoading: boolean;
1338
+ isFetching: boolean;
1290
1339
  isError: boolean;
1291
1340
  error: Error | null;
1292
- refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<NewsItem>, Error>>;
1341
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ContentListResponse<NewsItem>, Error>>;
1293
1342
  };
1294
1343
 
1295
1344
  /**
1296
- * useContent - Generic content fetching hook
1297
- *
1298
- * When authenticated (isPublicMode = false), fetches content visible to members
1299
- * including public, internal, and members-only content (for supported types).
1300
- *
1301
- * When not authenticated (isPublicMode = true), fetches only public content.
1302
- *
1303
- * @param contentType - The type of content to fetch (e.g., 'news', 'pages', 'events')
1304
- * @param options - Query options for filtering and pagination
1305
- *
1306
- * @example
1307
- * ```tsx
1308
- * // Fetch pages
1309
- * const { data: pages } = useContent('pages')
1345
+ * Fetch a published content collection.
1310
1346
  *
1311
- * // Fetch custom content type
1312
- * const { data: events } = useContent('events', {
1313
- * status: 'published',
1314
- * sortBy: 'startDate'
1315
- * })
1316
- * ```
1347
+ * AxCloud owns editorial data and publication. The consuming application owns
1348
+ * layout and rendering. Drafts are intentionally never selectable through
1349
+ * this delivery hook.
1317
1350
  */
1318
1351
  declare function useContent<T extends ContentItem = ContentItem>(contentType: string, options?: ContentQueryOptions): {
1319
1352
  data: T[];
1353
+ count: number;
1320
1354
  total: number;
1355
+ page: number;
1356
+ pageSize: number;
1321
1357
  hasMore: boolean;
1358
+ nextCursor: string | undefined;
1322
1359
  isLoading: boolean;
1360
+ isFetching: boolean;
1323
1361
  isError: boolean;
1324
1362
  error: Error | null;
1325
- refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PaginatedResponse<T>, Error>>;
1363
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ContentListResponse<T>, Error>>;
1326
1364
  };
1327
1365
  interface ContentItemOptions {
1328
- /** Force public endpoint even when authenticated */
1366
+ /** Force public delivery even when the visitor is authenticated. */
1329
1367
  publicOnly?: boolean;
1330
1368
  /** Return the requested translation when content has language variants. */
1331
1369
  lang?: string;
1332
1370
  }
1333
- /**
1334
- * useContentItem - Fetch a single content item by ID or slug
1335
- *
1336
- * When authenticated (isPublicMode = false), fetches from member endpoint
1337
- * which can return members-only content (for supported types).
1338
- *
1339
- * When not authenticated (isPublicMode = true), fetches only public content.
1340
- *
1341
- * @param contentType - The type of content (e.g., 'news', 'pages', 'events')
1342
- * @param idOrSlug - The content ID or slug
1343
- * @param options - Optional settings
1344
- *
1345
- * @example
1346
- * ```tsx
1347
- * // Fetch a page by slug
1348
- * const { data: page } = useContentItem('pages', 'about-us', { lang: 'sv' })
1349
- *
1350
- * // Force public endpoint
1351
- * const { data: page } = useContentItem('pages', 'about-us', { publicOnly: true })
1352
- * ```
1353
- */
1371
+ /** Fetch one published content item by ID or slug. */
1354
1372
  declare function useContentItem<T extends ContentItem = ContentItem>(contentType: string, idOrSlug: string, options?: ContentItemOptions): {
1355
1373
  data: _tanstack_react_query.NoInfer<T> | null;
1356
1374
  isLoading: boolean;
1375
+ isFetching: boolean;
1357
1376
  isError: boolean;
1358
1377
  error: Error | null;
1359
1378
  refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.NoInfer<T>, Error>>;
@@ -1362,16 +1381,17 @@ interface PageContentState<T extends ContentItem = ContentItem> extends ContentS
1362
1381
  page: T | null;
1363
1382
  data: T | null;
1364
1383
  isLoading: boolean;
1384
+ isFetching: boolean;
1365
1385
  isError: boolean;
1366
1386
  error: Error | null;
1367
1387
  refetch: () => unknown;
1368
1388
  }
1369
1389
  /**
1370
- * usePageContent - Fetch a website page and expose structured template fields.
1390
+ * Fetch a website page and expose structured template fields.
1371
1391
  *
1372
1392
  * Use `page.content`/`page.blocks` for article-like rich text pages. Use
1373
- * `text('hero.title')`, `list('benefits.items')`, etc. for designed website templates
1374
- * where the frontend owns layout and AxCloud owns content.
1393
+ * `text('hero.title')`, `list('benefits.items')`, etc. for designed website
1394
+ * templates where the frontend owns layout and AxCloud owns content.
1375
1395
  */
1376
1396
  declare function usePageContent<T extends ContentItem = ContentItem>(slug: string, options?: ContentItemOptions): PageContentState<T>;
1377
1397
 
@@ -2158,4 +2178,4 @@ interface LinkedAccountsListProps {
2158
2178
  */
2159
2179
  declare function LinkedAccountsList({ providers, showConnectButtons, className, onUnlink, onLinkInitiated, renderIdentity, renderAvailableProvider, }: LinkedAccountsListProps): react_jsx_runtime.JSX.Element;
2160
2180
 
2161
- 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 ContentItem, 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 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 UseAuthReturn, type UseLinkedAccountsReturn, type User, 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, useUser, userHasAllPermissions, userHasAnyPermission, userHasPermission };
2181
+ 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 };