mftsccs-node 0.0.59 → 0.0.62

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.
@@ -259,4 +259,14 @@ export declare class BaseUrl {
259
259
  * @returns {string} The bulk type concept retrieval API endpoint
260
260
  */
261
261
  static GetConceptConnectionByType(): string;
262
+ /**
263
+ * Returns the URL for OAuth token requests.
264
+ * @returns {string} The OAuth token API endpoint
265
+ */
266
+ static OAuthTokenUrl(): string;
267
+ /**
268
+ * Returns the URL for OAuth token refresh requests.
269
+ * @returns {string} The OAuth token refresh API endpoint
270
+ */
271
+ static OAuthRefreshUrl(): string;
262
272
  }
@@ -0,0 +1,169 @@
1
+ /**
2
+ * @fileoverview Configuration class for CCS initialization.
3
+ * This module provides a clean way to manage optional CCS configuration parameters.
4
+ * @module DataStructures/CCSConfig
5
+ */
6
+ /**
7
+ * Configuration class for CCS initialization.
8
+ *
9
+ * This class holds all optional configuration parameters for the CCS library,
10
+ * keeping the init() function clean with only essential parameters.
11
+ *
12
+ * @class CCSConfig
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const config = new CCSConfig({
17
+ * aiUrl: "https://ai.example.com",
18
+ * accessToken: "jwt-token",
19
+ * enableAi: true,
20
+ * flags: { logApplication: true },
21
+ * storagePath: "./data/ccs/"
22
+ * });
23
+ *
24
+ * await init(
25
+ * "https://api.example.com",
26
+ * "http://localhost:5001",
27
+ * "MyApp",
28
+ * config
29
+ * );
30
+ * ```
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // Minimal configuration with OAuth
35
+ * const config = new CCSConfig({
36
+ * clientId: "101084838",
37
+ * clientSecret: "your-secret"
38
+ * });
39
+ *
40
+ * await init("https://api.example.com", "", "MyApp", config);
41
+ * ```
42
+ */
43
+ export declare class CCSConfig {
44
+ /** URL for the AI service. Defaults to "https://ai.freeschema.com" */
45
+ aiUrl: string;
46
+ /** JWT bearer token for authentication. Can be set later via updateAccessToken() */
47
+ accessToken: string;
48
+ /** Whether to enable AI features. Defaults to true */
49
+ enableAi: boolean;
50
+ /**
51
+ * Dictionary of feature flags for controlling CCS behavior.
52
+ * Available flags:
53
+ * - logApplication: Enable application-level logging
54
+ * - logPackage: Enable package-level logging
55
+ * - accessTracker: Enable access tracking
56
+ * - isTest: Enable test mode
57
+ */
58
+ flags?: Record<string, boolean>;
59
+ /**
60
+ * Dictionary of additional parameters.
61
+ * Example: { logserver: "https://logs.example.com" }
62
+ */
63
+ parameters?: Record<string, string>;
64
+ /** Path for storing local data (ID counters, cached data, etc.) */
65
+ storagePath?: string;
66
+ /** OAuth client ID for authentication */
67
+ clientId?: string;
68
+ /** OAuth client secret for authentication */
69
+ clientSecret?: string;
70
+ /** Application name for OAuth and logging purposes */
71
+ applicationName?: string;
72
+ /**
73
+ * Creates a new CCSConfig instance.
74
+ *
75
+ * @param options - Partial configuration options to override defaults
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Use default values
80
+ * const config = new CCSConfig();
81
+ * ```
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // Override specific values
86
+ * const config = new CCSConfig({
87
+ * aiUrl: "https://custom-ai.example.com",
88
+ * enableAi: false,
89
+ * clientId: "123456",
90
+ * clientSecret: "secret",
91
+ * flags: {
92
+ * logApplication: true,
93
+ * accessTracker: true
94
+ * }
95
+ * });
96
+ * ```
97
+ */
98
+ constructor(options?: Partial<CCSConfig>);
99
+ /**
100
+ * Returns true if OAuth credentials are configured.
101
+ * @returns {boolean} Whether both clientId and clientSecret are set
102
+ */
103
+ hasOAuthCredentials(): boolean;
104
+ /**
105
+ * Returns true if an access token is configured.
106
+ * @returns {boolean} Whether accessToken is set
107
+ */
108
+ hasAccessToken(): boolean;
109
+ /**
110
+ * Get a specific flag value with a default fallback.
111
+ *
112
+ * @param flagName - The name of the flag to retrieve
113
+ * @param defaultValue - Default value if flag is not set
114
+ * @returns {boolean} The flag value or default
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const config = new CCSConfig({
119
+ * flags: { logApplication: true }
120
+ * });
121
+ * config.getFlag('logApplication', false); // returns true
122
+ * config.getFlag('unknownFlag', false); // returns false
123
+ * ```
124
+ */
125
+ getFlag(flagName: string, defaultValue?: boolean): boolean;
126
+ /**
127
+ * Get a specific parameter value with a default fallback.
128
+ *
129
+ * @param paramName - The name of the parameter to retrieve
130
+ * @param defaultValue - Default value if parameter is not set
131
+ * @returns {string} The parameter value or default
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * const config = new CCSConfig({
136
+ * parameters: { logserver: "https://logs.example.com" }
137
+ * });
138
+ * config.getParameter('logserver', ''); // returns "https://logs.example.com"
139
+ * config.getParameter('unknown', ''); // returns ""
140
+ * ```
141
+ */
142
+ getParameter(paramName: string, defaultValue?: string): string;
143
+ /**
144
+ * Set a flag value.
145
+ *
146
+ * @param flagName - The name of the flag to set
147
+ * @param value - The boolean value to set
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * const config = new CCSConfig();
152
+ * config.setFlag('logApplication', true);
153
+ * ```
154
+ */
155
+ setFlag(flagName: string, value: boolean): void;
156
+ /**
157
+ * Set a parameter value.
158
+ *
159
+ * @param paramName - The name of the parameter to set
160
+ * @param value - The string value to set
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * const config = new CCSConfig();
165
+ * config.setParameter('logserver', 'https://logs.example.com');
166
+ * ```
167
+ */
168
+ setParameter(paramName: string, value: string): void;
169
+ }
@@ -48,4 +48,48 @@ export declare class TokenStorage {
48
48
  * Consider clearing this value on logout or session expiration.
49
49
  */
50
50
  static BearerAccessToken: string;
51
+ /**
52
+ * OAuth client ID for token refresh
53
+ * @static
54
+ * @type {string}
55
+ * @default ""
56
+ */
57
+ static CLIENT_ID: string;
58
+ /**
59
+ * OAuth client secret for token refresh
60
+ * @static
61
+ * @type {string}
62
+ * @default ""
63
+ */
64
+ static CLIENT_SECRET: string;
65
+ /**
66
+ * Application name for OAuth
67
+ * @static
68
+ * @type {string}
69
+ * @default ""
70
+ */
71
+ static APPLICATION_NAME: string;
72
+ /**
73
+ * Gets authorization header object for HTTP requests.
74
+ * @returns {Record<string, string>} Headers object with Authorization header if token exists
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const headers = TokenStorage.getAuthHeader();
79
+ * // Returns: { 'Authorization': 'Bearer your-token' } or {}
80
+ * ```
81
+ */
82
+ static getAuthHeader(): Record<string, string>;
83
+ /**
84
+ * Checks if OAuth credentials are configured for automatic token refresh.
85
+ * @returns {boolean} True if client ID, secret, and app name are all set
86
+ */
87
+ static hasOAuthCredentials(): boolean;
88
+ /**
89
+ * Sets OAuth credentials for automatic token refresh.
90
+ * @param clientId - OAuth client ID
91
+ * @param clientSecret - OAuth client secret
92
+ * @param applicationName - Application name
93
+ */
94
+ static setOAuthCredentials(clientId: string, clientSecret: string, applicationName: string): void;
51
95
  }
