@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/README.md +80 -35
- package/dist/index.d.mts +111 -91
- package/dist/index.d.ts +111 -91
- package/dist/index.js +389 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +391 -141
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @axcode/axcloud-sdk
|
|
2
2
|
|
|
3
|
-
SDK for building websites with AxCloud CMS and member management.
|
|
3
|
+
SDK for building websites with AxCloud CMS and member management. AxCloud is
|
|
4
|
+
headless: it owns content, publication, access control and delivery APIs, while
|
|
5
|
+
the consuming application owns markup, layout and design.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -17,25 +19,24 @@ The SDK is published with two tags for different environments:
|
|
|
17
19
|
| `latest` | Production | Stable, tested | `npm install @axcode/axcloud-sdk` |
|
|
18
20
|
| `next` | Development/Staging | Preview, may have breaking changes | `npm install @axcode/axcloud-sdk@next` |
|
|
19
21
|
|
|
20
|
-
**Recommended setup:**
|
|
22
|
+
**Recommended production setup:**
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
}
|
|
24
|
+
Resolve `latest` deliberately, then commit the exact version and lockfile:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install --save-exact @axcode/axcloud-sdk@latest
|
|
28
|
+
```
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
```json
|
|
31
31
|
{
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@axcode/axcloud-sdk": "
|
|
33
|
+
"@axcode/axcloud-sdk": "0.1.6"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Do not install a moving tag in CI or during deployment. Test a specific `next`
|
|
39
|
+
version in a branch when needed, then promote and pin the stable release.
|
|
39
40
|
|
|
40
41
|
## Quick Start
|
|
41
42
|
|
|
@@ -90,7 +91,10 @@ function NewsPage() {
|
|
|
90
91
|
}
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
> **Content
|
|
94
|
+
> **Content delivery:** These hooks return only published snapshots. When the
|
|
95
|
+
> user is authenticated, access to internal, member and section content is
|
|
96
|
+
> derived from the verified token. Anonymous users receive only public content.
|
|
97
|
+
> Client-supplied status or section identifiers never grant broader access.
|
|
94
98
|
|
|
95
99
|
Pages and news can be stored once in AxCloud with translations and requested per language:
|
|
96
100
|
|
|
@@ -234,31 +238,23 @@ function MySectionPage() {
|
|
|
234
238
|
}
|
|
235
239
|
```
|
|
236
240
|
|
|
237
|
-
### 4b.
|
|
241
|
+
### 4b. Section-scoped content
|
|
238
242
|
|
|
239
243
|
```tsx
|
|
240
244
|
import { useNews, useMySection } from '@axcode/axcloud-sdk';
|
|
241
245
|
|
|
242
246
|
function SectionNews() {
|
|
243
|
-
const {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const { data: sectionNews } = useNews({ sectionId });
|
|
247
|
-
|
|
248
|
-
// Or fetch all organization news
|
|
249
|
-
const { data: allNews } = useNews();
|
|
247
|
+
const { section } = useMySection();
|
|
248
|
+
// AxCloud derives the allowed sections from the authenticated membership.
|
|
249
|
+
const { data: visibleNews } = useNews();
|
|
250
250
|
|
|
251
251
|
return (
|
|
252
252
|
<div>
|
|
253
253
|
<h2>Section News</h2>
|
|
254
|
-
{
|
|
255
|
-
<NewsCard key={item.id} item={item} />
|
|
256
|
-
))}
|
|
257
|
-
|
|
258
|
-
<h2>All Organization News</h2>
|
|
259
|
-
{allNews.map((item) => (
|
|
254
|
+
{visibleNews.map((item) => (
|
|
260
255
|
<NewsCard key={item.id} item={item} />
|
|
261
256
|
))}
|
|
257
|
+
{!section && <p>You are not assigned to a section.</p>}
|
|
262
258
|
</div>
|
|
263
259
|
);
|
|
264
260
|
}
|
|
@@ -360,10 +356,13 @@ function Dashboard() {
|
|
|
360
356
|
| Hook | Description |
|
|
361
357
|
| --------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
362
358
|
| `useAuth()` | Login/logout, email-verification state, resend, and profile refresh |
|
|
363
|
-
| `useUser()` | Fetch
|
|
359
|
+
| `useUser()` | Fetch the normalized user and verified organization membership |
|
|
360
|
+
| `useUpdateMyProfile()` | Update the signed-in user's name, phone, and address |
|
|
364
361
|
| `useOrg()` | Fetch organization info and check modules |
|
|
365
|
-
| `useNews(options?)` | Fetch
|
|
366
|
-
| `useContent(type, options?)` | Fetch
|
|
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 |
|
|
367
366
|
| `useMySection()` | Fetch current user's section with members |
|
|
368
367
|
| `useSections()` | Fetch all organization sections |
|
|
369
368
|
| `useBranding()` | Fetch organization branding (logo, colors) |
|
|
@@ -374,24 +373,70 @@ function Dashboard() {
|
|
|
374
373
|
| `useDocuments(options?)` | List published public documents |
|
|
375
374
|
| `useDocumentDownload(documentId)` | Fetch a signed document download URL |
|
|
376
375
|
|
|
376
|
+
Profile self-service is deliberately limited to personal contact fields. Organization title,
|
|
377
|
+
email, roles, status, organization, and section assignments remain administrator-managed.
|
|
378
|
+
|
|
379
|
+
`useUser()` normalizes the API response to camelCase. Organization-specific values always come
|
|
380
|
+
from the membership for the provider's `orgId`:
|
|
381
|
+
|
|
382
|
+
```tsx
|
|
383
|
+
const {
|
|
384
|
+
user,
|
|
385
|
+
roleInOrg,
|
|
386
|
+
title,
|
|
387
|
+
section, // { id, name, role } | null
|
|
388
|
+
sections, // all verified section memberships
|
|
389
|
+
sectionId,
|
|
390
|
+
sectionIds,
|
|
391
|
+
memberSince, // normalized from joined_at
|
|
392
|
+
} = useUser();
|
|
393
|
+
|
|
394
|
+
return <p>{section?.name ?? 'No section'} · member since {memberSince}</p>;
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
```tsx
|
|
398
|
+
import { useUpdateMyProfile } from '@axcode/axcloud-sdk';
|
|
399
|
+
|
|
400
|
+
function ProfileForm() {
|
|
401
|
+
const updateProfile = useUpdateMyProfile();
|
|
402
|
+
|
|
403
|
+
const save = () => updateProfile.mutateAsync({
|
|
404
|
+
firstName: 'Anna',
|
|
405
|
+
lastName: 'Pilot',
|
|
406
|
+
phone: '+46701234567',
|
|
407
|
+
address: 'Flyggatan 1',
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
return <button onClick={save} disabled={updateProfile.isPending}>Save profile</button>;
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
377
414
|
### Content Query Options
|
|
378
415
|
|
|
379
416
|
```typescript
|
|
380
417
|
interface ContentQueryOptions {
|
|
381
418
|
page?: number; // Page number (default: 1)
|
|
382
419
|
pageSize?: number; // Items per page (default: 20)
|
|
383
|
-
status?: 'draft' | 'published' | 'archived';
|
|
384
|
-
visibility?: 'draft' | 'published' | 'archived';
|
|
385
|
-
audience?: 'public' | 'internal' | 'members' | 'section';
|
|
386
|
-
sectionId?: string; // Filter by specific section
|
|
387
420
|
search?: string; // Search in title/content
|
|
388
|
-
sortBy?:
|
|
421
|
+
sortBy?: 'publishedAt' | 'createdAt' | 'updatedAt' | 'title';
|
|
389
422
|
sortOrder?: 'asc' | 'desc';
|
|
423
|
+
tags?: string[];
|
|
390
424
|
lang?: string; // Return translated title/slug/blocks when available
|
|
391
425
|
publicOnly?: boolean; // Force public endpoint even when authenticated
|
|
392
426
|
}
|
|
393
427
|
```
|
|
394
428
|
|
|
429
|
+
Collection hooks return `data`, `count`, `total`, `page`, `pageSize`,
|
|
430
|
+
`hasMore`, `nextCursor`, `isLoading`, `isFetching`, `isError`, `error` and
|
|
431
|
+
`refetch`. During Auth0's initial session check, member-capable hooks wait
|
|
432
|
+
instead of briefly requesting public content. Member caches are isolated per
|
|
433
|
+
Auth0 subject and removed on logout or account change.
|
|
434
|
+
All other identity-bound AxCloud query data is removed at the same boundary.
|
|
435
|
+
|
|
436
|
+
Structured slots are untrusted CMS input. Prefer `text()`, `list()` and
|
|
437
|
+
`image()`. `unsafeHtml()` (and the deprecated `html()` alias) must be sanitized
|
|
438
|
+
before use with `dangerouslySetInnerHTML`.
|
|
439
|
+
|
|
395
440
|
### Components
|
|
396
441
|
|
|
397
442
|
| Component | Description |
|
package/dist/index.d.mts
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
|
-
|
|
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
|
|
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?:
|
|
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
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
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:
|
|
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
|
-
*
|
|
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
|
-
*
|
|
1277
|
-
*
|
|
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<
|
|
1341
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ContentListResponse<NewsItem>, Error>>;
|
|
1293
1342
|
};
|
|
1294
1343
|
|
|
1295
1344
|
/**
|
|
1296
|
-
*
|
|
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
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
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<
|
|
1363
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ContentListResponse<T>, Error>>;
|
|
1326
1364
|
};
|
|
1327
1365
|
interface ContentItemOptions {
|
|
1328
|
-
/** Force public
|
|
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
|
-
*
|
|
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
|
|
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 };
|