@flexbe/sdk 0.2.1 → 0.2.3

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
@@ -16,23 +16,15 @@ import { FlexbeClient } from '@flexbe/sdk';
16
16
  // Initialize the client with API Key authentication
17
17
  const client = new FlexbeClient({
18
18
  apiKey: 'your-api-key',
19
- siteId: 'your-site-id', // optional, required for site-specific endpoints
20
19
  baseUrl: 'https://api.flexbe.com', // optional
21
20
  timeout: 30000, // optional, defaults to 30 seconds
22
21
  });
22
+ const siteApi = client.getSiteApi(SITE_ID)
23
23
 
24
- // Or initialize with JWT Bearer token authentication
25
- const client = new FlexbeClient({
26
- authType: 'bearer',
27
- siteId: 'your-site-id', // optional, required for site-specific endpoints
28
- baseUrl: 'https://api.flexbe.com', // optional
29
- timeout: 30000, // optional, defaults to 30 seconds
30
- });
31
-
32
- // Using the Pages API
24
+ // Using the Pages API for a specific site
33
25
  try {
34
- // Get list of pages
35
- const pages = await client.pages.getPages({
26
+ // Get list of pages for site
27
+ const pages = await siteApi.pages.getPages({
36
28
  limit: 10,
37
29
  offset: 0,
38
30
  type: 'page',
@@ -40,8 +32,8 @@ try {
40
32
  });
41
33
  console.log(pages.pages);
42
34
 
43
- // Get a single page
44
- const page = await client.pages.getPage(123);
35
+ // Get a single page from site
36
+ const page = await siteApi.pages.getPage(123);
45
37
  console.log(page);
46
38
  } catch (error) {
47
39
  console.error(error.message);
@@ -58,7 +50,7 @@ try {
58
50
  - Automatic error handling
59
51
  - Configurable timeout and base URL
60
52
  - Native fetch API support (works in both Node.js and browser)
61
- - Site-specific endpoints support
53
+ - Multi-site support with site-specific API instances
62
54
  - Query parameter handling
63
55
  - Request timeout handling
64
56
  - Token sharing between browser tabs (for JWT authentication)
@@ -68,7 +60,6 @@ try {
68
60
  The SDK supports the following environment variables:
69
61
  - `FLEXBE_API_KEY`: Your API key (required for API Key authentication)
70
62
  - `FLEXBE_API_URL`: Base URL (defaults to 'https://api.flexbe.com')
71
- - `FLEXBE_SITE_ID`: Your site ID
72
63
 
73
64
  ## Development
74
65
 
@@ -13,14 +13,7 @@ export class ApiClient {
13
13
  this.config = config;
14
14
  this.auth = new FlexbeAuth(config);
15
15
  }
16
- replaceSiteId(url) {
17
- if (!this.config.siteId) {
18
- return url;
19
- }
20
- return url.replace(/:siteId:/g, this.config.siteId);
21
- }
22
16
  buildUrl(path, params) {
23
- const processedPath = this.replaceSiteId(path);
24
17
  const searchParams = new URLSearchParams();
25
18
  if (params) {
26
19
  Object.entries(params).forEach(([key, value]) => {
@@ -29,7 +22,7 @@ export class ApiClient {
29
22
  }
30
23
  });
31
24
  }
32
- return `${processedPath}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
25
+ return `${path}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
33
26
  }
34
27
  request(config) {
35
28
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,8 +1,9 @@
1
1
  import { FlexbeAuthType } from '../types';
2
- import { Pages } from './pages';
3
2
  import { ApiClient } from './api-client';
3
+ import { SiteApi } from './site-api';
4
4
  export class FlexbeClient {
5
5
  constructor(config) {
6
+ this.siteApis = new Map();
6
7
  const getEnvVar = (key) => {
7
8
  if (typeof process !== 'undefined' && process.env) {
8
9
  return process.env[key];
@@ -13,13 +14,24 @@ export class FlexbeClient {
13
14
  baseUrl: (config === null || config === void 0 ? void 0 : config.baseUrl) || getEnvVar('FLEXBE_API_URL') || 'https://api.flexbe.com',
14
15
  timeout: (config === null || config === void 0 ? void 0 : config.timeout) || 30000,
15
16
  apiKey: (config === null || config === void 0 ? void 0 : config.apiKey) || getEnvVar('FLEXBE_API_KEY') || '',
16
- siteId: (config === null || config === void 0 ? void 0 : config.siteId) || getEnvVar('FLEXBE_SITE_ID'),
17
17
  authType: (config === null || config === void 0 ? void 0 : config.authType) || FlexbeAuthType.API_KEY,
18
18
  };
19
19
  if (this.config.authType === 'apiKey' && !this.config.apiKey) {
20
20
  throw new Error('API key is required when using apiKey authentication. Please provide it either through config or FLEXBE_API_KEY environment variable.');
21
21
  }
22
22
  this.api = new ApiClient(this.config);
23
- this.pages = new Pages(this.api);
23
+ }
24
+ /**
25
+ * Get a SiteApi instance for a specific site
26
+ * @param siteId - The ID of the site to get an API instance for
27
+ * @returns A SiteApi instance for the specified site
28
+ */
29
+ getSiteApi(siteId) {
30
+ let siteApi = this.siteApis.get(siteId);
31
+ if (!siteApi) {
32
+ siteApi = new SiteApi(this.api, siteId);
33
+ this.siteApis.set(siteId, siteApi);
34
+ }
35
+ return siteApi;
24
36
  }
25
37
  }
@@ -8,8 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  export class Pages {
11
- constructor(api) {
11
+ constructor(api, siteId) {
12
12
  this.api = api;
13
+ this.siteId = siteId;
13
14
  }
14
15
  /**
15
16
  * Get list of pages for a site
@@ -24,7 +25,7 @@ export class Pages {
24
25
  */
25
26
  getPages(params) {
26
27
  return __awaiter(this, void 0, void 0, function* () {
27
- const response = yield this.api.get('/sites/:siteId:/pages', { params });
28
+ const response = yield this.api.get(`/sites/${this.siteId}/pages`, { params });
28
29
  return response.data;
29
30
  });
30
31
  }
@@ -33,7 +34,7 @@ export class Pages {
33
34
  */
34
35
  getPage(pageId) {
35
36
  return __awaiter(this, void 0, void 0, function* () {
36
- const response = yield this.api.get(`/sites/:siteId:/pages/${pageId}`);
37
+ const response = yield this.api.get(`/sites/${this.siteId}/pages/${pageId}`);
37
38
  return response.data;
38
39
  });
39
40
  }
@@ -42,7 +43,7 @@ export class Pages {
42
43
  */
43
44
  getFolders() {
44
45
  return __awaiter(this, void 0, void 0, function* () {
45
- const response = yield this.api.get('/sites/:siteId:/pages-folders');
46
+ const response = yield this.api.get(`/sites/${this.siteId}/pages-folders`);
46
47
  return response.data;
47
48
  });
48
49
  }
@@ -51,7 +52,7 @@ export class Pages {
51
52
  */
52
53
  getFolder(folderId) {
53
54
  return __awaiter(this, void 0, void 0, function* () {
54
- const response = yield this.api.get(`/sites/:siteId:/pages-folders/${folderId}`);
55
+ const response = yield this.api.get(`/sites/${this.siteId}/pages-folders/${folderId}`);
55
56
  return response.data;
56
57
  });
57
58
  }
@@ -64,7 +65,7 @@ export class Pages {
64
65
  */
65
66
  updateFolder(folderId, data) {
66
67
  return __awaiter(this, void 0, void 0, function* () {
67
- const response = yield this.api.patch(`/sites/:siteId:/pages-folders/${folderId}`, data);
68
+ const response = yield this.api.patch(`/sites/${this.siteId}/pages-folders/${folderId}`, data);
68
69
  return response.data;
69
70
  });
70
71
  }
@@ -76,7 +77,7 @@ export class Pages {
76
77
  */
77
78
  createFolder(data) {
78
79
  return __awaiter(this, void 0, void 0, function* () {
79
- const response = yield this.api.post('/sites/:siteId:/pages-folders', data);
80
+ const response = yield this.api.post(`/sites/${this.siteId}/pages-folders`, data);
80
81
  return response.data;
81
82
  });
82
83
  }
@@ -87,7 +88,33 @@ export class Pages {
87
88
  */
88
89
  deleteFolder(folderId) {
89
90
  return __awaiter(this, void 0, void 0, function* () {
90
- yield this.api.delete(`/sites/:siteId:/pages-folders/${folderId}`);
91
+ yield this.api.delete(`/sites/${this.siteId}/pages-folders/${folderId}`);
92
+ });
93
+ }
94
+ /**
95
+ * Update a page's properties
96
+ * @param pageId - ID of the page to update
97
+ * @param data - Update parameters including:
98
+ * - status: New status for the page
99
+ * - name: New name for the page
100
+ * - uri: New URI for the page
101
+ * - language: New language for the page
102
+ * - folderId: New folder ID for the page
103
+ * - sortIndex: New position in the page list
104
+ * - meta: Meta information for the page:
105
+ * - title: Page title
106
+ * - description: Meta description for SEO
107
+ * - keywords: Meta keywords for SEO
108
+ * - ogImage: Open Graph image URL for social sharing
109
+ * - ogTitle: Open Graph title for social sharing
110
+ * - ogDescription: Open Graph description for social sharing
111
+ * - noindex: Whether to prevent search engine indexing
112
+ * - grid: Grid configuration for the page
113
+ */
114
+ updatePage(pageId, data) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ const response = yield this.api.put(`/sites/${this.siteId}/pages/${pageId}`, data);
117
+ return response.data;
91
118
  });
92
119
  }
93
120
  }
@@ -0,0 +1,6 @@
1
+ import { Pages } from './pages';
2
+ export class SiteApi {
3
+ constructor(api, siteId) {
4
+ this.pages = new Pages(api, siteId);
5
+ }
6
+ }
@@ -7,14 +7,7 @@ class ApiClient {
7
7
  this.config = config;
8
8
  this.auth = new auth_1.FlexbeAuth(config);
9
9
  }
10
- replaceSiteId(url) {
11
- if (!this.config.siteId) {
12
- return url;
13
- }
14
- return url.replace(/:siteId:/g, this.config.siteId);
15
- }
16
10
  buildUrl(path, params) {
17
- const processedPath = this.replaceSiteId(path);
18
11
  const searchParams = new URLSearchParams();
19
12
  if (params) {
20
13
  Object.entries(params).forEach(([key, value]) => {
@@ -23,7 +16,7 @@ class ApiClient {
23
16
  }
24
17
  });
25
18
  }
26
- return `${processedPath}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
19
+ return `${path}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
27
20
  }
28
21
  async request(config) {
29
22
  try {
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlexbeClient = void 0;
4
4
  const types_1 = require("../types");
5
- const pages_1 = require("./pages");
6
5
  const api_client_1 = require("./api-client");
6
+ const site_api_1 = require("./site-api");
7
7
  class FlexbeClient {
8
8
  constructor(config) {
9
+ this.siteApis = new Map();
9
10
  const getEnvVar = (key) => {
10
11
  if (typeof process !== 'undefined' && process.env) {
11
12
  return process.env[key];
@@ -16,14 +17,25 @@ class FlexbeClient {
16
17
  baseUrl: config?.baseUrl || getEnvVar('FLEXBE_API_URL') || 'https://api.flexbe.com',
17
18
  timeout: config?.timeout || 30000,
18
19
  apiKey: config?.apiKey || getEnvVar('FLEXBE_API_KEY') || '',
19
- siteId: config?.siteId || getEnvVar('FLEXBE_SITE_ID'),
20
20
  authType: config?.authType || types_1.FlexbeAuthType.API_KEY,
21
21
  };
22
22
  if (this.config.authType === 'apiKey' && !this.config.apiKey) {
23
23
  throw new Error('API key is required when using apiKey authentication. Please provide it either through config or FLEXBE_API_KEY environment variable.');
24
24
  }
25
25
  this.api = new api_client_1.ApiClient(this.config);
26
- this.pages = new pages_1.Pages(this.api);
26
+ }
27
+ /**
28
+ * Get a SiteApi instance for a specific site
29
+ * @param siteId - The ID of the site to get an API instance for
30
+ * @returns A SiteApi instance for the specified site
31
+ */
32
+ getSiteApi(siteId) {
33
+ let siteApi = this.siteApis.get(siteId);
34
+ if (!siteApi) {
35
+ siteApi = new site_api_1.SiteApi(this.api, siteId);
36
+ this.siteApis.set(siteId, siteApi);
37
+ }
38
+ return siteApi;
27
39
  }
28
40
  }
29
41
  exports.FlexbeClient = FlexbeClient;
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Pages = void 0;
4
4
  class Pages {
5
- constructor(api) {
5
+ constructor(api, siteId) {
6
6
  this.api = api;
7
+ this.siteId = siteId;
7
8
  }
8
9
  /**
9
10
  * Get list of pages for a site
@@ -17,28 +18,28 @@ class Pages {
17
18
  * - folderId: Filter by folder ID
18
19
  */
19
20
  async getPages(params) {
20
- const response = await this.api.get('/sites/:siteId:/pages', { params });
21
+ const response = await this.api.get(`/sites/${this.siteId}/pages`, { params });
21
22
  return response.data;
22
23
  }
23
24
  /**
24
25
  * Get a single page by ID
25
26
  */
26
27
  async getPage(pageId) {
27
- const response = await this.api.get(`/sites/:siteId:/pages/${pageId}`);
28
+ const response = await this.api.get(`/sites/${this.siteId}/pages/${pageId}`);
28
29
  return response.data;
29
30
  }
30
31
  /**
31
32
  * Get list of folders for a site
32
33
  */
33
34
  async getFolders() {
34
- const response = await this.api.get('/sites/:siteId:/pages-folders');
35
+ const response = await this.api.get(`/sites/${this.siteId}/pages-folders`);
35
36
  return response.data;
36
37
  }
37
38
  /**
38
39
  * Get a single folder by ID
39
40
  */
40
41
  async getFolder(folderId) {
41
- const response = await this.api.get(`/sites/:siteId:/pages-folders/${folderId}`);
42
+ const response = await this.api.get(`/sites/${this.siteId}/pages-folders/${folderId}`);
42
43
  return response.data;
43
44
  }
44
45
  /**
@@ -49,7 +50,7 @@ class Pages {
49
50
  * - sortIndex: New position in the folder list
50
51
  */
51
52
  async updateFolder(folderId, data) {
52
- const response = await this.api.patch(`/sites/:siteId:/pages-folders/${folderId}`, data);
53
+ const response = await this.api.patch(`/sites/${this.siteId}/pages-folders/${folderId}`, data);
53
54
  return response.data;
54
55
  }
55
56
  /**
@@ -59,7 +60,7 @@ class Pages {
59
60
  * - sortIndex: Position in the folder list (optional)
60
61
  */
61
62
  async createFolder(data) {
62
- const response = await this.api.post('/sites/:siteId:/pages-folders', data);
63
+ const response = await this.api.post(`/sites/${this.siteId}/pages-folders`, data);
63
64
  return response.data;
64
65
  }
65
66
  /**
@@ -68,7 +69,31 @@ class Pages {
68
69
  * @throws {ForbiddenException} When the folder does not belong to the site
69
70
  */
70
71
  async deleteFolder(folderId) {
71
- await this.api.delete(`/sites/:siteId:/pages-folders/${folderId}`);
72
+ await this.api.delete(`/sites/${this.siteId}/pages-folders/${folderId}`);
73
+ }
74
+ /**
75
+ * Update a page's properties
76
+ * @param pageId - ID of the page to update
77
+ * @param data - Update parameters including:
78
+ * - status: New status for the page
79
+ * - name: New name for the page
80
+ * - uri: New URI for the page
81
+ * - language: New language for the page
82
+ * - folderId: New folder ID for the page
83
+ * - sortIndex: New position in the page list
84
+ * - meta: Meta information for the page:
85
+ * - title: Page title
86
+ * - description: Meta description for SEO
87
+ * - keywords: Meta keywords for SEO
88
+ * - ogImage: Open Graph image URL for social sharing
89
+ * - ogTitle: Open Graph title for social sharing
90
+ * - ogDescription: Open Graph description for social sharing
91
+ * - noindex: Whether to prevent search engine indexing
92
+ * - grid: Grid configuration for the page
93
+ */
94
+ async updatePage(pageId, data) {
95
+ const response = await this.api.put(`/sites/${this.siteId}/pages/${pageId}`, data);
96
+ return response.data;
72
97
  }
73
98
  }
74
99
  exports.Pages = Pages;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SiteApi = void 0;
4
+ const pages_1 = require("./pages");
5
+ class SiteApi {
6
+ constructor(api, siteId) {
7
+ this.pages = new pages_1.Pages(api, siteId);
8
+ }
9
+ }
10
+ exports.SiteApi = SiteApi;
@@ -4,14 +4,7 @@ export class ApiClient {
4
4
  this.config = config;
5
5
  this.auth = new FlexbeAuth(config);
6
6
  }
7
- replaceSiteId(url) {
8
- if (!this.config.siteId) {
9
- return url;
10
- }
11
- return url.replace(/:siteId:/g, this.config.siteId);
12
- }
13
7
  buildUrl(path, params) {
14
- const processedPath = this.replaceSiteId(path);
15
8
  const searchParams = new URLSearchParams();
16
9
  if (params) {
17
10
  Object.entries(params).forEach(([key, value]) => {
@@ -20,7 +13,7 @@ export class ApiClient {
20
13
  }
21
14
  });
22
15
  }
23
- return `${processedPath}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
16
+ return `${path}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
24
17
  }
25
18
  async request(config) {
26
19
  try {
@@ -1,8 +1,9 @@
1
1
  import { FlexbeAuthType } from '../types';
2
- import { Pages } from './pages';
3
2
  import { ApiClient } from './api-client';
3
+ import { SiteApi } from './site-api';
4
4
  export class FlexbeClient {
5
5
  constructor(config) {
6
+ this.siteApis = new Map();
6
7
  const getEnvVar = (key) => {
7
8
  if (typeof process !== 'undefined' && process.env) {
8
9
  return process.env[key];
@@ -13,13 +14,24 @@ export class FlexbeClient {
13
14
  baseUrl: config?.baseUrl || getEnvVar('FLEXBE_API_URL') || 'https://api.flexbe.com',
14
15
  timeout: config?.timeout || 30000,
15
16
  apiKey: config?.apiKey || getEnvVar('FLEXBE_API_KEY') || '',
16
- siteId: config?.siteId || getEnvVar('FLEXBE_SITE_ID'),
17
17
  authType: config?.authType || FlexbeAuthType.API_KEY,
18
18
  };
19
19
  if (this.config.authType === 'apiKey' && !this.config.apiKey) {
20
20
  throw new Error('API key is required when using apiKey authentication. Please provide it either through config or FLEXBE_API_KEY environment variable.');
21
21
  }
22
22
  this.api = new ApiClient(this.config);
23
- this.pages = new Pages(this.api);
23
+ }
24
+ /**
25
+ * Get a SiteApi instance for a specific site
26
+ * @param siteId - The ID of the site to get an API instance for
27
+ * @returns A SiteApi instance for the specified site
28
+ */
29
+ getSiteApi(siteId) {
30
+ let siteApi = this.siteApis.get(siteId);
31
+ if (!siteApi) {
32
+ siteApi = new SiteApi(this.api, siteId);
33
+ this.siteApis.set(siteId, siteApi);
34
+ }
35
+ return siteApi;
24
36
  }
25
37
  }
@@ -1,6 +1,7 @@
1
1
  export class Pages {
2
- constructor(api) {
2
+ constructor(api, siteId) {
3
3
  this.api = api;
4
+ this.siteId = siteId;
4
5
  }
5
6
  /**
6
7
  * Get list of pages for a site
@@ -14,28 +15,28 @@ export class Pages {
14
15
  * - folderId: Filter by folder ID
15
16
  */
16
17
  async getPages(params) {
17
- const response = await this.api.get('/sites/:siteId:/pages', { params });
18
+ const response = await this.api.get(`/sites/${this.siteId}/pages`, { params });
18
19
  return response.data;
19
20
  }
20
21
  /**
21
22
  * Get a single page by ID
22
23
  */
23
24
  async getPage(pageId) {
24
- const response = await this.api.get(`/sites/:siteId:/pages/${pageId}`);
25
+ const response = await this.api.get(`/sites/${this.siteId}/pages/${pageId}`);
25
26
  return response.data;
26
27
  }
27
28
  /**
28
29
  * Get list of folders for a site
29
30
  */
30
31
  async getFolders() {
31
- const response = await this.api.get('/sites/:siteId:/pages-folders');
32
+ const response = await this.api.get(`/sites/${this.siteId}/pages-folders`);
32
33
  return response.data;
33
34
  }
34
35
  /**
35
36
  * Get a single folder by ID
36
37
  */
37
38
  async getFolder(folderId) {
38
- const response = await this.api.get(`/sites/:siteId:/pages-folders/${folderId}`);
39
+ const response = await this.api.get(`/sites/${this.siteId}/pages-folders/${folderId}`);
39
40
  return response.data;
40
41
  }
41
42
  /**
@@ -46,7 +47,7 @@ export class Pages {
46
47
  * - sortIndex: New position in the folder list
47
48
  */
48
49
  async updateFolder(folderId, data) {
49
- const response = await this.api.patch(`/sites/:siteId:/pages-folders/${folderId}`, data);
50
+ const response = await this.api.patch(`/sites/${this.siteId}/pages-folders/${folderId}`, data);
50
51
  return response.data;
51
52
  }
52
53
  /**
@@ -56,7 +57,7 @@ export class Pages {
56
57
  * - sortIndex: Position in the folder list (optional)
57
58
  */
58
59
  async createFolder(data) {
59
- const response = await this.api.post('/sites/:siteId:/pages-folders', data);
60
+ const response = await this.api.post(`/sites/${this.siteId}/pages-folders`, data);
60
61
  return response.data;
61
62
  }
62
63
  /**
@@ -65,6 +66,30 @@ export class Pages {
65
66
  * @throws {ForbiddenException} When the folder does not belong to the site
66
67
  */
67
68
  async deleteFolder(folderId) {
68
- await this.api.delete(`/sites/:siteId:/pages-folders/${folderId}`);
69
+ await this.api.delete(`/sites/${this.siteId}/pages-folders/${folderId}`);
70
+ }
71
+ /**
72
+ * Update a page's properties
73
+ * @param pageId - ID of the page to update
74
+ * @param data - Update parameters including:
75
+ * - status: New status for the page
76
+ * - name: New name for the page
77
+ * - uri: New URI for the page
78
+ * - language: New language for the page
79
+ * - folderId: New folder ID for the page
80
+ * - sortIndex: New position in the page list
81
+ * - meta: Meta information for the page:
82
+ * - title: Page title
83
+ * - description: Meta description for SEO
84
+ * - keywords: Meta keywords for SEO
85
+ * - ogImage: Open Graph image URL for social sharing
86
+ * - ogTitle: Open Graph title for social sharing
87
+ * - ogDescription: Open Graph description for social sharing
88
+ * - noindex: Whether to prevent search engine indexing
89
+ * - grid: Grid configuration for the page
90
+ */
91
+ async updatePage(pageId, data) {
92
+ const response = await this.api.put(`/sites/${this.siteId}/pages/${pageId}`, data);
93
+ return response.data;
69
94
  }
70
95
  }
@@ -0,0 +1,6 @@
1
+ import { Pages } from './pages';
2
+ export class SiteApi {
3
+ constructor(api, siteId) {
4
+ this.pages = new Pages(api, siteId);
5
+ }
6
+ }
@@ -3,7 +3,6 @@ export declare class ApiClient {
3
3
  private readonly config;
4
4
  private readonly auth;
5
5
  constructor(config: FlexbeConfig);
6
- private replaceSiteId;
7
6
  private buildUrl;
8
7
  private request;
9
8
  get<T>(url: string, config?: RequestInit & {
@@ -1,9 +1,14 @@
1
1
  import { FlexbeConfig } from '../types';
2
- import { Pages } from './pages';
3
- import { ApiClient } from './api-client';
2
+ import { SiteApi } from './site-api';
4
3
  export declare class FlexbeClient {
5
4
  private readonly config;
6
- readonly pages: Pages;
7
- readonly api: ApiClient;
5
+ private readonly api;
6
+ private readonly siteApis;
8
7
  constructor(config?: Partial<FlexbeConfig>);
8
+ /**
9
+ * Get a SiteApi instance for a specific site
10
+ * @param siteId - The ID of the site to get an API instance for
11
+ * @returns A SiteApi instance for the specified site
12
+ */
13
+ getSiteApi(siteId: number): SiteApi;
9
14
  }
@@ -1,8 +1,9 @@
1
- import { Page, GetPagesParams, PageListResponse, PageFolder, PageFolderListResponse, UpdateFolderParams, CreateFolderParams } from '../types/pages';
1
+ import { Page, GetPagesParams, PageListResponse, PageFolder, PageFolderListResponse, UpdateFolderParams, CreateFolderParams, UpdatePageParams } from '../types/pages';
2
2
  import { ApiClient } from './api-client';
3
3
  export declare class Pages {
4
4
  private readonly api;
5
- constructor(api: ApiClient);
5
+ private readonly siteId;
6
+ constructor(api: ApiClient, siteId: number);
6
7
  /**
7
8
  * Get list of pages for a site
8
9
  * @param params - Query parameters including:
@@ -48,4 +49,25 @@ export declare class Pages {
48
49
  * @throws {ForbiddenException} When the folder does not belong to the site
49
50
  */
50
51
  deleteFolder(folderId: number): Promise<void>;
52
+ /**
53
+ * Update a page's properties
54
+ * @param pageId - ID of the page to update
55
+ * @param data - Update parameters including:
56
+ * - status: New status for the page
57
+ * - name: New name for the page
58
+ * - uri: New URI for the page
59
+ * - language: New language for the page
60
+ * - folderId: New folder ID for the page
61
+ * - sortIndex: New position in the page list
62
+ * - meta: Meta information for the page:
63
+ * - title: Page title
64
+ * - description: Meta description for SEO
65
+ * - keywords: Meta keywords for SEO
66
+ * - ogImage: Open Graph image URL for social sharing
67
+ * - ogTitle: Open Graph title for social sharing
68
+ * - ogDescription: Open Graph description for social sharing
69
+ * - noindex: Whether to prevent search engine indexing
70
+ * - grid: Grid configuration for the page
71
+ */
72
+ updatePage(pageId: number, data: UpdatePageParams): Promise<Page>;
51
73
  }
@@ -0,0 +1,6 @@
1
+ import { ApiClient } from './api-client';
2
+ import { Pages } from './pages';
3
+ export declare class SiteApi {
4
+ readonly pages: Pages;
5
+ constructor(api: ApiClient, siteId: number);
6
+ }
@@ -67,7 +67,7 @@ export interface GetPagesParams {
67
67
  folderId?: number;
68
68
  }
69
69
  export interface PageListResponse {
70
- pages: Page[];
70
+ list: Page[];
71
71
  pagination: Pagination;
72
72
  }
73
73
  export interface PageFolder {
@@ -76,7 +76,7 @@ export interface PageFolder {
76
76
  sortIndex: number;
77
77
  }
78
78
  export interface PageFolderListResponse {
79
- folders: PageFolder[];
79
+ list: PageFolder[];
80
80
  }
81
81
  export interface UpdateFolderParams {
82
82
  title?: string;
@@ -86,3 +86,35 @@ export interface CreateFolderParams {
86
86
  title: string;
87
87
  sortIndex?: number;
88
88
  }
89
+ export interface UpdatePageParams {
90
+ status?: PageStatus;
91
+ name?: string;
92
+ uri?: string;
93
+ language?: string;
94
+ folderId?: number;
95
+ sortIndex?: number;
96
+ meta?: {
97
+ title?: string;
98
+ description?: string;
99
+ keywords?: string;
100
+ ogImage?: string;
101
+ ogTitle?: string;
102
+ ogDescription?: string;
103
+ noindex?: boolean;
104
+ };
105
+ grid?: {
106
+ color?: string;
107
+ desktop?: {
108
+ columns: number;
109
+ containerWidth: number;
110
+ columnWidth: number;
111
+ gap: number;
112
+ };
113
+ mobile?: {
114
+ columns: number;
115
+ containerWidth: number;
116
+ columnWidth: number;
117
+ gap: number;
118
+ };
119
+ };
120
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexbe/sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "TypeScript SDK for Flexbe API",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",