@@ -2,6 +2,7 @@
2
2
  * @module ErrorPosting
3
3
  * @description Provides error handling functions for HTTP and internal errors with structured error responses
4
4
  */
5
+ import { HttpResponse } from "../Http/HttpClient.service";
5
6
  /**
6
7
  * Handles HTTP errors by creating and throwing structured error responses.
7
8
  * Specifically handles 401 Unauthorized errors.
@@ -23,6 +24,7 @@
23
24
  * - Useful for API call error handling
24
25
  */
25
26
  export declare function HandleHttpError(response: Response): void;
27
+ export declare function HandleHttpErrorHttp(response: HttpResponse): void;
26
28
  /**
27
29
  * Handles internal application errors by creating and throwing structured error responses.
28
30
  * Wraps any error object into a FreeSchemaResponse.
@@ -0,0 +1,205 @@
1
+ /**
2
+ * @fileoverview HTTP Client - Handles API requests with automatic token refresh on 401 errors.
3
+ * This module provides a robust HTTP client that automatically refreshes OAuth tokens
4
+ * when receiving 401 Unauthorized responses, ensuring seamless API access.
5
+ * @module Services/Http/HttpClient
6
+ */
7
+ /**
8
+ * Custom error thrown when token refresh fails.
9
+ */
10
+ export declare class TokenRefreshError extends Error {
11
+ constructor(message: string);
12
+ }
13
+ /**
14
+ * Container for HTTP response data.
15
+ * Provides convenient methods to parse response body as JSON or text.
16
+ */
17
+ export declare class HttpResponse {
18
+ status: number;
19
+ body: string;
20
+ headers: Record<string, string>;
21
+ /**
22
+ * Creates a new HttpResponse instance.
23
+ * @param status - HTTP status code
24
+ * @param body - Response body as string
25
+ * @param headers - Response headers
26
+ */
27
+ constructor(status: number, body: string, headers: Record<string, string>);
28
+ /**
29
+ * Parse response body as JSON.
30
+ * @returns {Promise<any>} Parsed JSON object
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const response = await requestWithRetry('GET', url);
35
+ * const data = await response.json();
36
+ * console.log(data.id);
37
+ * ```
38
+ */
39
+ json(): Promise<any>;
40
+ /**
41
+ * Get response body as text.
42
+ * @returns {Promise<string>} Response body as string
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const response = await requestWithRetry('GET', url);
47
+ * const text = await response.text();
48
+ * console.log(text);
49
+ * ```
50
+ */
51
+ text(): Promise<string>;
52
+ /**
53
+ * Checks if the response status indicates success (200-299).
54
+ * @returns {boolean} True if status is in the 2xx range
55
+ */
56
+ get ok(): boolean;
57
+ }
58
+ /**
59
+ * Make an HTTP request with automatic retry on 401 Unauthorized.
60
+ *
61
+ * If a 401 error occurs and OAuth credentials are available, this function
62
+ * will automatically refresh the token and retry the request once.
63
+ *
64
+ * @async
65
+ * @param {string} method - HTTP method (GET, POST, PUT, DELETE, etc.)
66
+ * @param {string} url - The URL to request
67
+ * @param {Record<string, string>} [headers] - Optional headers dict
68
+ * @param {any} [body] - Optional request body (JSON will be stringified)
69
+ * @param {number} [maxRetries=1] - Maximum number of retries on 401
70
+ * @returns {Promise<HttpResponse>} HttpResponse object with status, body, and headers
71
+ * @throws {TokenRefreshError} If token refresh fails
72
+ * @throws {Error} For other network errors
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const headers = { "Content-Type": "application/json" };
77
+ * const response = await requestWithRetry(
78
+ * "POST",
79
+ * url,
80
+ * headers,
81
+ * { id: 123 }
82
+ * );
83
+ * if (response.ok) {
84
+ * const data = await response.json();
85
+ * console.log(data);
86
+ * }
87
+ * ```
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * // Automatic token refresh on 401
92
+ * try {
93
+ * const response = await requestWithRetry("GET", url);
94
+ * // If receives 401, will automatically refresh token and retry
95
+ * } catch (error) {
96
+ * if (error instanceof TokenRefreshError) {
97
+ * console.error('Authentication failed:', error.message);
98
+ * }
99
+ * }
100
+ * ```
101
+ */
102
+ export declare function requestWithRetry(method: string, url: string, headers?: Record<string, string>, body?: any, maxRetries?: number): Promise<HttpResponse>;
103
+ /**
104
+ * Convenience method for POST requests with automatic retry on 401.
105
+ *
106
+ * @async
107
+ * @param {string} url - The URL to request
108
+ * @param {Record<string, string>} [headers] - Optional headers dict
109
+ * @param {any} [body] - Optional request body (will be JSON stringified if object)
110
+ * @returns {Promise<HttpResponse>} HttpResponse object
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const response = await postWithRetry(
115
+ * "https://api.example.com/concepts",
116
+ * { "Content-Type": "application/json" },
117
+ * { name: "Test", value: 123 }
118
+ * );
119
+ * if (response.ok) {
120
+ * const data = await response.json();
121
+ * console.log('Created:', data);
122
+ * }
123
+ * ```
124
+ */
125
+ export declare function postWithRetry(url: string, headers?: Record<string, string>, body?: any): Promise<HttpResponse>;
126
+ /**
127
+ * Convenience method for GET requests with automatic retry on 401.
128
+ *
129
+ * @async
130
+ * @param {string} url - The URL to request
131
+ * @param {Record<string, string>} [headers] - Optional headers dict
132
+ * @param {Record<string, any>} [params] - Optional query parameters
133
+ * @returns {Promise<HttpResponse>} HttpResponse object
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const response = await getWithRetry(
138
+ * "https://api.example.com/concepts",
139
+ * undefined,
140
+ * { id: 123, type: "test" }
141
+ * );
142
+ * if (response.ok) {
143
+ * const data = await response.json();
144
+ * console.log(data);
145
+ * }
146
+ * ```
147
+ */
148
+ export declare function getWithRetry(url: string, headers?: Record<string, string>, params?: Record<string, any>): Promise<HttpResponse>;
149
+ /**
150
+ * Convenience method for PUT requests with automatic retry on 401.
151
+ *
152
+ * @async
153
+ * @param {string} url - The URL to request
154
+ * @param {Record<string, string>} [headers] - Optional headers dict
155
+ * @param {any} [body] - Optional request body
156
+ * @returns {Promise<HttpResponse>} HttpResponse object
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const response = await putWithRetry(
161
+ * "https://api.example.com/concepts/123",
162
+ * { "Content-Type": "application/json" },
163
+ * { name: "Updated Name" }
164
+ * );
165
+ * ```
166
+ */
167
+ export declare function putWithRetry(url: string, headers?: Record<string, string>, body?: any): Promise<HttpResponse>;
168
+ /**
169
+ * Convenience method for DELETE requests with automatic retry on 401.
170
+ *
171
+ * @async
172
+ * @param {string} url - The URL to request
173
+ * @param {Record<string, string>} [headers] - Optional headers dict
174
+ * @returns {Promise<HttpResponse>} HttpResponse object
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const response = await deleteWithRetry(
179
+ * "https://api.example.com/concepts/123"
180
+ * );
181
+ * if (response.ok) {
182
+ * console.log('Deleted successfully');
183
+ * }
184
+ * ```
185
+ */
186
+ export declare function deleteWithRetry(url: string, headers?: Record<string, string>): Promise<HttpResponse>;
187
+ /**
188
+ * Convenience method for PATCH requests with automatic retry on 401.
189
+ *
190
+ * @async
191
+ * @param {string} url - The URL to request
192
+ * @param {Record<string, string>} [headers] - Optional headers dict
193
+ * @param {any} [body] - Optional request body
194
+ * @returns {Promise<HttpResponse>} HttpResponse object
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * const response = await patchWithRetry(
199
+ * "https://api.example.com/concepts/123",
200
+ * { "Content-Type": "application/json" },
201
+ * { status: "active" }
202
+ * );
203
+ * ```
204
+ */
205
+ export declare function patchWithRetry(url: string, headers?: Record<string, string>, body?: any): Promise<HttpResponse>;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @fileoverview OAuth API - Handles OAuth token requests for authentication.
3
+ * This module provides functions for obtaining and refreshing OAuth access tokens
4
+ * from the authentication server.
5
+ * @module Services/oauth/CallOauth
6
+ */
7
+ /**
8
+ * Response from OAuth token request.
9
+ * Contains either successful token data or error information.
10
+ *
11
+ * @interface OAuthResponse
12
+ */
13
+ export interface OAuthResponse {
14
+ /** Whether the OAuth request was successful */
15
+ success: boolean;
16
+ /** The OAuth access token (empty if request failed) */
17
+ access_token?: string;
18
+ /** The token type (typically "Bearer") */
19
+ token_type?: string;
20
+ /** Number of seconds until the token expires */
21
+ expires_in?: number;
22
+ /** Error message if the request failed */
23
+ error?: string;
24
+ }
25
+ /**
26
+ * Request an OAuth access token from the server.
27
+ *
28
+ * This function authenticates with the OAuth endpoint using client credentials
29
+ * and returns an access token that can be used for API requests.
30
+ *
31
+ * @async
32
+ * @param {string} client_id - The OAuth client ID.
33
+ * @param {string} client_secret - The OAuth client secret.
34
+ * @param {string} application_name - The name of the application requesting the token.
35
+ * @param {boolean} [auto_set_token=true] - If true, automatically sets the token in TokenStorage
36
+ * for subsequent API calls.
37
+ * @returns {Promise<OAuthResponse>} OAuthResponse with the access token if successful,
38
+ * or error details if failed.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * import { getOAuthToken } from './Services/oauth/CallOauth.service';
43
+ *
44
+ * const response = await getOAuthToken(
45
+ * "101084838",
46
+ * "your-client-secret",
47
+ * "myapp"
48
+ * );
49
+ * if (response.success) {
50
+ * console.log(`Token: ${response.access_token}`);
51
+ * } else {
52
+ * console.log(`Error: ${response.error}`);
53
+ * }
54
+ * ```
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Get token without auto-setting
59
+ * const response = await getOAuthToken(
60
+ * "101084838",
61
+ * "secret",
62
+ * "myapp",
63
+ * false
64
+ * );
65
+ * // Manually set token later
66
+ * if (response.success) {
67
+ * TokenStorage.BearerAccessToken = response.access_token || "";
68
+ * }
69
+ * ```
70
+ */
71
+ export declare function getOAuthToken(client_id: string, client_secret: string, application_name: string, auto_set_token?: boolean): Promise<OAuthResponse>;
72
+ /**
73
+ * Refresh an OAuth access token using a refresh token.
74
+ *
75
+ * This function uses a refresh token from a previous authentication to obtain
76
+ * a new access token without requiring the user to re-authenticate.
77
+ *
78
+ * @async
79
+ * @param {string} client_id - The OAuth client ID.
80
+ * @param {string} client_secret - The OAuth client secret.
81
+ * @param {string} refresh_token - The refresh token from a previous authentication.
82
+ * @param {boolean} [auto_set_token=true] - If true, automatically sets the new token in TokenStorage.
83
+ * @returns {Promise<OAuthResponse>} OAuthResponse with the new access token if successful.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * import { refreshOAuthToken } from './Services/oauth/CallOauth.service';
88
+ *
89
+ * const response = await refreshOAuthToken(
90
+ * "101084838",
91
+ * "your-client-secret",
92
+ * "your-refresh-token"
93
+ * );
94
+ * if (response.success) {
95
+ * console.log(`New Token: ${response.access_token}`);
96
+ * } else {
97
+ * console.log(`Error: ${response.error}`);
98
+ * }
99
+ * ```
100
+ */
101
+ export declare function refreshOAuthToken(client_id: string, client_secret: string, refresh_token: string, auto_set_token?: boolean): Promise<OAuthResponse>;
@@ -7,6 +7,8 @@
7
7
  * @see {@link https://documentation.freeschema.com} for detailed documentation
8
8
  */
9
9
  export { init, updateAccessToken };
10
+ export { getOAuthToken, refreshOAuthToken, OAuthResponse } from './Services/oauth/CallOauth.service';
11
+ export { requestWithRetry, postWithRetry, getWithRetry, putWithRetry, deleteWithRetry, patchWithRetry, HttpResponse, TokenRefreshError } from './Services/Http/HttpClient.service';
10
12
  export { SplitStrings } from './Services/SplitStrings';
11
13
  export { GetCompositionList, GetCompositionListWithId } from './Services/GetCompositionList';
12
14
  export { GetCompositionListLocal, GetCompositionListLocalWithId } from './Services/Local/GetCompositionListLocal';
@@ -89,7 +91,10 @@ export { UserBinaryTree } from './DataStructures/User/UserBinaryTree';
89
91
  export { FilterSearch } from './DataStructures/FilterSearch';
90
92
  export { SearchStructure } from './DataStructures/Search/SearchStructure';
91
93
  export { FreeSchemaResponse } from './DataStructures/Responses/ErrorResponse';
94
+ export { CCSConfig } from './DataStructures/CCSConfig';
95
+ import { CCSConfig } from './DataStructures/CCSConfig';
92
96
  export { BaseUrl } from './DataStructures/BaseUrl';
97
+ export { TokenStorage } from './DataStructures/Security/TokenStorage';
93
98
  export { SchemaQueryListener } from './WrapperFunctions/SchemaQueryObservable';
94
99
  export { FreeschemaQuery } from './DataStructures/Search/FreeschemaQuery';
95
100
  export { GiveConnection, GetAllTheConnectionsByTypeAndOfTheConcept } from './Services/Delete/GetAllConnectionByType';
@@ -117,7 +122,7 @@ declare function updateAccessToken(accessToken?: string): void;
117
122
  * It performs the following operations asynchronously:
118
123
  *
119
124
  * 1. Sets up base URLs for the main API and AI services
120
- * 2. Stores the authentication token for API requests
125
+ * 2. Stores the authentication token for API requests (or obtains one via OAuth)
121
126
  * 3. Initializes the system (database setup)
122
127
  * 4. Creates binary trees from concept data for efficient querying (by ID, character, and type)
123
128
  * 5. Creates local binary trees for offline/local concept management
@@ -128,22 +133,54 @@ declare function updateAccessToken(accessToken?: string): void;
128
133
  * are updated as each operation completes to indicate which data structures are ready for use.
129
134
  *
130
135
  * @param url - The base URL for the main backend API endpoint (e.g., 'https://api.example.com')
131
- * @param aiurl - The base URL for the AI service endpoint (e.g., 'https://ai.example.com')
132
- * @param accessToken - The bearer access token for authenticating API requests
136
+ * @param nodeUrl - The base URL for the Node.js service endpoint (optional)
137
+ * @param applicationName - The name of the application (used for OAuth and logging)
138
+ * @param config - Optional CCSConfig object containing all optional configuration parameters
133
139
  *
134
140
  * @example
135
141
  * ```typescript
136
- * // Initialize the system with backend URLs and auth token
137
- * init(
138
- * 'https://api.freeschema.com',
139
- * 'https://ai.freeschema.com',
140
- * 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
141
- * );
142
+ * // Simple initialization with just URL
143
+ * init('https://api.freeschema.com');
144
+ * ```
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * // Initialize with access token
149
+ * const config = new CCSConfig({
150
+ * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
151
+ * });
152
+ * init('https://api.freeschema.com', '', 'MyApp', config);
153
+ * ```
142
154
  *
143
- * // After initialization, check if data is loaded before querying
144
- * if (IdentifierFlags.isDataLoaded) {
145
- * // Safe to query concepts
146
- * }
155
+ * @example
156
+ * ```typescript
157
+ * // Initialize with OAuth credentials
158
+ * const config = new CCSConfig({
159
+ * clientId: '101084838',
160
+ * clientSecret: 'your-client-secret',
161
+ * aiUrl: 'https://ai.freeschema.com',
162
+ * enableAi: true
163
+ * });
164
+ * init('https://api.freeschema.com', '', 'MyApp', config);
165
+ * ```
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * // Full configuration
170
+ * const config = new CCSConfig({
171
+ * aiUrl: 'https://ai.example.com',
172
+ * accessToken: 'token',
173
+ * enableAi: true,
174
+ * flags: {
175
+ * logApplication: true,
176
+ * accessTracker: true
177
+ * },
178
+ * parameters: {
179
+ * logserver: 'https://logs.example.com'
180
+ * },
181
+ * storagePath: './data/ccs/'
182
+ * });
183
+ * init('https://api.example.com', 'http://localhost:5001', 'MyApp', config);
147
184
  * ```
148
185
  *
149
186
  * @remarks
@@ -154,9 +191,10 @@ declare function updateAccessToken(accessToken?: string): void;
154
191
  * - `isConnectionLoaded`, `isConnectionTypeLoaded` - Remote connection data ready
155
192
  * - `isLocalConnectionLoaded` - Local connection data ready
156
193
  *
194
+ * @see CCSConfig for all available configuration options
157
195
  * @see IdentifierFlags for checking initialization status
158
196
  * @see InitializeSystem for database initialization details
159
197
  * @see CreateBinaryTreeFromData for concept tree creation
160
198
  * @see https://documentation.freeschema.com/#installation for setup guide
161
199
  */
162
- declare function init(url?: string, aiurl?: string, accessToken?: string): void;
200
+ declare function init(url?: string, nodeUrl?: string, applicationName?: string, config?: CCSConfig): void;