@limetech/lime-web-components 6.7.0 → 6.8.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [6.8.0](https://github.com/Lundalogik/lime-web-components/compare/v6.7.0...v6.8.0) (2026-01-28)
2
+
3
+
4
+ ### Features
5
+
6
+
7
+ * **problem:** add problem provider interfaces ([a4d003f](https://github.com/Lundalogik/lime-web-components/commit/a4d003f3a8665185c7ec7a99458ebf671d541641))
8
+
1
9
  ## [6.7.0](https://github.com/Lundalogik/lime-web-components/compare/v6.6.0...v6.7.0) (2026-01-14)
2
10
 
3
11
 
@@ -1,28 +1,94 @@
1
1
  /**
2
- * Service for handling application level events
2
+ * Service for application-wide event communication
3
+ *
4
+ * The {@link EventDispatcher} enables loosely-coupled communication between
5
+ * components through a publish-subscribe pattern.
6
+ *
7
+ * Components can dispatch custom events and subscribe to events from other
8
+ * components without direct coupling. This is particularly useful for:
9
+ * - Cross-component communication
10
+ * - Responding to platform-level events (navigation, data changes)
11
+ * - Notifying other components of state changes
12
+ *
13
+ * @example
14
+ * Basic usage
15
+ * ```typescript
16
+ * const eventDispatcher = platform.get(PlatformServiceName.EventDispatcher);
17
+ *
18
+ * // Dispatch an event
19
+ * eventDispatcher.dispatch('data-changed', { id: 123 });
20
+ *
21
+ * // Listen for events
22
+ * const handler = (event: CustomEvent<{ id: number }>) => {
23
+ * console.log('Data changed:', event.detail.id);
24
+ * };
25
+ * eventDispatcher.addListener('data-changed', handler);
26
+ *
27
+ * // Clean up
28
+ * eventDispatcher.removeListener('data-changed', handler);
29
+ * ```
30
+ *
3
31
  * @public
4
32
  * @group Event dispatching
5
33
  */
6
34
  export interface EventDispatcher {
7
35
  /**
8
- * Dispatch a new event
36
+ * Dispatch a custom event to all registered listeners
9
37
  *
10
- * @param eventName - name of the event to dispatch
11
- * @param data - data attached to the event
38
+ * Creates and dispatches a `CustomEvent` with the provided data. All components
39
+ * that have registered listeners for this event name will be notified.
40
+ *
41
+ * @param eventName - Unique name identifying the event type
42
+ * @param data - Data payload to include in the event's `detail` property
43
+ * @returns The `CustomEvent` that was dispatched
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const eventDispatcher = platform.get(PlatformServiceName.EventDispatcher);
48
+ * eventDispatcher.dispatch('item-selected', { itemId: 42, name: 'Widget' });
49
+ * ```
12
50
  */
13
51
  dispatch<T>(eventName: string, data: T): CustomEvent<T>;
14
52
  /**
15
- * Add a new listener for a specific event
53
+ * Register a listener for a specific event type
54
+ *
55
+ * The listener function will be called whenever an event with the matching
56
+ * name is dispatched. The same listener can be registered multiple times,
57
+ * but should typically be registered only once per component instance.
58
+ *
59
+ * **Important:** Always remove listeners in `disconnectedCallback()` to
60
+ * prevent memory leaks.
16
61
  *
17
- * @param eventName - name of the event to listen to
18
- * @param listener - listener to invoke when the event is dispatched
62
+ * @param eventName - Name of the event to listen for
63
+ * @param listener - Callback function to invoke when the event is dispatched
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * eventDispatcher.addListener('message-received', (event) => {
68
+ * console.log('Message:', event.detail);
69
+ * });
70
+ * ```
19
71
  */
20
72
  addListener<T>(eventName: string, listener: (event: CustomEvent<T>) => void): void;
21
73
  /**
22
- * Stop listening for a specific event
74
+ * Unregister a previously registered event listener
75
+ *
76
+ * Removes the specified listener function for the given event name. The
77
+ * listener reference must be the same function instance that was passed
78
+ * to {@link addListener}.
79
+ *
80
+ * Always call this in `disconnectedCallback()` to clean up listeners and
81
+ * prevent memory leaks.
82
+ *
83
+ * @param eventName - Name of the event to stop listening for
84
+ * @param listener - The exact listener function that was previously registered
23
85
  *
24
- * @param eventName - name of the event to stop listening to
25
- * @param listener - listener to remove from the dispatcher
86
+ * @example
87
+ * ```typescript
88
+ * const handler = (event: CustomEvent<string>) => console.log(event.detail);
89
+ * eventDispatcher.addListener('message-received', handler);
90
+ * eventDispatcher.removeListener('message-received', handler);
91
+ * ```
26
92
  */
27
93
  removeListener<T>(eventName: string, listener: (event: CustomEvent<T>) => void): void;
28
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eventdispatcher.d.ts","sourceRoot":"","sources":["../../src/eventdispatcher/eventdispatcher.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAExD;;;;;OAKG;IACH,WAAW,CAAC,CAAC,EACT,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,IAAI,CAAC;IAER;;;;;OAKG;IACH,cAAc,CAAC,CAAC,EACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,IAAI,CAAC;CACX"}
1
+ {"version":3,"file":"eventdispatcher.d.ts","sourceRoot":"","sources":["../../src/eventdispatcher/eventdispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAExD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,WAAW,CAAC,CAAC,EACT,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,IAAI,CAAC;IAER;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,CAAC,CAAC,EACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,IAAI,CAAC;CACX"}
@@ -9,10 +9,28 @@ export interface SelectFiltersOptions extends StateOptions {
9
9
  limetype?: string;
10
10
  }
11
11
  /**
12
- * Gets a list of filters
12
+ * Decorator that subscribes to filters from the {@link FilterRepository}.
13
+ *
14
+ * This decorator automatically updates the decorated property whenever filters
15
+ * change in the platform. You can optionally filter by limetype or filter ID.
16
+ *
17
+ * @param options - Configuration including limetype/ID filtering and state transformation via {@link SelectFiltersOptions}
18
+ * @returns A PropertyDecorator that sets up automatic subscription to filters
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * @State()
23
+ * @SelectFilters()
24
+ * private filters: Filter[];
25
+ * ```
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * @State()
30
+ * @SelectFilters({ limetype: 'company' })
31
+ * private companyFilters: Filter[];
32
+ * ```
13
33
  *
14
- * @param options - state decorator options
15
- * @returns state decorator
16
34
  * @public
17
35
  * @group Filters
18
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../src/filter/decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,YAAY,EAEf,MAAM,SAAS,CAAC;AAGjB;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CACzB,OAAO,GAAE,oBAAyB,GACnC,iBAAiB,CAMnB"}
1
+ {"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../src/filter/decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,YAAY,EAEf,MAAM,SAAS,CAAC;AAGjB;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CACzB,OAAO,GAAE,oBAAyB,GACnC,iBAAiB,CAMnB"}
@@ -1,22 +1,100 @@
1
1
  import { Filter } from '../query';
2
2
  import { StateRepository } from '../core';
3
3
  /**
4
+ * Repository for managing saved filter definitions.
5
+ *
6
+ * {@link FilterRepository} provides methods to create, update, and delete {@link Filter}
7
+ * definitions. Filters are named, reusable query expressions that can be applied to
8
+ * limetypes to define subsets of objects (e.g., "My Active Deals", "High Priority Tickets").
9
+ *
10
+ * Filters can be:
11
+ * - System-wide (available to all users)
12
+ * - User-specific (private to a single user when `iduser` is set)
13
+ * - Referenced in {@link InFilterExpression}s for advanced queries
14
+ *
15
+ * The repository extends {@link StateRepository}, enabling:
16
+ * - Reactive subscriptions to filter changes
17
+ * - Automatic UI updates when filters are created or deleted
18
+ * - Integration with state decorators
19
+ *
20
+ * @example
21
+ * Basic usage
22
+ * ```typescript
23
+ * const repo = platform.get(PlatformServiceName.FilterRepository);
24
+ *
25
+ * const filter: Filter = {
26
+ * id: 'high_value_deals',
27
+ * limetype: 'deal',
28
+ * name: { 'en': 'High Value Deals' },
29
+ * filter: {
30
+ * op: Operator.AND,
31
+ * exp: [
32
+ * { key: 'status', op: Operator.EQUALS, exp: 'active' },
33
+ * { key: 'value', op: Operator.GREATER_OR_EQUAL, exp: 100000 }
34
+ * ]
35
+ * }
36
+ * };
37
+ *
38
+ * await repo.save(filter);
39
+ * ```
40
+ *
4
41
  * @public
5
42
  * @group Filters
43
+ * @see {@link Filter} for filter definition structure
44
+ * @see {@link Expression} for building filter expressions
45
+ * @see {@link InFilterExpression} for referencing filters in queries
46
+ * @see {@link StateRepository} for subscription patterns
6
47
  */
7
48
  export interface FilterRepository extends StateRepository {
8
49
  /**
9
- * Saves the new filter to the database
50
+ * Save a filter definition to the database.
10
51
  *
11
- * @param filter - a filter to save
12
- * @returns a promise that will be resolved when the filter is saved
52
+ * Creates a new filter or updates an existing one. The filter will be stored
53
+ * persistently and become available for use in queries and filter expressions.
54
+ *
55
+ * If a filter with the same `id` already exists, it will be updated with the
56
+ * new values. Otherwise, a new filter is created.
57
+ *
58
+ * @param filter - The {@link Filter} definition to save
59
+ * @returns Promise that resolves when the filter is saved
60
+ * @throws Error if save fails due to validation or permission issues
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const repo = platform.get(PlatformServiceName.FilterRepository);
65
+ *
66
+ * const filter: Filter = {
67
+ * id: 'my_deals',
68
+ * limetype: 'deal',
69
+ * name: { 'en': 'My Deals' },
70
+ * filter: { key: 'owner', op: Operator.EQUALS, exp: currentUserId }
71
+ * };
72
+ *
73
+ * await repo.save(filter);
74
+ * ```
75
+ *
76
+ * @see {@link Filter} for the filter structure
77
+ * @see {@link Expression} for building filter expressions
78
+ * @see {@link delete} to remove a filter
13
79
  */
14
80
  save(filter: Filter): Promise<void>;
15
81
  /**
16
- * Deletes the filter
82
+ * Delete a filter from the database.
83
+ *
84
+ * Permanently removes the specified filter. This operation cannot be undone.
85
+ *
86
+ * @param filter - The {@link Filter} to delete
87
+ * @returns Promise that resolves when the filter is deleted
88
+ * @throws Error if deletion fails due to permissions or other issues
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const repo = platform.get(PlatformServiceName.FilterRepository);
93
+ * await repo.delete(filter);
94
+ * ```
17
95
  *
18
- * @param filter - a filter to delete
19
- * @returns a promise that will be resolved when the filter is deleted
96
+ * @see {@link Filter} for the filter structure
97
+ * @see {@link save} to create or update a filter
20
98
  */
21
99
  delete(filter: Filter): Promise<void>;
22
100
  }
@@ -1 +1 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/filter/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACrD;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC"}
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/filter/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpC;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC"}
@@ -1,76 +1,227 @@
1
1
  /**
2
- * HTTP service for sending requests to a given URL
2
+ * HTTP service for sending requests to backend endpoints
3
3
  *
4
- * By default, the service will work with the JSON data format. If anything but JSON is returned from the endpoint,
5
- * the `responseType` property in the `options` parameter needs to be set.
4
+ * The {@link HttpClient} is the primary interface for making HTTP requests
5
+ * within the Lime platform.
6
+ *
7
+ * By default, all requests expect JSON responses. For other content types
8
+ * (text, binary data, etc.), set the `responseType` in {@link HttpOptions}.
9
+ *
10
+ * All methods throw {@link HttpResponseError} on HTTP errors (4xx, 5xx status codes).
11
+ *
12
+ * @example
13
+ * Basic GET request for JSON data
14
+ * ```typescript
15
+ * const http = platform.get(PlatformServiceName.Http);
16
+ * const data = await http.get('my_addon/endpoint');
17
+ * console.log(data);
18
+ * ```
19
+ *
20
+ * @example
21
+ * POST request with data and query parameters
22
+ * ```typescript
23
+ * const http = platform.get(PlatformServiceName.Http);
24
+ * const response = await http.post(
25
+ * 'my_addon/users',
26
+ * { name: 'John Doe', email: 'john@example.com' },
27
+ * { params: { notify: 'true' } }
28
+ * );
29
+ * ```
30
+ *
31
+ * @example
32
+ * Error handling with HttpResponseError
33
+ * ```typescript
34
+ * const http = platform.get(PlatformServiceName.Http);
35
+ * try {
36
+ * const data = await http.get('my_addon/endpoint');
37
+ * } catch (error) {
38
+ * if (error.name === 'HttpResponseError') {
39
+ * console.error(`HTTP ${error.status}: ${error.message}`);
40
+ * console.error('Response:', error.response);
41
+ * }
42
+ * }
43
+ * ```
44
+ *
45
+ * @example
46
+ * Downloading a file as blob
47
+ * ```typescript
48
+ * const http = platform.get(PlatformServiceName.Http);
49
+ * const blob = await http.get('my_addon/download/report.pdf', {
50
+ * responseType: 'blob'
51
+ * });
52
+ * const url = URL.createObjectURL(blob);
53
+ * window.open(url);
54
+ * ```
6
55
  *
7
56
  * @public
8
57
  * @group HTTP
9
58
  */
10
59
  export interface HttpClient {
11
60
  /**
12
- * Sends a get request.
61
+ * Sends a GET request to retrieve data from the server
13
62
  *
14
- * @param url - Url to resource (for instance my_addon/endpoint).
15
- * @param options - The HTTP options to send with the request.
16
- * @returns
63
+ * @param url - Relative URL to the resource (e.g., 'my_addon/endpoint').
64
+ * The URL is relative to the Lime CRM base URL.
65
+ * @param options - Optional {@link HttpOptions} for query parameters, headers, or response type
66
+ * @returns Promise resolving to the response data. Type depends on {@link HttpOptions.responseType}
67
+ *
68
+ * @throws {@link HttpResponseError} when the server responds with an error status (4xx, 5xx)
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const http = platform.get(PlatformServiceName.Http);
73
+ * const users = await http.get('my_addon/users', {
74
+ * params: { active: 'true', limit: '10' }
75
+ * });
76
+ * ```
17
77
  */
18
78
  get(url: string, options?: HttpOptions): Promise<any>;
19
79
  /**
20
- * Sends a post request.
80
+ * Sends a POST request to create new data on the server
81
+ *
82
+ * @param url - Relative URL to the resource (e.g., 'my_addon/endpoint')
83
+ * @param data - Payload to send in the request body. Will be JSON-encoded by default.
84
+ * @param options - Optional {@link HttpOptions} for query parameters, headers, or response type
85
+ * @returns Promise resolving to the response data. Type depends on {@link HttpOptions.responseType}
21
86
  *
22
- * @param url - Url to resource (for instance my_addon/endpoint).
23
- * @param data - Payload to send to the server.
24
- * @param options - The HTTP options to send with the request.
25
- * @returns
87
+ * @throws {@link HttpResponseError} when the server responds with an error status (4xx, 5xx)
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const http = platform.get(PlatformServiceName.Http);
92
+ * const newUser = await http.post('my_addon/users', {
93
+ * name: 'Jane Smith',
94
+ * email: 'jane@example.com'
95
+ * });
96
+ * ```
26
97
  */
27
98
  post(url: string, data?: object, options?: HttpOptions): Promise<any>;
28
99
  /**
29
- * Sends a patch request.
100
+ * Sends a PATCH request to partially update existing data on the server
101
+ *
102
+ * @param url - Relative URL to the resource (e.g., 'my_addon/users/123')
103
+ * @param data - Partial payload containing only the fields to update
104
+ * @param options - Optional {@link HttpOptions} for query parameters, headers, or response type
105
+ * @returns Promise resolving to the response data. Type depends on {@link HttpOptions.responseType}
30
106
  *
31
- * @param url - Url to resource (for instance my_addon/endpoint).
32
- * @param data - Payload to send to the server.
33
- * @param options - The HTTP options to send with the request.
34
- * @returns
107
+ * @throws {@link HttpResponseError} when the server responds with an error status (4xx, 5xx)
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const http = platform.get(PlatformServiceName.Http);
112
+ * await http.patch('my_addon/users/123', {
113
+ * email: 'newemail@example.com'
114
+ * });
115
+ * ```
35
116
  */
36
117
  patch(url: string, data?: object, options?: HttpOptions): Promise<any>;
37
118
  /**
38
- * Sends a put request.
119
+ * Sends a PUT request to replace existing data on the server
120
+ *
121
+ * @param url - Relative URL to the resource (e.g., 'my_addon/users/123')
122
+ * @param data - Complete payload to replace the existing resource
123
+ * @param options - Optional {@link HttpOptions} for query parameters, headers, or response type
124
+ * @returns Promise resolving to the response data. Type depends on {@link HttpOptions.responseType}
125
+ *
126
+ * @throws {@link HttpResponseError} when the server responds with an error status (4xx, 5xx)
39
127
  *
40
- * @param url - Url to resource (for instance my_addon/endpoint).
41
- * @param data - Payload to send to the server.
42
- * @param options - The HTTP options to send with the request.
43
- * @returns
128
+ * @example
129
+ * ```typescript
130
+ * const http = platform.get(PlatformServiceName.Http);
131
+ * await http.put('my_addon/users/123', {
132
+ * name: 'Jane Doe',
133
+ * email: 'jane@example.com',
134
+ * role: 'admin'
135
+ * });
136
+ * ```
44
137
  */
45
138
  put(url: string, data?: object, options?: HttpOptions): Promise<any>;
46
139
  /**
47
- * Sends a delete request.
140
+ * Sends a DELETE request to remove data from the server
141
+ *
142
+ * @param url - Relative URL to the resource (e.g., 'my_addon/users/123')
143
+ * @param options - Optional {@link HttpOptions} for query parameters or headers
144
+ * @returns Promise resolving to the response data. Type depends on {@link HttpOptions.responseType}
145
+ *
146
+ * @throws {@link HttpResponseError} when the server responds with an error status (4xx, 5xx)
48
147
  *
49
- * @param url - Url to resource (for instance my_addon/endpoint).
50
- * @param options - The HTTP options to send with the request.
51
- * @returns
148
+ * @example
149
+ * ```typescript
150
+ * const http = platform.get(PlatformServiceName.Http);
151
+ * await http.delete('my_addon/users/123');
152
+ * ```
52
153
  */
53
154
  delete(url: string, options?: HttpOptions): Promise<any>;
54
155
  }
55
156
  /**
157
+ * Configuration options for HTTP requests
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * const http = platform.get(PlatformServiceName.Http);
162
+ * const options: HttpOptions = {
163
+ * params: { search: 'John', limit: '10' },
164
+ * headers: { 'X-Custom-Header': 'value' },
165
+ * responseType: 'json'
166
+ * };
167
+ * const data = await http.get('my_addon/users', options);
168
+ * ```
169
+ *
56
170
  * @public
57
171
  * @group HTTP
58
172
  */
59
173
  export interface HttpOptions {
60
174
  /**
61
- * Query parameters to include in the request
175
+ * Query parameters to append to the URL
176
+ *
177
+ * Parameters will be URL-encoded and appended to the request URL.
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * // Results in: my_addon/users?active=true&role=admin&role=user
182
+ * const params = {
183
+ * active: 'true',
184
+ * role: ['admin', 'user']
185
+ * };
186
+ * ```
62
187
  */
63
188
  params?: HttpParams;
64
189
  /**
65
- * Additional HTTP-headers to send in the request
190
+ * Additional HTTP headers to include in the request
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * const headers = {
195
+ * 'Authorization': 'Bearer token123',
196
+ * 'Accept-Language': 'en-US'
197
+ * };
198
+ * ```
66
199
  */
67
200
  headers?: HttpHeaders;
68
201
  /**
69
- * Type of the response that is returned. Defaults to `json`
202
+ * Expected response data type. Defaults to 'json'
203
+ *
204
+ * - `json`: Parse response as JSON (default)
205
+ * - `text`: Get response as plain text string
206
+ * - `blob`: Get response as binary Blob (for file downloads)
207
+ * - `arraybuffer`: Get response as ArrayBuffer (for binary data processing)
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * // Download PDF file
212
+ * const pdfBlob = await http.get('my_addon/report.pdf', {
213
+ * responseType: 'blob'
214
+ * });
215
+ * ```
70
216
  */
71
217
  responseType?: HttpResponseType;
72
218
  }
73
219
  /**
220
+ * URL query parameters for HTTP requests
221
+ *
222
+ * Key-value pairs that will be appended to the request URL as query string.
223
+ * Array values will be repeated for the same parameter name.
224
+ *
74
225
  * @public
75
226
  * @group HTTP
76
227
  */
@@ -78,6 +229,11 @@ export interface HttpParams {
78
229
  [param: string]: string | string[];
79
230
  }
80
231
  /**
232
+ * HTTP headers for requests
233
+ *
234
+ * Custom headers to include in the HTTP request. Array values will be
235
+ * joined as comma-separated values for the same header name.
236
+ *
81
237
  * @public
82
238
  * @group HTTP
83
239
  */
@@ -85,15 +241,33 @@ export interface HttpHeaders {
85
241
  [header: string]: string | string[];
86
242
  }
87
243
  /**
244
+ * Response data type for HTTP requests
245
+ *
246
+ * Determines how the response body will be parsed and returned.
247
+ *
88
248
  * @public
89
249
  * @group HTTP
90
250
  */
91
251
  export type HttpResponseType = 'text' | 'json' | 'arraybuffer' | 'blob';
92
252
  /**
93
- * Defines the HTTP methods as constants.
94
- * Used in the UploadFile class in lime-crm-components
253
+ * HTTP method constants
254
+ *
255
+ * Standard HTTP methods as constant values. Useful for type-safe method
256
+ * selection in custom HTTP utilities.
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * function makeRequest(method: HttpMethod, url: string) {
261
+ * if (method === HttpMethod.Get) {
262
+ * // Handle GET request
263
+ * }
264
+ * }
265
+ *
266
+ * makeRequest(HttpMethod.Post, 'my_addon/endpoint');
267
+ * ```
95
268
  *
96
269
  * @public
270
+ * @group HTTP
97
271
  */
98
272
  export declare const HttpMethod: {
99
273
  readonly Get: "GET";
@@ -103,26 +277,59 @@ export declare const HttpMethod: {
103
277
  readonly Patch: "PATCH";
104
278
  };
105
279
  /**
106
- * Type definition for HTTP methods. It can be any of the values defined in the
107
- * HttpMethod constant.
280
+ * Type definition for HTTP methods
281
+ *
282
+ * Union type of all values in the {@link HttpMethod} constant.
108
283
  *
109
284
  * @public
285
+ * @group HTTP
110
286
  */
111
287
  export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];
112
288
  /**
113
- * Exception thrown by {@link HttpClient} when an error occurs while sending a
114
- * request
289
+ * Error thrown when an HTTP request fails
290
+ *
291
+ * This error is thrown by {@link HttpClient} methods when the server responds
292
+ * with an error status code (4xx or 5xx).
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * const http = platform.get(PlatformServiceName.Http);
297
+ *
298
+ * try {
299
+ * const data = await http.get('my_addon/data');
300
+ * } catch (error) {
301
+ * if (error.name !== 'HttpResponseError') {
302
+ * throw error;
303
+ * }
304
+ *
305
+ * if (error.status === 404) {
306
+ * console.error('Resource not found');
307
+ * } else if (error.status >= 500) {
308
+ * console.error('Server error:', error.status);
309
+ * }
310
+ *
311
+ * const body = await error.response.text();
312
+ * console.error('Response body:', body);
313
+ * }
314
+ * ```
115
315
  *
116
316
  * @public
317
+ * @group HTTP
117
318
  */
118
319
  export interface HttpResponseError extends Error {
119
320
  name: 'HttpResponseError';
120
321
  /**
121
- * Http status code
322
+ * HTTP status code from the failed response
122
323
  */
123
324
  status: number;
124
325
  /**
125
- * The response from the request
326
+ * The full Response object from the failed request
327
+ *
328
+ * Use this to access response headers or read the response body:
329
+ * ```typescript
330
+ * const body = await error.response.text();
331
+ * const contentType = error.response.headers.get('content-type');
332
+ * ```
126
333
  */
127
334
  response: Response;
128
335
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACvB;;;;;;OAMG;IAEH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAEtD;;;;;;;OAOG;IAEH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAEtE;;;;;;;OAOG;IAEH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAEvE;;;;;;;OAOG;IAEH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAErE;;;;;;OAMG;IAEH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAC5D;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IAEpB;;OAEG;IACH,OAAO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