@halix/action-sdk 1.0.19 → 1.0.21

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 (37) hide show
  1. package/lib/cjs/content.js +257 -0
  2. package/lib/cjs/data-crud.js +297 -0
  3. package/lib/cjs/index.js +53 -678
  4. package/lib/cjs/lists.js +175 -0
  5. package/lib/cjs/sdk-general.js +92 -0
  6. package/lib/cjs/types/content.d.ts +119 -0
  7. package/lib/cjs/types/content.d.ts.map +1 -0
  8. package/lib/cjs/types/data-crud.d.ts +156 -0
  9. package/lib/cjs/types/data-crud.d.ts.map +1 -0
  10. package/lib/cjs/types/index.d.ts +8 -578
  11. package/lib/cjs/types/index.d.ts.map +1 -1
  12. package/lib/cjs/types/lists.d.ts +212 -0
  13. package/lib/cjs/types/lists.d.ts.map +1 -0
  14. package/lib/cjs/types/sdk-general.d.ts +263 -0
  15. package/lib/cjs/types/sdk-general.d.ts.map +1 -0
  16. package/lib/cjs/types/utilities.d.ts +73 -0
  17. package/lib/cjs/types/utilities.d.ts.map +1 -0
  18. package/lib/cjs/utilities.js +131 -0
  19. package/lib/esm/content.js +228 -0
  20. package/lib/esm/content.js.map +1 -0
  21. package/lib/esm/data-crud.js +264 -0
  22. package/lib/esm/data-crud.js.map +1 -0
  23. package/lib/esm/index.js.map +1 -1
  24. package/lib/esm/index.mjs +26 -673
  25. package/lib/esm/lists.js +157 -0
  26. package/lib/esm/lists.js.map +1 -0
  27. package/lib/esm/sdk-general.js +138 -0
  28. package/lib/esm/sdk-general.js.map +1 -0
  29. package/lib/esm/types/content.d.ts +118 -0
  30. package/lib/esm/types/data-crud.d.ts +155 -0
  31. package/lib/esm/types/index.d.ts +8 -578
  32. package/lib/esm/types/lists.d.ts +211 -0
  33. package/lib/esm/types/sdk-general.d.ts +262 -0
  34. package/lib/esm/types/utilities.d.ts +72 -0
  35. package/lib/esm/utilities.js +126 -0
  36. package/lib/esm/utilities.js.map +1 -0
  37. package/package.json +12 -1
