@flexbe/sdk 0.1.0

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.
Files changed (41) hide show
  1. package/README.md +80 -0
  2. package/dist/browser/client/client.js +109 -0
  3. package/dist/browser/client/pages.js +32 -0
  4. package/dist/browser/index.js +4 -0
  5. package/dist/browser/types/index.js +1 -0
  6. package/dist/browser/types/pages.js +16 -0
  7. package/dist/cjs/client/client.js +110 -0
  8. package/dist/cjs/client/pages.js +23 -0
  9. package/dist/cjs/index.js +20 -0
  10. package/dist/cjs/types/index.js +2 -0
  11. package/dist/cjs/types/pages.js +19 -0
  12. package/dist/client/flexbe-client.d.ts +13 -0
  13. package/dist/client/flexbe-client.js +62 -0
  14. package/dist/esm/client/client.js +106 -0
  15. package/dist/esm/client/pages.js +19 -0
  16. package/dist/esm/index.js +4 -0
  17. package/dist/esm/types/index.js +1 -0
  18. package/dist/esm/types/pages.js +16 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +18 -0
  21. package/dist/src/client/flexbe-client.d.ts +20 -0
  22. package/dist/src/client/flexbe-client.js +86 -0
  23. package/dist/src/client/pages-client.d.ts +14 -0
  24. package/dist/src/client/pages-client.js +23 -0
  25. package/dist/src/index.d.ts +4 -0
  26. package/dist/src/index.js +20 -0
  27. package/dist/src/types/index.d.ts +23 -0
  28. package/dist/src/types/index.js +2 -0
  29. package/dist/src/types/pages.d.ts +41 -0
  30. package/dist/src/types/pages.js +19 -0
  31. package/dist/test/client/flexbe-client.test.d.ts +1 -0
  32. package/dist/test/client/flexbe-client.test.js +38 -0
  33. package/dist/test/client/pages-client.test.d.ts +1 -0
  34. package/dist/test/client/pages-client.test.js +82 -0
  35. package/dist/types/client/client.d.ts +26 -0
  36. package/dist/types/client/pages.d.ts +14 -0
  37. package/dist/types/index.d.ts +4 -0
  38. package/dist/types/index.js +2 -0
  39. package/dist/types/types/index.d.ts +23 -0
  40. package/dist/types/types/pages.d.ts +41 -0
  41. package/package.json +67 -0
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # Flexbe TypeScript SDK
2
+
3
+ A TypeScript SDK for interacting with the Flexbe API. Works in both Node.js and browser environments.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @flexbe/sdk-ts
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { FlexbeClient } from '@flexbe/sdk-ts';
15
+
16
+ // Initialize the client
17
+ const client = new FlexbeClient({
18
+ apiKey: 'your-api-key',
19
+ siteId: 'your-site-id', // optional, required for site-specific endpoints
20
+ baseUrl: 'https://api.flexbe.com', // optional
21
+ timeout: 30000, // optional, defaults to 30 seconds
22
+ });
23
+
24
+ // Using the Pages API
25
+ try {
26
+ // Get list of pages
27
+ const pages = await client.pages.getPages({
28
+ limit: 10,
29
+ offset: 0,
30
+ type: 'page',
31
+ status: 'published'
32
+ });
33
+ console.log(pages.pages);
34
+
35
+ // Get a single page
36
+ const page = await client.pages.getPage(123);
37
+ console.log(page);
38
+ } catch (error) {
39
+ console.error(error.message);
40
+ }
41
+
42
+ ```
43
+
44
+ ## Features
45
+
46
+ - TypeScript support with full type definitions
47
+ - API Key authentication
48
+ - Automatic error handling
49
+ - Configurable timeout and base URL
50
+ - Native fetch API support (works in both Node.js and browser)
51
+ - Site-specific endpoints support
52
+ - Query parameter handling
53
+ - Request timeout handling
54
+
55
+ ## Environment Variables
56
+
57
+ The SDK supports the following environment variables:
58
+ - `FLEXBE_API_KEY`: Your API key
59
+ - `FLEXBE_API_URL`: Base URL (defaults to 'https://api.flexbe.com')
60
+ - `FLEXBE_SITE_ID`: Your site ID
61
+
62
+ ## Development
63
+
64
+ ```bash
65
+ # Install dependencies
66
+ npm install
67
+
68
+ # Build the SDK
69
+ npm run build
70
+
71
+ # Run tests
72
+ npm test
73
+
74
+ # Lint code
75
+ npm run lint
76
+ ```
77
+
78
+ ## License
79
+
80
+ MIT
@@ -0,0 +1,109 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Pages } from './pages';
11
+ export class FlexbeClient {
12
+ constructor(config) {
13
+ const getEnvVar = (key) => {
14
+ if (typeof process !== 'undefined' && process.env) {
15
+ return process.env[key];
16
+ }
17
+ return undefined;
18
+ };
19
+ this.config = {
20
+ baseUrl: (config === null || config === void 0 ? void 0 : config.baseUrl) || getEnvVar('FLEXBE_API_URL') || 'https://api.flexbe.com',
21
+ timeout: (config === null || config === void 0 ? void 0 : config.timeout) || 30000,
22
+ apiKey: (config === null || config === void 0 ? void 0 : config.apiKey) || getEnvVar('FLEXBE_API_KEY') || '',
23
+ siteId: (config === null || config === void 0 ? void 0 : config.siteId) || getEnvVar('FLEXBE_SITE_ID'),
24
+ };
25
+ if (!this.config.apiKey) {
26
+ throw new Error('API key is required. Please provide it either through config or FLEXBE_API_KEY environment variable.');
27
+ }
28
+ this.pages = new Pages(this);
29
+ }
30
+ buildUrl(path, params) {
31
+ const searchParams = new URLSearchParams();
32
+ if (params) {
33
+ Object.entries(params).forEach(([key, value]) => {
34
+ if (value !== undefined && value !== null) {
35
+ searchParams.append(key, String(value));
36
+ }
37
+ });
38
+ }
39
+ return `${path}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
40
+ }
41
+ request(config) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ const controller = new AbortController();
45
+ const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
46
+ const url = this.buildUrl(config.url, config.params);
47
+ const response = yield fetch(this.config.baseUrl + url, Object.assign(Object.assign({}, config), { headers: Object.assign({ 'Authorization': `Bearer ${this.config.apiKey}`, 'Content-Type': 'application/json' }, config.headers), signal: controller.signal }));
48
+ clearTimeout(timeoutId);
49
+ if (!response.ok) {
50
+ const defaultError = { message: response.statusText };
51
+ const errorData = yield response.json().catch(() => defaultError);
52
+ const error = {
53
+ message: errorData.message || response.statusText,
54
+ code: errorData.code,
55
+ status: response.status,
56
+ details: errorData.details,
57
+ };
58
+ throw error;
59
+ }
60
+ const data = yield response.json();
61
+ return {
62
+ data,
63
+ status: response.status,
64
+ statusText: response.statusText,
65
+ };
66
+ }
67
+ catch (error) {
68
+ if (error instanceof Error && error.name === 'AbortError') {
69
+ const timeoutError = {
70
+ message: 'Request timeout',
71
+ status: 408,
72
+ };
73
+ throw timeoutError;
74
+ }
75
+ throw error;
76
+ }
77
+ });
78
+ }
79
+ get(url, config) {
80
+ return this.request(Object.assign(Object.assign({}, config), { method: 'GET', url }));
81
+ }
82
+ post(url, data, config) {
83
+ return this.request(Object.assign(Object.assign({}, config), { method: 'POST', url, body: JSON.stringify(data) }));
84
+ }
85
+ put(url, data, config) {
86
+ return this.request(Object.assign(Object.assign({}, config), { method: 'PUT', url, body: JSON.stringify(data) }));
87
+ }
88
+ delete(url, config) {
89
+ return this.request(Object.assign(Object.assign({}, config), { method: 'DELETE', url }));
90
+ }
91
+ getSiteUrl(path) {
92
+ if (!this.config.siteId) {
93
+ return path;
94
+ }
95
+ return `/sites/${this.config.siteId}${path}`;
96
+ }
97
+ sitesGet(path, config) {
98
+ return this.get(this.getSiteUrl(path), config);
99
+ }
100
+ sitesPost(path, data, config) {
101
+ return this.post(this.getSiteUrl(path), data, config);
102
+ }
103
+ sitesPut(path, data, config) {
104
+ return this.put(this.getSiteUrl(path), data, config);
105
+ }
106
+ sitesDelete(path, config) {
107
+ return this.delete(this.getSiteUrl(path), config);
108
+ }
109
+ }
@@ -0,0 +1,32 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export class Pages {
11
+ constructor(client) {
12
+ this.client = client;
13
+ }
14
+ /**
15
+ * Get list of pages for a site
16
+ */
17
+ getPages(params) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const response = yield this.client.sitesGet('/pages', { params });
20
+ return response.data;
21
+ });
22
+ }
23
+ /**
24
+ * Get a single page by ID
25
+ */
26
+ getPage(pageId) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const response = yield this.client.sitesGet(`/pages/${pageId}`);
29
+ return response.data;
30
+ });
31
+ }
32
+ }
@@ -0,0 +1,4 @@
1
+ export * from './client/client';
2
+ export * from './client/pages';
3
+ export * from './types';
4
+ export * from './types/pages';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export var PageType;
2
+ (function (PageType) {
3
+ PageType["PAGE"] = "page";
4
+ PageType["FILE"] = "file";
5
+ PageType["GLOBAL"] = "global";
6
+ PageType["AI"] = "ai";
7
+ PageType["CMS"] = "cms";
8
+ PageType["ECOMMERCE_PRODUCT"] = "ecommerce_product";
9
+ PageType["ECOMMERCE_CATEGORY"] = "ecommerce_category";
10
+ })(PageType || (PageType = {}));
11
+ export var PageStatus;
12
+ (function (PageStatus) {
13
+ PageStatus["PUBLISHED"] = "published";
14
+ PageStatus["DRAFTED"] = "drafted";
15
+ PageStatus["DELETED"] = "deleted";
16
+ })(PageStatus || (PageStatus = {}));
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlexbeClient = void 0;
4
+ const pages_1 = require("./pages");
5
+ class FlexbeClient {
6
+ constructor(config) {
7
+ const getEnvVar = (key) => {
8
+ if (typeof process !== 'undefined' && process.env) {
9
+ return process.env[key];
10
+ }
11
+ return undefined;
12
+ };
13
+ this.config = {
14
+ baseUrl: config?.baseUrl || getEnvVar('FLEXBE_API_URL') || 'https://api.flexbe.com',
15
+ timeout: config?.timeout || 30000,
16
+ apiKey: config?.apiKey || getEnvVar('FLEXBE_API_KEY') || '',
17
+ siteId: config?.siteId || getEnvVar('FLEXBE_SITE_ID'),
18
+ };
19
+ if (!this.config.apiKey) {
20
+ throw new Error('API key is required. Please provide it either through config or FLEXBE_API_KEY environment variable.');
21
+ }
22
+ this.pages = new pages_1.Pages(this);
23
+ }
24
+ buildUrl(path, params) {
25
+ const searchParams = new URLSearchParams();
26
+ if (params) {
27
+ Object.entries(params).forEach(([key, value]) => {
28
+ if (value !== undefined && value !== null) {
29
+ searchParams.append(key, String(value));
30
+ }
31
+ });
32
+ }
33
+ return `${path}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
34
+ }
35
+ async request(config) {
36
+ try {
37
+ const controller = new AbortController();
38
+ const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
39
+ const url = this.buildUrl(config.url, config.params);
40
+ const response = await fetch(this.config.baseUrl + url, {
41
+ ...config,
42
+ headers: {
43
+ 'Authorization': `Bearer ${this.config.apiKey}`,
44
+ 'Content-Type': 'application/json',
45
+ ...config.headers,
46
+ },
47
+ signal: controller.signal,
48
+ });
49
+ clearTimeout(timeoutId);
50
+ if (!response.ok) {
51
+ const defaultError = { message: response.statusText };
52
+ const errorData = await response.json().catch(() => defaultError);
53
+ const error = {
54
+ message: errorData.message || response.statusText,
55
+ code: errorData.code,
56
+ status: response.status,
57
+ details: errorData.details,
58
+ };
59
+ throw error;
60
+ }
61
+ const data = await response.json();
62
+ return {
63
+ data,
64
+ status: response.status,
65
+ statusText: response.statusText,
66
+ };
67
+ }
68
+ catch (error) {
69
+ if (error instanceof Error && error.name === 'AbortError') {
70
+ const timeoutError = {
71
+ message: 'Request timeout',
72
+ status: 408,
73
+ };
74
+ throw timeoutError;
75
+ }
76
+ throw error;
77
+ }
78
+ }
79
+ get(url, config) {
80
+ return this.request({ ...config, method: 'GET', url });
81
+ }
82
+ post(url, data, config) {
83
+ return this.request({ ...config, method: 'POST', url, body: JSON.stringify(data) });
84
+ }
85
+ put(url, data, config) {
86
+ return this.request({ ...config, method: 'PUT', url, body: JSON.stringify(data) });
87
+ }
88
+ delete(url, config) {
89
+ return this.request({ ...config, method: 'DELETE', url });
90
+ }
91
+ getSiteUrl(path) {
92
+ if (!this.config.siteId) {
93
+ return path;
94
+ }
95
+ return `/sites/${this.config.siteId}${path}`;
96
+ }
97
+ sitesGet(path, config) {
98
+ return this.get(this.getSiteUrl(path), config);
99
+ }
100
+ sitesPost(path, data, config) {
101
+ return this.post(this.getSiteUrl(path), data, config);
102
+ }
103
+ sitesPut(path, data, config) {
104
+ return this.put(this.getSiteUrl(path), data, config);
105
+ }
106
+ sitesDelete(path, config) {
107
+ return this.delete(this.getSiteUrl(path), config);
108
+ }
109
+ }
110
+ exports.FlexbeClient = FlexbeClient;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pages = void 0;
4
+ class Pages {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get list of pages for a site
10
+ */
11
+ async getPages(params) {
12
+ const response = await this.client.sitesGet('/pages', { params });
13
+ return response.data;
14
+ }
15
+ /**
16
+ * Get a single page by ID
17
+ */
18
+ async getPage(pageId) {
19
+ const response = await this.client.sitesGet(`/pages/${pageId}`);
20
+ return response.data;
21
+ }
22
+ }
23
+ exports.Pages = Pages;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client/client"), exports);
18
+ __exportStar(require("./client/pages"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ __exportStar(require("./types/pages"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PageStatus = exports.PageType = void 0;
4
+ var PageType;
5
+ (function (PageType) {
6
+ PageType["PAGE"] = "page";
7
+ PageType["FILE"] = "file";
8
+ PageType["GLOBAL"] = "global";
9
+ PageType["AI"] = "ai";
10
+ PageType["CMS"] = "cms";
11
+ PageType["ECOMMERCE_PRODUCT"] = "ecommerce_product";
12
+ PageType["ECOMMERCE_CATEGORY"] = "ecommerce_category";
13
+ })(PageType || (exports.PageType = PageType = {}));
14
+ var PageStatus;
15
+ (function (PageStatus) {
16
+ PageStatus["PUBLISHED"] = "published";
17
+ PageStatus["DRAFTED"] = "drafted";
18
+ PageStatus["DELETED"] = "deleted";
19
+ })(PageStatus || (exports.PageStatus = PageStatus = {}));
@@ -0,0 +1,13 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { FlexbeConfig, FlexbeResponse } from '../types';
3
+ export declare class FlexbeClient {
4
+ private readonly client;
5
+ private readonly config;
6
+ constructor(config: FlexbeConfig);
7
+ private setupInterceptors;
8
+ protected request<T>(config: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
9
+ protected get<T>(url: string, config?: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
10
+ protected post<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
11
+ protected put<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
12
+ protected delete<T>(url: string, config?: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
13
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FlexbeClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class FlexbeClient {
9
+ constructor(config) {
10
+ this.config = {
11
+ baseUrl: config.baseUrl || 'https://api.flexbe.com',
12
+ timeout: config.timeout || 30000,
13
+ ...config,
14
+ };
15
+ this.client = axios_1.default.create({
16
+ baseURL: this.config.baseUrl,
17
+ timeout: this.config.timeout,
18
+ headers: {
19
+ 'Authorization': `Bearer ${this.config.apiKey}`,
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ });
23
+ this.setupInterceptors();
24
+ }
25
+ setupInterceptors() {
26
+ this.client.interceptors.response.use((response) => response, (error) => {
27
+ const flexbeError = {
28
+ message: error.response?.data?.message || error.message,
29
+ code: error.response?.data?.code,
30
+ status: error.response?.status,
31
+ details: error.response?.data?.details,
32
+ };
33
+ return Promise.reject(flexbeError);
34
+ });
35
+ }
36
+ async request(config) {
37
+ try {
38
+ const response = await this.client.request(config);
39
+ return {
40
+ data: response.data,
41
+ status: response.status,
42
+ statusText: response.statusText,
43
+ };
44
+ }
45
+ catch (error) {
46
+ throw error;
47
+ }
48
+ }
49
+ get(url, config) {
50
+ return this.request({ ...config, method: 'GET', url });
51
+ }
52
+ post(url, data, config) {
53
+ return this.request({ ...config, method: 'POST', url, data });
54
+ }
55
+ put(url, data, config) {
56
+ return this.request({ ...config, method: 'PUT', url, data });
57
+ }
58
+ delete(url, config) {
59
+ return this.request({ ...config, method: 'DELETE', url });
60
+ }
61
+ }
62
+ exports.FlexbeClient = FlexbeClient;
@@ -0,0 +1,106 @@
1
+ import { Pages } from './pages';
2
+ export class FlexbeClient {
3
+ constructor(config) {
4
+ const getEnvVar = (key) => {
5
+ if (typeof process !== 'undefined' && process.env) {
6
+ return process.env[key];
7
+ }
8
+ return undefined;
9
+ };
10
+ this.config = {
11
+ baseUrl: config?.baseUrl || getEnvVar('FLEXBE_API_URL') || 'https://api.flexbe.com',
12
+ timeout: config?.timeout || 30000,
13
+ apiKey: config?.apiKey || getEnvVar('FLEXBE_API_KEY') || '',
14
+ siteId: config?.siteId || getEnvVar('FLEXBE_SITE_ID'),
15
+ };
16
+ if (!this.config.apiKey) {
17
+ throw new Error('API key is required. Please provide it either through config or FLEXBE_API_KEY environment variable.');
18
+ }
19
+ this.pages = new Pages(this);
20
+ }
21
+ buildUrl(path, params) {
22
+ const searchParams = new URLSearchParams();
23
+ if (params) {
24
+ Object.entries(params).forEach(([key, value]) => {
25
+ if (value !== undefined && value !== null) {
26
+ searchParams.append(key, String(value));
27
+ }
28
+ });
29
+ }
30
+ return `${path}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
31
+ }
32
+ async request(config) {
33
+ try {
34
+ const controller = new AbortController();
35
+ const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
36
+ const url = this.buildUrl(config.url, config.params);
37
+ const response = await fetch(this.config.baseUrl + url, {
38
+ ...config,
39
+ headers: {
40
+ 'Authorization': `Bearer ${this.config.apiKey}`,
41
+ 'Content-Type': 'application/json',
42
+ ...config.headers,
43
+ },
44
+ signal: controller.signal,
45
+ });
46
+ clearTimeout(timeoutId);
47
+ if (!response.ok) {
48
+ const defaultError = { message: response.statusText };
49
+ const errorData = await response.json().catch(() => defaultError);
50
+ const error = {
51
+ message: errorData.message || response.statusText,
52
+ code: errorData.code,
53
+ status: response.status,
54
+ details: errorData.details,
55
+ };
56
+ throw error;
57
+ }
58
+ const data = await response.json();
59
+ return {
60
+ data,
61
+ status: response.status,
62
+ statusText: response.statusText,
63
+ };
64
+ }
65
+ catch (error) {
66
+ if (error instanceof Error && error.name === 'AbortError') {
67
+ const timeoutError = {
68
+ message: 'Request timeout',
69
+ status: 408,
70
+ };
71
+ throw timeoutError;
72
+ }
73
+ throw error;
74
+ }
75
+ }
76
+ get(url, config) {
77
+ return this.request({ ...config, method: 'GET', url });
78
+ }
79
+ post(url, data, config) {
80
+ return this.request({ ...config, method: 'POST', url, body: JSON.stringify(data) });
81
+ }
82
+ put(url, data, config) {
83
+ return this.request({ ...config, method: 'PUT', url, body: JSON.stringify(data) });
84
+ }
85
+ delete(url, config) {
86
+ return this.request({ ...config, method: 'DELETE', url });
87
+ }
88
+ getSiteUrl(path) {
89
+ if (!this.config.siteId) {
90
+ return path;
91
+ }
92
+ return `/sites/${this.config.siteId}${path}`;
93
+ }
94
+ sitesGet(path, config) {
95
+ return this.get(this.getSiteUrl(path), config);
96
+ }
97
+ sitesPost(path, data, config) {
98
+ return this.post(this.getSiteUrl(path), data, config);
99
+ }
100
+ sitesPut(path, data, config) {
101
+ return this.put(this.getSiteUrl(path), data, config);
102
+ }
103
+ sitesDelete(path, config) {
104
+ return this.delete(this.getSiteUrl(path), config);
105
+ }
106
+ }
@@ -0,0 +1,19 @@
1
+ export class Pages {
2
+ constructor(client) {
3
+ this.client = client;
4
+ }
5
+ /**
6
+ * Get list of pages for a site
7
+ */
8
+ async getPages(params) {
9
+ const response = await this.client.sitesGet('/pages', { params });
10
+ return response.data;
11
+ }
12
+ /**
13
+ * Get a single page by ID
14
+ */
15
+ async getPage(pageId) {
16
+ const response = await this.client.sitesGet(`/pages/${pageId}`);
17
+ return response.data;
18
+ }
19
+ }
@@ -0,0 +1,4 @@
1
+ export * from './client/client';
2
+ export * from './client/pages';
3
+ export * from './types';
4
+ export * from './types/pages';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export var PageType;
2
+ (function (PageType) {
3
+ PageType["PAGE"] = "page";
4
+ PageType["FILE"] = "file";
5
+ PageType["GLOBAL"] = "global";
6
+ PageType["AI"] = "ai";
7
+ PageType["CMS"] = "cms";
8
+ PageType["ECOMMERCE_PRODUCT"] = "ecommerce_product";
9
+ PageType["ECOMMERCE_CATEGORY"] = "ecommerce_category";
10
+ })(PageType || (PageType = {}));
11
+ export var PageStatus;
12
+ (function (PageStatus) {
13
+ PageStatus["PUBLISHED"] = "published";
14
+ PageStatus["DRAFTED"] = "drafted";
15
+ PageStatus["DELETED"] = "deleted";
16
+ })(PageStatus || (PageStatus = {}));
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './client/flexbe-client';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./client/flexbe-client"), exports);
@@ -0,0 +1,20 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { FlexbeConfig, FlexbeResponse } from '../types';
3
+ import { PagesClient } from './pages-client';
4
+ export declare class FlexbeClient {
5
+ private readonly client;
6
+ private readonly config;
7
+ readonly pages: PagesClient;
8
+ constructor(config?: Partial<FlexbeConfig>);
9
+ private setupInterceptors;
10
+ private request;
11
+ private get;
12
+ private post;
13
+ private put;
14
+ private delete;
15
+ private getSiteUrl;
16
+ sitesGet<T>(path: string, config?: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
17
+ sitesPost<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
18
+ sitesPut<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
19
+ sitesDelete<T>(path: string, config?: AxiosRequestConfig): Promise<FlexbeResponse<T>>;
20
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FlexbeClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const pages_client_1 = require("./pages-client");
9
+ class FlexbeClient {
10
+ constructor(config) {
11
+ this.config = {
12
+ baseUrl: config?.baseUrl || process.env.FLEXBE_API_URL || 'https://api.flexbe.com',
13
+ timeout: config?.timeout || 30000,
14
+ apiKey: config?.apiKey || process.env.FLEXBE_API_KEY || '',
15
+ siteId: config?.siteId || process.env.FLEXBE_SITE_ID,
16
+ };
17
+ if (!this.config.apiKey) {
18
+ throw new Error('API key is required. Please provide it either through config or FLEXBE_API_KEY environment variable.');
19
+ }
20
+ this.client = axios_1.default.create({
21
+ baseURL: this.config.baseUrl,
22
+ timeout: this.config.timeout,
23
+ headers: {
24
+ 'Authorization': `Bearer ${this.config.apiKey}`,
25
+ 'Content-Type': 'application/json',
26
+ },
27
+ });
28
+ this.setupInterceptors();
29
+ this.pages = new pages_client_1.PagesClient(this);
30
+ }
31
+ setupInterceptors() {
32
+ this.client.interceptors.response.use((response) => response, (error) => {
33
+ const flexbeError = {
34
+ message: error.response?.data?.message || error.message,
35
+ code: error.response?.data?.code,
36
+ status: error.response?.status,
37
+ details: error.response?.data?.details,
38
+ };
39
+ return Promise.reject(flexbeError);
40
+ });
41
+ }
42
+ async request(config) {
43
+ try {
44
+ const response = await this.client.request(config);
45
+ return {
46
+ data: response.data,
47
+ status: response.status,
48
+ statusText: response.statusText,
49
+ };
50
+ }
51
+ catch (error) {
52
+ throw error;
53
+ }
54
+ }
55
+ get(url, config) {
56
+ return this.request({ ...config, method: 'GET', url });
57
+ }
58
+ post(url, data, config) {
59
+ return this.request({ ...config, method: 'POST', url, data });
60
+ }
61
+ put(url, data, config) {
62
+ return this.request({ ...config, method: 'PUT', url, data });
63
+ }
64
+ delete(url, config) {
65
+ return this.request({ ...config, method: 'DELETE', url });
66
+ }
67
+ getSiteUrl(path) {
68
+ if (!this.config.siteId) {
69
+ return path;
70
+ }
71
+ return `/sites/${this.config.siteId}${path}`;
72
+ }
73
+ sitesGet(path, config) {
74
+ return this.get(this.getSiteUrl(path), config);
75
+ }
76
+ sitesPost(path, data, config) {
77
+ return this.post(this.getSiteUrl(path), data, config);
78
+ }
79
+ sitesPut(path, data, config) {
80
+ return this.put(this.getSiteUrl(path), data, config);
81
+ }
82
+ sitesDelete(path, config) {
83
+ return this.delete(this.getSiteUrl(path), config);
84
+ }
85
+ }
86
+ exports.FlexbeClient = FlexbeClient;
@@ -0,0 +1,14 @@
1
+ import { Page, GetPagesParams, PageListResponse } from '../types/pages';
2
+ import { FlexbeClient } from './flexbe-client';
3
+ export declare class PagesClient {
4
+ private readonly client;
5
+ constructor(client: FlexbeClient);
6
+ /**
7
+ * Get list of pages for a site
8
+ */
9
+ getPages(params?: GetPagesParams): Promise<PageListResponse>;
10
+ /**
11
+ * Get a single page by ID
12
+ */
13
+ getPage(pageId: number): Promise<Page>;
14
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PagesClient = void 0;
4
+ class PagesClient {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get list of pages for a site
10
+ */
11
+ async getPages(params) {
12
+ const response = await this.client.sitesGet('/pages', { params });
13
+ return response.data;
14
+ }
15
+ /**
16
+ * Get a single page by ID
17
+ */
18
+ async getPage(pageId) {
19
+ const response = await this.client.sitesGet(`/pages/${pageId}`);
20
+ return response.data;
21
+ }
22
+ }
23
+ exports.PagesClient = PagesClient;
@@ -0,0 +1,4 @@
1
+ export * from './client/flexbe-client';
2
+ export * from './client/pages-client';
3
+ export * from './types';
4
+ export * from './types/pages';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client/flexbe-client"), exports);
18
+ __exportStar(require("./client/pages-client"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ __exportStar(require("./types/pages"), exports);
@@ -0,0 +1,23 @@
1
+ export interface FlexbeConfig {
2
+ apiKey?: string;
3
+ baseUrl?: string;
4
+ timeout?: number;
5
+ siteId?: string;
6
+ }
7
+ export interface FlexbeResponse<T> {
8
+ data: T;
9
+ status: number;
10
+ statusText: string;
11
+ }
12
+ export interface FlexbeErrorResponse {
13
+ message: string;
14
+ code?: string;
15
+ details?: unknown;
16
+ }
17
+ export interface FlexbeError {
18
+ message: string;
19
+ code?: string;
20
+ status?: number;
21
+ details?: unknown;
22
+ }
23
+ export type FlexbeAuthType = 'apiKey' | 'bearer' | 'oauth2';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,41 @@
1
+ export declare enum PageType {
2
+ PAGE = "page",
3
+ FILE = "file",
4
+ GLOBAL = "global",
5
+ AI = "ai",
6
+ CMS = "cms",
7
+ ECOMMERCE_PRODUCT = "ecommerce_product",
8
+ ECOMMERCE_CATEGORY = "ecommerce_category"
9
+ }
10
+ export declare enum PageStatus {
11
+ PUBLISHED = "published",
12
+ DRAFTED = "drafted",
13
+ DELETED = "deleted"
14
+ }
15
+ export interface Page {
16
+ id: number;
17
+ siteId: number;
18
+ type: PageType;
19
+ uri: string;
20
+ title: string | null;
21
+ status: PageStatus;
22
+ updatedAt?: Date;
23
+ imgId: number | null;
24
+ sortIndex: number;
25
+ }
26
+ export interface GetPagesParams {
27
+ offset?: number;
28
+ limit?: number;
29
+ type?: PageType;
30
+ status?: PageStatus;
31
+ search?: string;
32
+ }
33
+ export interface Pagination {
34
+ limit: number;
35
+ offset: number;
36
+ total: number;
37
+ }
38
+ export interface PageListResponse {
39
+ pages: Page[];
40
+ pagination: Pagination;
41
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PageStatus = exports.PageType = void 0;
4
+ var PageType;
5
+ (function (PageType) {
6
+ PageType["PAGE"] = "page";
7
+ PageType["FILE"] = "file";
8
+ PageType["GLOBAL"] = "global";
9
+ PageType["AI"] = "ai";
10
+ PageType["CMS"] = "cms";
11
+ PageType["ECOMMERCE_PRODUCT"] = "ecommerce_product";
12
+ PageType["ECOMMERCE_CATEGORY"] = "ecommerce_category";
13
+ })(PageType || (exports.PageType = PageType = {}));
14
+ var PageStatus;
15
+ (function (PageStatus) {
16
+ PageStatus["PUBLISHED"] = "published";
17
+ PageStatus["DRAFTED"] = "drafted";
18
+ PageStatus["DELETED"] = "deleted";
19
+ })(PageStatus || (exports.PageStatus = PageStatus = {}));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const flexbe_client_1 = require("../../src/client/flexbe-client");
4
+ describe('FlexbeClient', () => {
5
+ let client;
6
+ const testConfig = {
7
+ apiKey: process.env.FLEXBE_API_KEY || 'test-api-key',
8
+ baseUrl: process.env.FLEXBE_API_URL || 'https://api.flexbe.com',
9
+ };
10
+ beforeEach(() => {
11
+ client = new flexbe_client_1.FlexbeClient(testConfig);
12
+ });
13
+ it('should initialize with correct configuration', () => {
14
+ expect(client).toBeDefined();
15
+ const axiosInstance = client.client;
16
+ expect(axiosInstance.defaults.baseURL).toBe(testConfig.baseUrl);
17
+ expect(axiosInstance.defaults.headers.Authorization).toBe(`Bearer ${testConfig.apiKey}`);
18
+ });
19
+ it('should handle successful GET request', async () => {
20
+ // Access protected method for testing
21
+ const response = await client.get('/');
22
+ expect(response).toBeDefined();
23
+ expect(response.status).toBe(200);
24
+ expect(response.data).toBeDefined();
25
+ });
26
+ it('should handle error response', async () => {
27
+ try {
28
+ // Access protected method for testing
29
+ await client.get('/non-existent-endpoint');
30
+ fail('Should have thrown an error');
31
+ }
32
+ catch (error) {
33
+ const flexbeError = error;
34
+ expect(flexbeError.message).toBeDefined();
35
+ expect(flexbeError.status).toBeDefined();
36
+ }
37
+ });
38
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const flexbe_client_1 = require("../../src/client/flexbe-client");
4
+ const pages_1 = require("../../src/types/pages");
5
+ describe('PagesClient', () => {
6
+ let client;
7
+ const testConfig = {
8
+ apiKey: process.env.FLEXBE_API_KEY || 'test-api-key',
9
+ baseUrl: process.env.FLEXBE_API_URL || 'https://api.flexbe.com',
10
+ siteId: process.env.FLEXBE_SITE_ID || '0',
11
+ };
12
+ beforeEach(() => {
13
+ client = new flexbe_client_1.FlexbeClient(testConfig);
14
+ });
15
+ it('should initialize with correct configuration', () => {
16
+ expect(client.pages).toBeDefined();
17
+ const axiosInstance = client.client;
18
+ expect(axiosInstance.defaults.baseURL).toBe(testConfig.baseUrl);
19
+ expect(axiosInstance.defaults.headers.Authorization).toBe(`Bearer ${testConfig.apiKey}`);
20
+ });
21
+ it('should get list of pages with default parameters', async () => {
22
+ const response = await client.pages.getPages();
23
+ expect(response).toBeDefined();
24
+ expect(response.pages).toBeDefined();
25
+ expect(response.pagination).toBeDefined();
26
+ expect(response.pagination.limit).toBe(10);
27
+ expect(response.pagination.offset).toBe(0);
28
+ expect(response.pagination.total).toBeDefined();
29
+ });
30
+ it('should get list of pages with custom parameters', async () => {
31
+ const params = {
32
+ offset: 0,
33
+ limit: 20,
34
+ type: pages_1.PageType.PAGE,
35
+ status: pages_1.PageStatus.PUBLISHED,
36
+ search: ''
37
+ };
38
+ const response = await client.pages.getPages(params);
39
+ expect(response).toBeDefined();
40
+ expect(response.pages).toBeDefined();
41
+ expect(response.pagination).toBeDefined();
42
+ expect(response.pagination.limit).toBe(params.limit);
43
+ expect(response.pagination.offset).toBe(params.offset);
44
+ expect(response.pagination.total).toBeDefined();
45
+ });
46
+ it('should get a single page by ID', async () => {
47
+ const pageId = 2272741;
48
+ const response = await client.pages.getPage(pageId);
49
+ expect(response).toBeDefined();
50
+ expect(response.id).toBe(pageId);
51
+ expect(response.siteId).toBe(Number(testConfig.siteId));
52
+ expect(response.type).toBeDefined();
53
+ expect(response.uri).toBeDefined();
54
+ expect(response.status).toBeDefined();
55
+ expect(response.sortIndex).toBeDefined();
56
+ });
57
+ it('should handle error when getting non-existent page', async () => {
58
+ try {
59
+ await client.pages.getPage(999999);
60
+ fail('Should have thrown an error');
61
+ }
62
+ catch (error) {
63
+ const flexbeError = error;
64
+ expect(flexbeError.message).toBeDefined();
65
+ expect(flexbeError.status).toBeDefined();
66
+ }
67
+ });
68
+ it('should handle error when getting pages with invalid parameters', async () => {
69
+ try {
70
+ await client.pages.getPages({
71
+ offset: -1,
72
+ limit: 0
73
+ });
74
+ fail('Should have thrown an error');
75
+ }
76
+ catch (error) {
77
+ const flexbeError = error;
78
+ expect(flexbeError.message).toBeDefined();
79
+ expect(flexbeError.status).toBeDefined();
80
+ }
81
+ });
82
+ });
@@ -0,0 +1,26 @@
1
+ import { FlexbeConfig, FlexbeResponse } from '../types';
2
+ import { Pages } from './pages';
3
+ export declare class FlexbeClient {
4
+ private readonly config;
5
+ readonly pages: Pages;
6
+ constructor(config?: Partial<FlexbeConfig>);
7
+ private buildUrl;
8
+ private request;
9
+ private get;
10
+ private post;
11
+ private put;
12
+ private delete;
13
+ private getSiteUrl;
14
+ sitesGet<T>(path: string, config?: RequestInit & {
15
+ params?: Record<string, unknown>;
16
+ }): Promise<FlexbeResponse<T>>;
17
+ sitesPost<T>(path: string, data?: unknown, config?: RequestInit & {
18
+ params?: Record<string, unknown>;
19
+ }): Promise<FlexbeResponse<T>>;
20
+ sitesPut<T>(path: string, data?: unknown, config?: RequestInit & {
21
+ params?: Record<string, unknown>;
22
+ }): Promise<FlexbeResponse<T>>;
23
+ sitesDelete<T>(path: string, config?: RequestInit & {
24
+ params?: Record<string, unknown>;
25
+ }): Promise<FlexbeResponse<T>>;
26
+ }
@@ -0,0 +1,14 @@
1
+ import { Page, GetPagesParams, PageListResponse } from '../types/pages';
2
+ import { FlexbeClient } from './client';
3
+ export declare class Pages {
4
+ private readonly client;
5
+ constructor(client: FlexbeClient);
6
+ /**
7
+ * Get list of pages for a site
8
+ */
9
+ getPages(params?: GetPagesParams): Promise<PageListResponse>;
10
+ /**
11
+ * Get a single page by ID
12
+ */
13
+ getPage(pageId: number): Promise<Page>;
14
+ }
@@ -0,0 +1,4 @@
1
+ export * from './client/client';
2
+ export * from './client/pages';
3
+ export * from './types';
4
+ export * from './types/pages';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ export interface FlexbeConfig {
2
+ apiKey?: string;
3
+ baseUrl?: string;
4
+ timeout?: number;
5
+ siteId?: string;
6
+ }
7
+ export interface FlexbeResponse<T> {
8
+ data: T;
9
+ status: number;
10
+ statusText: string;
11
+ }
12
+ export interface FlexbeErrorResponse {
13
+ message: string;
14
+ code?: string;
15
+ details?: unknown;
16
+ }
17
+ export interface FlexbeError {
18
+ message: string;
19
+ code?: string;
20
+ status?: number;
21
+ details?: unknown;
22
+ }
23
+ export type FlexbeAuthType = 'apiKey' | 'bearer' | 'oauth2';
@@ -0,0 +1,41 @@
1
+ export declare enum PageType {
2
+ PAGE = "page",
3
+ FILE = "file",
4
+ GLOBAL = "global",
5
+ AI = "ai",
6
+ CMS = "cms",
7
+ ECOMMERCE_PRODUCT = "ecommerce_product",
8
+ ECOMMERCE_CATEGORY = "ecommerce_category"
9
+ }
10
+ export declare enum PageStatus {
11
+ PUBLISHED = "published",
12
+ DRAFTED = "drafted",
13
+ DELETED = "deleted"
14
+ }
15
+ export interface Page {
16
+ id: number;
17
+ siteId: number;
18
+ type: PageType;
19
+ uri: string;
20
+ title: string | null;
21
+ status: PageStatus;
22
+ updatedAt?: Date;
23
+ imgId: number | null;
24
+ sortIndex: number;
25
+ }
26
+ export interface GetPagesParams extends Record<string, unknown> {
27
+ offset?: number;
28
+ limit?: number;
29
+ type?: PageType;
30
+ status?: PageStatus;
31
+ search?: string;
32
+ }
33
+ export interface Pagination {
34
+ limit: number;
35
+ offset: number;
36
+ total: number;
37
+ }
38
+ export interface PageListResponse {
39
+ pages: Page[];
40
+ pagination: Pagination;
41
+ }
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@flexbe/sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for Flexbe API",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "browser": "dist/browser/index.js",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/cjs/index.js",
13
+ "types": "./dist/types/index.d.ts"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "npm run build:esm && npm run build:cjs && npm run build:browser",
18
+ "build:esm": "tsc -p tsconfig.esm.json",
19
+ "build:cjs": "tsc -p tsconfig.cjs.json",
20
+ "build:browser": "tsc -p tsconfig.browser.json",
21
+ "test": "dotenv -e test/.env.test jest",
22
+ "lint": "eslint src --ext .ts",
23
+ "format": "prettier --write \"src/**/*.ts\"",
24
+ "prepare": "npm run build",
25
+ "prepublishOnly": "npm test && npm run lint",
26
+ "publish": "npm publish --access public"
27
+ },
28
+ "keywords": [
29
+ "flexbe",
30
+ "sdk",
31
+ "typescript",
32
+ "api-client"
33
+ ],
34
+ "author": "Flexbe",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/flexbe/sdk-ts.git"
39
+ },
40
+ "bugs": {
41
+ "url": "https://github.com/flexbe/sdk-ts/issues"
42
+ },
43
+ "homepage": "https://github.com/flexbe/sdk-ts#readme",
44
+ "dependencies": {},
45
+ "devDependencies": {
46
+ "@types/jest": "^29.5.12",
47
+ "@types/node": "^20.11.19",
48
+ "@typescript-eslint/eslint-plugin": "^7.0.1",
49
+ "@typescript-eslint/parser": "^7.0.1",
50
+ "dotenv-cli": "^7.4.1",
51
+ "eslint": "^8.56.0",
52
+ "jest": "^29.7.0",
53
+ "prettier": "^3.2.5",
54
+ "ts-jest": "^29.1.2",
55
+ "typescript": "~5.5.0"
56
+ },
57
+ "files": [
58
+ "dist",
59
+ "README.md"
60
+ ],
61
+ "engines": {
62
+ "node": ">=16.0.0"
63
+ },
64
+ "publishConfig": {
65
+ "access": "public"
66
+ }
67
+ }