@@ -0,0 +1,212 @@
1
+ import { Observable } from 'rxjs';
2
+ /**
3
+ * SortField is an interface for specifying sort fields.
4
+ */
5
+ export interface SortField {
6
+ /** The attribute ID to sort by */
7
+ attributeId: string;
8
+ /** Whether to sort in descending order */
9
+ descending?: boolean;
10
+ /** Whether to perform case-insensitive comparison */
11
+ caseInsensitive?: boolean;
12
+ /** Whether to use auto-sequencing */
13
+ autoSequence?: boolean;
14
+ }
15
+ /**
16
+ * DataSortField represents a single sort field, wrapping an attribute ID and sort direction.
17
+ */
18
+ export interface DataSortField {
19
+ /** The ID of the attribute to sort by (can include relationship paths with dots, e.g. "customer.lastName") */
20
+ attributeId: string;
21
+ /** Whether to sort in descending order (true) or ascending order (false, default) */
22
+ descending?: boolean;
23
+ }
24
+ /**
25
+ * ListDataRequest is an interface defining the properties of a list data request.
26
+ * This request is used to retrieve list data from the Halix platform.
27
+ */
28
+ export interface ListDataRequest {
29
+ /**
30
+ * The ID of the root data element to retrieve.
31
+ */
32
+ dataElementId: string;
33
+ /**
34
+ * The 1-based page number to retrieve. Works with pageSize.
35
+ * Alternatively, you can use traditional offset/limit pagination.
36
+ */
37
+ pageNumber?: number;
38
+ /**
39
+ * The number of records per page. Works with pageNumber.
40
+ */
41
+ pageSize?: number;
42
+ /**
43
+ * Sort configuration - list of sort fields in priority order.
44
+ * Each field can include relationship paths (e.g., "customer.lastName").
45
+ */
46
+ sort?: DataSortField[];
47
+ /**
48
+ * The ID of the data element that defines the overall scope of records.
49
+ * The dataElementId must be related to this through a foreign key or key array.
50
+ * Works with parentKey to scope results. This is often an organization proxy
51
+ * or user proxy element, but not necessarily so.
52
+ */
53
+ parentDataElementId: string;
54
+ /**
55
+ * The key of an object that all records must be related to.
56
+ * Works with parentDataElementId to scope results.
57
+ */
58
+ parentKey?: string;
59
+ /**
60
+ * Optional field to specify the foreign key field on the root element that defines
61
+ * the relationship to the parent. If omitted, a derived key is assumed.
62
+ */
63
+ parentKeyField?: string;
64
+ /**
65
+ * Optional property to specify the relationship field for foreignKeySet relationships.
66
+ * Required when parent has multiple relationships to the child element.
67
+ */
68
+ childKeysField?: string;
69
+ /**
70
+ * Filter expression to limit results. Evaluated within the parent key scope.
71
+ * Uses `dataexpr` format.
72
+ */
73
+ filter?: string;
74
+ /**
75
+ * List of fields being displayed on the list. Only these fields are populated in
76
+ * returned objects to reduce payload size. If fields include relationship paths,
77
+ * those relationships are automatically retrieved.
78
+ */
79
+ displayFields?: string[];
80
+ /**
81
+ * Additional field values to include that may not be in displayFields, sort, or filters.
82
+ */
83
+ additionalFieldsToFetch?: string[];
84
+ }
85
+ /**
86
+ * ListDataResponse wraps a data provider response to a list data request.
87
+ */
88
+ export interface ListDataResponse {
89
+ /**
90
+ * A slice of the appropriate runtime struct type containing a single page-worth of data.
91
+ * The actual type of objects in this array depends on the dataElementId being queried.
92
+ */
93
+ data: any[];
94
+ /** The total number of entries across all pages */
95
+ total: number;
96
+ /**
97
+ * The index within the data array of the selected row.
98
+ * This value is provided when a search term is included in the data request.
99
+ */
100
+ selectedRow: number;
101
+ /** The 1-based page number included in this response */
102
+ pageNumber: number;
103
+ }
104
+ /**
105
+ * ListDataSearchOptions is an interface defining the search options for list data retrieval.
106
+ */
107
+ export interface ListDataSearchOptions {
108
+ /** The attribute ID to search by */
109
+ attributeId: string;
110
+ /** The value to search for */
111
+ value: string;
112
+ /** The total number of items in the list */
113
+ total: number;
114
+ }
115
+ /**
116
+ * ListDataOptions is an interface defining options for list data retrieval.
117
+ */
118
+ export interface ListDataOptions {
119
+ /** Whether to access the public endpoint (no authentication required) */
120
+ isPublic?: boolean;
121
+ /** Whether to bypass total count calculation for performance */
122
+ bypassTotal?: boolean;
123
+ /**
124
+ * Search options for binary search functionality; if provided, the response will include
125
+ * the page of data that contains the first occurrence of the search value. The selectedRow
126
+ * property will be set to the index of the first occurrence of the search value.
127
+ */
128
+ search?: ListDataSearchOptions;
129
+ }
130
+ /**
131
+ * getListData retrieves list data from the Halix platform. This function can operate in four
132
+ * different modes based on the provided options:
133
+ *
134
+ * 1. Authenticated list data retrieval (default)
135
+ * 2. Public list data retrieval (when isPublic is true)
136
+ * 3. Authenticated list data with search (when search options are provided)
137
+ * 4. Public list data with search (when both isPublic and search options are provided)
138
+ *
139
+ * The search functionality uses binary search to efficiently locate items in a sorted list by
140
+ * a specific attribute value.
141
+ *
142
+ * @param request - The list data request containing list configuration and parameters
143
+ * @param options - Optional configuration for the request
144
+ *
145
+ * @returns Promise resolving to the list data response
146
+ *
147
+ * @example
148
+ * // Basic authenticated list data retrieval
149
+ * const listData = await getListData({
150
+ * dataElementId: 'customer',
151
+ * parentDataElementId: 'company',
152
+ * parentKey: orgProxyKey,
153
+ * pageNumber: 1,
154
+ * pageSize: 50,
155
+ * displayFields: ['firstName', 'lastName', 'email']
156
+ * });
157
+ * console.log('Total customers:', listData.total);
158
+ * console.log('Page:', listData.pageNumber);
159
+ * console.log('Data:', listData.data);
160
+ *
161
+ * @example
162
+ * // Public list data retrieval without authentication
163
+ * const publicData = await getListData({
164
+ * dataElementId: 'product',
165
+ * parentDataElementId: 'catalog',
166
+ * parentKey: orgProxyKey,
167
+ * pageNumber: 1,
168
+ * pageSize: 20
169
+ * }, { isPublic: true });
170
+ *
171
+ * @example
172
+ * // List data retrieval with binary search
173
+ * const searchData = await getListData({
174
+ * dataElementId: 'purchases',
175
+ * parentDataElementId: 'customer',
176
+ * parentKey: userProxyKey,
177
+ * sort: [{ attributeId: 'invoiceNumber', descending: false }]
178
+ * }, {
179
+ * search: {
180
+ * attributeId: 'invoiceNumber',
181
+ * value: 'INV-123456',
182
+ * total: 1000
183
+ * }
184
+ * });
185
+ * console.log('Selected row index:', searchData.selectedRow);
186
+ */
187
+ export declare function getListData(request: ListDataRequest, options?: ListDataOptions): Promise<ListDataResponse>;
188
+ /**
189
+ * getListDataAsObservable retrieves list data from the Halix platform as an Observable. This
190
+ * function operates in the same four modes as getListData.
191
+ *
192
+ * @param request - The list data request containing list configuration and parameters
193
+ * @param options - Optional configuration for the request
194
+ *
195
+ * @returns Observable resolving to the list data response
196
+ *
197
+ * @example
198
+ * // Basic authenticated list data retrieval as Observable
199
+ * getListDataAsObservable({
200
+ * dataElementId: 'customer',
201
+ * parentDataElementId: 'company',
202
+ * parentKey: userContext.orgProxyKey,
203
+ * pageNumber: 1,
204
+ * pageSize: 50
205
+ * }).subscribe(response => {
206
+ * console.log('Total customers:', response.total);
207
+ * console.log('Page:', response.pageNumber);
208
+ * console.log('Data:', response.data);
209
+ * });
210
+ */
211
+ export declare function getListDataAsObservable(request: ListDataRequest, options?: ListDataOptions): Observable<ListDataResponse>;
212
+ //# sourceMappingURL=lists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../../src/lists.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAQ,UAAU,EAAiB,MAAM,MAAM,CAAC;AAOvD;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qDAAqD;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qCAAqC;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,8GAA8G;IAC9G,WAAW,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,EAAE,CAAC;IAEvB;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;;O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,CAAC,gBAAgB,CAAC,CAEzH"}
@@ -0,0 +1,263 @@
1
+ /**
2
+ * @module @halix/action-sdk/sdk-general
3
+ * @description Core SDK module providing global variables, initialization, and common types used
4
+ * across the entire SDK. This module includes:
5
+ * - Global variables for authentication, service configuration, and user context
6
+ * - initialize() function for setting up the SDK with incoming event data
7
+ * - Action response type definitions (ListActionResponse, FormTemplateActionResponse, etc.)
8
+ * - Response formatting helpers (prepareSuccessResponse, prepareErrorResponse)
9
+ * - Common interfaces (UserContext, IncomingEventBody, NotificationConfig)
10
+ *
11
+ * This module should be initialized by calling initialize() before using any other SDK functions.
12
+ * The global variables are then available for use and are automatically used by other SDK functions.
13
+ */
14
+ import { Observable } from 'rxjs';
15
+ /**
16
+ * authToken contains the authentication token that the action handler can use to make API requests
17
+ * to Halix web services. This value is set upon calling the initialize function with incoming event
18
+ * data.
19
+ */
20
+ export declare let getAuthToken: () => Observable<string>;
21
+ /**
22
+ * sandboxKey contains the sandbox key identifier; identifies the sandbox that the action handler is
23
+ * running in. The sandbox identifies the current solution. This value is set upon calling the
24
+ * initialize function with incoming event data.
25
+ */
26
+ export declare let sandboxKey: string;
27
+ /**
28
+ * serviceAddress contains the URL of the Halix service that the action handler can use to make API
29
+ * requests to. This value is set upon calling the initialize function with incoming event data.
30
+ */
31
+ export declare let serviceAddress: string;
32
+ /**
33
+ * actionSubject contains the identifier of the subject of the action. The subject is the object
34
+ * that the action is being performed on. The action subject's contents will differ depending on the
35
+ * context in which the action is being executed. This value is set upon calling the initialize
36
+ * function with incoming event data.
37
+ * - for formTemplateActions, the action subject is the data being edited on the form
38
+ * - for pageTemplateActions, the action subject is record containing the context variables and
39
+ * their corresponding values on the page
40
+ * - for objectSaveActions, the action subject is the object being saved
41
+ * - for calculatedFieldActions, the action subject is the object containing the calculated field
42
+ * - for singleValueActions, the action subject may differ depending on the caller
43
+ */
44
+ export declare let actionSubject: any;
45
+ /**
46
+ * userContext contains the user context information for the user that is executing the action.
47
+ * This value is set upon calling the initialize function with incoming event data.
48
+ */
49
+ export declare let userContext: UserContext;
50
+ /**
51
+ * params contains the parameters passed to the action. If an input dialog is used, params will
52
+ * contain the values entered in the dialog. This value is set upon calling the initialize
53
+ * function with incoming event data.
54
+ */
55
+ export declare let params: string;
56
+ /**
57
+ * useBody is a flag indicating how responses should be formatted. If true, the response will be
58
+ * returned as an object with the HTTP response code and ActionResponse in the body field. If false,
59
+ * the ActionResponse will be returned directly. Typically, this does not need to be set by the
60
+ * action handler and should remain false.
61
+ */
62
+ export declare let useBody: boolean;
63
+ /**
64
+ * initialize initializes the SDK with event data. This should be called at the beginning of the
65
+ * action handler to set up the SDK with incoming information, including context information, input
66
+ * parameters, and authentication information needed to make API requests to the Halix service.
67
+ *
68
+ * @param event - The event object containing authentication and context information
69
+ */
70
+ export declare function initialize(event: {
71
+ body?: IncomingEventBody;
72
+ }): void;
73
+ /**
74
+ * UserContext is an interface defining the properties of the user context.
75
+ */
76
+ export interface UserContext {
77
+ user: any;
78
+ userProxy: any;
79
+ orgProxy: any;
80
+ orgProxyKey: string;
81
+ orgKey: string;
82
+ userProxyKey: string;
83
+ }
84
+ /**
85
+ * IncomingEventBody is an interface defining the properties of an incoming event body. The halix
86
+ * platform provides these properties when an action is triggered.
87
+ */
88
+ export interface IncomingEventBody {
89
+ authToken?: string;
90
+ authTokenRetriever?: () => Observable<string>;
91
+ sandboxKey: string;
92
+ serviceAddress: string;
93
+ actionSubject: any;
94
+ userContext: UserContext;
95
+ params: Record<string, any>;
96
+ }
97
+ /**
98
+ * BaseActionResponse is an interface defining the base properties of an action response.
99
+ */
100
+ export interface BaseActionResponse {
101
+ /**
102
+ * The type of action response
103
+ *
104
+ * listAction - Use when the action is being run from a list
105
+ * formTemplateAction - Use when the action is being run from a form template
106
+ * pageTemplateAction - Use when the action is being run from a page template
107
+ * objectSaveAction - Use when the action has been specified for use on object save events
108
+ * calculatedFieldAction - Use when the action is being used to determine calculated field values
109
+ * singleValueAction - Use when the action is being used to determine a single value in specific
110
+ * build-in platform events (e.g., determining shopping cart prices)
111
+ * error - Use when the action is not successful
112
+ */
113
+ responseType: "listAction" | "formTemplateAction" | "pageTemplateAction" | "objectSaveAction" | "calculatedFieldAction" | "singleValueAction" | "error";
114
+ /** Whether the action is an error */
115
+ isError: boolean;
116
+ /** Notification configurations; present only if the action should trigger one or more notifications */
117
+ notificationConfigs?: NotificationConfig[];
118
+ }
119
+ /**
120
+ * ActionResponse is an interface defining the properties of an action response.
121
+ */
122
+ export type ActionResponse = ListActionResponse | FormTemplateActionResponse | PageTemplateActionResponse | ObjectSaveActionResponse | CalculatedFieldActionResponse | SingleValueActionResponse;
123
+ /**
124
+ * NotificationConfig is an interface defining a notification that should be triggered by a
125
+ * successful action response.
126
+ */
127
+ export interface NotificationConfig {
128
+ /** The ID of a notification definition setup within the solution */
129
+ notificationDefinitionId: string;
130
+ /** The key of the organization proxy */
131
+ organizationProxyKey: string;
132
+ /** The object type of the data associated with the notification */
133
+ dataObjectType: string;
134
+ /** The key of the data object associated with the notification */
135
+ dataObjectKey: string;
136
+ /** The parameters to pass to the notification */
137
+ params: Record<string, any>;
138
+ emailConfig?: {
139
+ /** The type of user proxy to send the email to */
140
+ recipientUserProxyType: string;
141
+ /** The keys of the user proxies to send the email to */
142
+ recipientUserProxyKeys: string[];
143
+ /** The email address of the sender */
144
+ fromEmailAddress?: string;
145
+ /** The name of the sender */
146
+ fromNameView?: string;
147
+ /** The email address to reply to */
148
+ replyEmailAddress?: string;
149
+ /** The email address to send the email to; use when sending emails to non-user proxies/free-form email addresses; can contain a comma-separated list of email addresses */
150
+ recipientEmail?: string;
151
+ };
152
+ smsConfig?: {
153
+ /** The type of user proxy to send the SMS to */
154
+ recipientUserProxyType: string;
155
+ /** The keys of the user proxies to send the SMS to */
156
+ recipientUserProxyKeys: string[];
157
+ /** The phone number to send the SMS to; can contain a comma-separated list of phone numbers */
158
+ recipientPhone: string;
159
+ };
160
+ pushConfig?: {
161
+ /** The type of user proxy to send the push notification to */
162
+ recipientUserProxyType: string;
163
+ /** The keys of the user proxies to send the push notification to */
164
+ recipientUserProxyKeys: string[];
165
+ /** The navigation data to pass to the push notification */
166
+ navigationData?: Record<string, string>;
167
+ };
168
+ }
169
+ /**
170
+ * ListActionResponse is an interface defining the properties of a list action response. These
171
+ * properties are expected by the list framework unpon receiving an action response from an action
172
+ * handler.
173
+ */
174
+ export interface ListActionResponse extends BaseActionResponse {
175
+ responseType: "listAction";
176
+ updatedSubject: any;
177
+ successMessage: string;
178
+ }
179
+ /**
180
+ * FormTemplateActionResponse is an interface defining the properties of a form template action
181
+ * response. These properties are expected by the form framework unpon receiving an action response
182
+ * from an action handler.
183
+ */
184
+ export interface FormTemplateActionResponse extends BaseActionResponse {
185
+ responseType: "formTemplateAction";
186
+ updatedSubject: any;
187
+ successMessage: string;
188
+ }
189
+ /**
190
+ * PageTemplateActionResponse is an interface defining the properties of a page template action
191
+ * response. These properties are expected by the page framework unpon receiving an action response
192
+ * from an action handler.
193
+ */
194
+ export interface PageTemplateActionResponse extends BaseActionResponse {
195
+ responseType: "pageTemplateAction";
196
+ successMessage: string;
197
+ updatedSubject?: Record<string, any>;
198
+ refreshPage?: boolean;
199
+ }
200
+ /**
201
+ * ObjectSaveActionResponse is an interface defining the properties of an object save action
202
+ * response. These properties are expected by the object save framework unpon receiving an action
203
+ * response from an action handler.
204
+ */
205
+ export interface ObjectSaveActionResponse extends BaseActionResponse {
206
+ responseType: "objectSaveAction";
207
+ updatedSubject: any;
208
+ successMessage: string;
209
+ }
210
+ /**
211
+ * CalculatedFieldActionResponse is an interface defining the properties of a calculated field
212
+ * action response. These properties are expected by the calculated field framework unpon receiving
213
+ * an action response from an action handler.
214
+ */
215
+ export interface CalculatedFieldActionResponse extends BaseActionResponse {
216
+ responseType: "calculatedFieldAction";
217
+ calculatedValue: any;
218
+ }
219
+ /**
220
+ * SingleValueActionResponse is an interface defining the properties of a single value action
221
+ * response. These properties are expected by the caller of the action.
222
+ */
223
+ export interface SingleValueActionResponse extends BaseActionResponse {
224
+ responseType: "singleValueAction";
225
+ successMessage: string;
226
+ value: any;
227
+ }
228
+ /**
229
+ * ErrorResponse is an interface defining the properties of an error response.
230
+ */
231
+ export interface ErrorResponse {
232
+ responseType: "error";
233
+ errorMessage: string;
234
+ }
235
+ /**
236
+ * prepareSuccessResponse prepares a success response in the appropriate format. The action handler
237
+ * should return an ActionResponse response when the action is successful. If useBody is true, the
238
+ * response will be returned as an object with the HTTP response code and the ActionResponse in the
239
+ * body field. If useBody is false, the ActionResponse will be returned directly.
240
+ *
241
+ * @param successResponse - The value to return
242
+ *
243
+ * @returns Formatted success response; an ActionResponse unless useBody is true
244
+ */
245
+ export declare function prepareSuccessResponse(successResponse: ActionResponse): {
246
+ statusCode: number;
247
+ body: string;
248
+ } | ActionResponse;
249
+ /**
250
+ * prepareErrorResponse prepares an error response in the appropriate format. The action handler
251
+ * should return an ErrorResponse response when the action is not successful. If useBody is true,
252
+ * the response will be returned as an object with the HTTP response code and the ErrorResponse in
253
+ * the body field. If useBody is false, the ErrorResponse will be returned directly.
254
+ *
255
+ * @param errorMessage - The error message
256
+ *
257
+ * @returns Formatted error response; an ErrorResponse unless useBody is true
258
+ */
259
+ export declare function prepareErrorResponse(errorMessage: string): {
260
+ statusCode: number;
261
+ body: string;
262
+ } | ErrorResponse;
263
+ //# sourceMappingURL=sdk-general.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-general.d.ts","sourceRoot":"","sources":["../../../src/sdk-general.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAM,MAAM,MAAM,CAAC;AAMtC;;;;GAIG;AACH,eAAO,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAElD;;;;GAIG;AACH,eAAO,IAAI,UAAU,EAAE,MAAM,CAAC;AAE9B;;;GAGG;AACH,eAAO,IAAI,cAAc,EAAE,MAAM,CAAC;AAElC;;;;;;;;;;;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E,MAAM,CAAA;CAAE,GAAG,aAAa,CAS/G"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @module @halix/action-sdk/utilities
3
+ * @description Utility functions for data manipulation and processing in the Halix Platform action SDK.
4
+ * This module provides helper functions for common data operations that are useful across various
5
+ * action handler scenarios.
6
+ *
7
+ * Key features:
8
+ * - sortObjectArray: In-place sorting of object arrays with multi-field priority sorting
9
+ * - compareValues: Flexible value comparison with support for strings, numbers, and null values
10
+ * - getValueFromObject: Extract values from nested objects using dot-notation paths
11
+ * - debounceFn: Debounce function calls to prevent excessive execution
12
+ */
13
+ /**
14
+ * SortField is an interface for specifying sort fields.
15
+ */
16
+ export interface SortField {
17
+ /** The attribute ID to sort by */
18
+ attributeId: string;
19
+ /** Whether to sort in descending order */
20
+ descending?: boolean;
21
+ /** Whether to perform case-insensitive comparison */
22
+ caseInsensitive?: boolean;
23
+ /** Whether to use auto-sequencing */
24
+ autoSequence?: boolean;
25
+ }
26
+ /**
27
+ * sortObjectArray is a helper function that sorts the passed array in place by the given
28
+ * attributes. Sorting by nested attributes in the form of a delimited attribute string are
29
+ * supported (e.g., "attribute.nestedAttribute").
30
+ *
31
+ * @param array - The array to sort
32
+ * @param sort - Array of sort field specifications
33
+ * @returns The sorted array
34
+ */
35
+ export declare function sortObjectArray<T>(array: Array<T>, sort: SortField[]): Array<T>;
36
+ /**
37
+ * compareValues is a helper function that compares two values for sorting purposes. If the values
38
+ * are strings, the comparison is case-insensitive. If the values are numbers, the comparison is
39
+ * performed numerically.
40
+ *
41
+ * @param valueA - First value to compare
42
+ * @param valueB - Second value to compare
43
+ * @param descending - Whether to sort in descending order
44
+ * @param caseInsensitive - Whether to perform case-insensitive comparison for strings
45
+ *
46
+ * @returns Comparison result (-1, 0, or 1)
47
+ */
48
+ export declare function compareValues(valueA: any, valueB: any, descending: boolean, caseInsensitive: boolean): number;
49
+ /**
50
+ * getValueFromObject is a helper function that extracts a value from an object using a dot-notation
51
+ * path. The path can include relationships. Relationship IDs may include a colon delimiter (e.g.,
52
+ * "accountMember:ownerAccountMemberKey") to specify the key of the related object. This is useful
53
+ * when an element has more than one relationship to the same object type. Otherwise, if only one
54
+ * relationship to the same object type exists, the key may be specified without the relationship ID
55
+ * (e.g., simply, "accountMember").
56
+ *
57
+ * @param object - The object to extract value from
58
+ * @param attribute - The attribute path (e.g., "user.address.city")
59
+ *
60
+ * @returns The extracted value
61
+ */
62
+ export declare function getValueFromObject(object: any, attribute: string): any;
63
+ /**
64
+ * debounceFn is a utility function that debounces a function call. It is used to prevent multiple
65
+ * calls to the same function within a short period of time.
66
+ *
67
+ * @param fn - The function to debounce
68
+ * @param wait - The number of milliseconds to wait before calling the function
69
+ *
70
+ * @returns The debounced function
71
+ */
72
+ export declare function debounceFn<T extends (...args: any[]) => void>(fn: T, wait?: number): (...args: Parameters<T>) => void;
73
+ //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../src/utilities.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;GAWG;AAMH;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qDAAqD;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qCAAqC;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAMD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAiB/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CA2B7G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG,CAuBtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,SAAM,IAEpE,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,UAIjC"}