@halix/action-sdk 1.0.5 → 1.0.7

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/LICENSE CHANGED
@@ -1,201 +1,30 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
1
+ Copyright (c) 2025 halix.io LLC
4
2
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this Software and associated documentation files (the “Software”), to view,
5
+ use, copy, modify, and distribute the Software, subject to the following conditions:
6
6
 
7
- 1. Definitions.
7
+ 1. **Permitted Use**
8
+ The Software may only be used:
9
+ - Within applications, extensions, or services that are built, hosted, or executed on the Halix platform (“Halix Platform”), and
10
+ - In accordance with the Halix Platform’s published SDK integration guidelines and technical requirements.
8
11
 
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
12
+ 2. **Prohibited Use**
13
+ You may not:
14
+ - Use the Software in any application, system, or environment that is not running on or deployed via the Halix Platform;
15
+ - Integrate, link, compile, or otherwise incorporate the Software into non-Halix systems;
16
+ - Use the Software to build tools that replicate or compete with the Halix Platform;
17
+ - Remove, obscure, or alter any copyright, trademark, or other proprietary notices.
11
18
 
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
19
+ 3. **No Warranty**
20
+ The Software is provided “as is,” without warranty of any kind, express or implied, including but not limited to warranties of merchantability or fitness for a particular purpose. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability.
14
21
 
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
+ 4. **Termination**
23
+ This license is automatically terminated if you violate any of its terms. Upon termination, you must cease all use of the Software and destroy all copies in your possession.
22
24
 
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
+ 5. **Commercial Licensing**
26
+ For use cases outside the scope of this license (e.g., use in non-Halix systems), please contact [your email or company] to obtain a commercial license.
25
27
 
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
28
+ ---
29
29
 
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
30
+ This License is not an open source license and does not grant any rights under any open source definition.
package/README.md CHANGED
@@ -1,2 +1,121 @@
1
- # halixsdk
2
- Halix Platform action SDK
1
+ # Halix Action SDK
2
+
3
+ The **Halix Action SDK** (`@halix/action-sdk`) provides a development framework for creating NodeJS Lambda-based actions that run inside the [Halix Platform](https://halix.io). It offers a streamlined API for handling incoming events, interacting with Halix data services, and sending structured responses back to the platform.
4
+
5
+ > 📌 **Note:** This SDK is **source-available** and is **licensed for use only within applications running on the Halix platform.**
6
+ > See the [LICENSE](./LICENSE) file for full terms.
7
+
8
+ ---
9
+ ## 📦 Installation
10
+
11
+ No installation is required.
12
+
13
+ The `@halix/action-sdk` is **natively available in the Halix platform runtime** and does not need to be manually installed or included via NPM.
14
+
15
+ Import the SDK using ECMAScript module syntax:
16
+
17
+ ```js
18
+ import * as hx from '@halix/action-sdk';
19
+ ```
20
+
21
+ This makes all SDK utilities available under the `hx.` namespace for clean and consistent access throughout your action logic.
22
+
23
+ ---
24
+
25
+ ## 🚀 Getting Started
26
+
27
+ Here’s a minimal example of a Halix action written in Node.js with ES module syntax:
28
+
29
+ ```js
30
+ import * as hx from '@halix/action-sdk';
31
+
32
+ export const handler = async (event) => {
33
+ // Initialize the SDK with incoming event context
34
+ hx.initialize(event);
35
+
36
+ // Get the subject of the action
37
+ const obj = hx.actionSubject;
38
+
39
+ // Refresh the object from the server
40
+ let fullObj;
41
+ try {
42
+ fullObj = await hx.getObject("exampleType", obj.objKey);
43
+ } catch (err) {
44
+ console.error("Error fetching object", err);
45
+ return hx.prepareErrorResponse("Failed to retrieve data");
46
+ }
47
+
48
+ // Perform updates or logic
49
+ fullObj.status = "Updated";
50
+
51
+ // Save the updated object
52
+ let saved;
53
+ try {
54
+ saved = await hx.saveRelatedObject("parentType", fullObj.parentKey, "exampleType", fullObj);
55
+ } catch (err) {
56
+ console.error("Error saving object", err);
57
+ return hx.prepareErrorResponse("Failed to save data");
58
+ }
59
+
60
+ // Return a success response
61
+ return hx.prepareSuccessResponse({
62
+ responseType: "formTemplateAction",
63
+ updatedSubject: saved,
64
+ successMessage: "Object saved successfully",
65
+ isError: false
66
+ });
67
+ };
68
+ ```
69
+
70
+ This action pattern is typical for use in Halix’s Lambda-style runtime environment.
71
+
72
+ ---
73
+
74
+ ## 📘 Key Concepts
75
+
76
+ - `authToken`: Auth token for secure API calls
77
+ - `sandboxKey`: Identifies the current Halix solution environment
78
+ - `actionSubject`: Object being acted on (varies by context)
79
+ - `userContext`: Info about the executing user
80
+ - `params`: Inputs passed to the action
81
+
82
+ ---
83
+
84
+ ## 🛠️ Core Functions
85
+
86
+ | Function | Description |
87
+ |----------|-------------|
88
+ | `initialize(event)` | Initializes the SDK with event context |
89
+ | `getObject(...)`, `getRelatedObjects(...)` | Retrieve objects from the Halix data layer |
90
+ | `saveRelatedObject(...)` | Save objects and establish relationships |
91
+ | `prepareSuccessResponse(...)` | Create a success response |
92
+ | `prepareErrorResponse(...)` | Create an error response |
93
+ | `sortObjectArray(...)` | Utility to sort object arrays |
94
+ | `getValueFromObject(...)` | Access nested or relationship-based attributes |
95
+
96
+ See [Full Documentation](https://mmastrangelo.github.io/halixsdk/) for more information.
97
+
98
+ ---
99
+
100
+ ## 🔐 License
101
+
102
+ **Halix SDK License v1.0**
103
+
104
+ This SDK is licensed for **use only within applications running on the Halix platform**, in accordance with Halix SDK guidelines.
105
+
106
+ - **You may not** use this SDK outside the Halix platform.
107
+ - Full license text is available in the [LICENSE](./LICENSE) file.
108
+
109
+ For commercial licensing outside this scope, contact [hello@halix.io](mailto:hello@halix.io).
110
+
111
+ ---
112
+
113
+ ## 🧰 Contributing
114
+
115
+ This repository is source-available but not open source. Contributions are currently limited to internal Halix developers and partners. Please open an issue to discuss improvements or bug reports.
116
+
117
+ ---
118
+
119
+ ## 🧭 About Halix
120
+
121
+ Halix is a low-code platform designed to empower developers and business users to build powerful applications quickly. Learn more at [halix.io](https://halix.io).
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,12 @@
1
1
  "use strict";
2
+ // Halix SDK License v1.0
3
+ // Copyright (c) 2025 halix.io LLC.
4
+ //
5
+ // This source code is licensed for use **only** within applications
6
+ // running on the Halix platform, in accordance with Halix SDK guidelines.
7
+ //
8
+ // Unauthorized use outside the Halix platform is prohibited.
9
+ // Full license terms available in the LICENSE file.
2
10
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
11
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
12
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -12,13 +20,63 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
20
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
21
  };
14
22
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.initialize = exports.prepareErrorResponse = exports.prepareSuccessResponse = exports.getValueFromObject = exports.compareValues = exports.sortObjectArray = exports.saveRelatedObject = exports.getObject = exports.getRelatedObjects = exports.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.authToken = void 0;
23
+ exports.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.authToken = void 0;
24
+ exports.getRelatedObjects = getRelatedObjects;
25
+ exports.getRelatedObjectsAsObservable = getRelatedObjectsAsObservable;
26
+ exports.getObject = getObject;
27
+ exports.getObjectAsObservable = getObjectAsObservable;
28
+ exports.saveRelatedObject = saveRelatedObject;
29
+ exports.saveRelatedObjectAsObservable = saveRelatedObjectAsObservable;
30
+ exports.sortObjectArray = sortObjectArray;
31
+ exports.compareValues = compareValues;
32
+ exports.getValueFromObject = getValueFromObject;
33
+ exports.prepareSuccessResponse = prepareSuccessResponse;
34
+ exports.prepareErrorResponse = prepareErrorResponse;
35
+ exports.initialize = initialize;
36
+ /**
37
+ * @module @halix/action-sdk
38
+ * @description Halix Platform action SDK for developing NodeJS Lambda-based actions on the Halix
39
+ * platform. Defines a framework for accepting incoming events from the Halix platform, making API
40
+ * requests to the Halix data service, and returning structured action responses back to the Halix
41
+ * platform.
42
+ */
16
43
  const axios_1 = __importDefault(require("axios"));
17
- function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
44
+ const rxjs_1 = require("rxjs");
45
+ /**
46
+ * getRelatedObjects retrieves an array of objects from the the database. The objects returned are
47
+ * related to a parent through a defined relationship in the schema. In a typical setup, action's
48
+ * auth token must have scope access to the parent object in order to access all of its related
49
+ * objects.
50
+ *
51
+ * It is common to use getRelatedObjects to retrieve all objects belonging to the current user proxy
52
+ * or organization proxy. For example, in a user context where the current user proxy element is
53
+ * "customer," an action might want to retrieve all "purchase" objects related to the current
54
+ * customer. Similarly, in an organization context where the current organization proxy is
55
+ * "business," an action might want to retrieve all "employee" objects related to the current
56
+ * business.
57
+ *
58
+ * @param parentElementId - The ID of the parent element
59
+ * @param parentKey - The key of the parent object
60
+ * @param elementId - The ID of the element
61
+ * @param filter - Optional filter criteria for the query; if not provided, all related objects will
62
+ * be returned
63
+ * @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
64
+ * objects will include the specified related objects as nested objects
65
+ *
66
+ * @returns Promise resolving to an array of objects
67
+ */
68
+ function getRelatedObjects(parentElementId, parentKey, elementId, filter, fetchedRelationships) {
18
69
  return __awaiter(this, void 0, void 0, function* () {
19
70
  let params;
20
- if (filter) {
21
- params = new URLSearchParams({ filter: filter });
71
+ if (filter || fetchedRelationships) {
72
+ let p = {};
73
+ if (filter) {
74
+ p.filter = filter;
75
+ }
76
+ if (fetchedRelationships) {
77
+ p.fetchedRelationships = fetchedRelationships.join(",");
78
+ }
79
+ params = new URLSearchParams(p);
22
80
  }
23
81
  let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
24
82
  console.log("Sending GET request to " + url + " with token " + exports.authToken);
@@ -29,18 +87,89 @@ function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
29
87
  return response.data;
30
88
  });
31
89
  }
32
- exports.getRelatedObjects = getRelatedObjects;
33
- function getObject(dataElementId, key) {
90
+ /**
91
+ * getRelatedObjectsAsObservable retrieves an array of objects from the the database. The objects
92
+ * returned are related to a parent through a defined relationship in the schema. In a typical
93
+ * setup, action's auth token must have scope access to the parent object in order to access all of
94
+ * its related objects.
95
+ *
96
+ * It is common to use getRelatedObjects to retrieve all objects belonging to the current user proxy
97
+ * or organization proxy. For example, in a user context where the current user proxy element is
98
+ * "customer," an action might want to retrieve all "purchase" objects related to the current
99
+ * customer. Similarly, in an organization context where the current organization proxy is
100
+ * "business," an action might want to retrieve all "employee" objects related to the current
101
+ * business.
102
+ *
103
+ * @param parentElementId - The ID of the parent element
104
+ * @param parentKey - The key of the parent element
105
+ * @param elementId - The ID of the element
106
+ * @param filter - Optional filter criteria for the query; if not provided, all related objects will
107
+ * be returned
108
+ * @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
109
+ * objects will include the specified related objects as nested objects
110
+ *
111
+ * @returns Observable resolving to an array of objects
112
+ */
113
+ function getRelatedObjectsAsObservable(parentElementId, parentKey, elementId, filter, fetchedRelationships) {
114
+ return (0, rxjs_1.from)(getRelatedObjects(parentElementId, parentKey, elementId, filter, fetchedRelationships));
115
+ }
116
+ /**
117
+ * getObject retrieves a single object from the database by its data element ID and key.
118
+ *
119
+ * @param dataElementId - The ID of the data element
120
+ * @param key - The key of the object
121
+ * @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
122
+ * object will include the specified related objects as nested objects
123
+ * @returns Promise resolving to the object data
124
+ */
125
+ function getObject(dataElementId, key, fetchedRelationships) {
34
126
  return __awaiter(this, void 0, void 0, function* () {
127
+ let params;
128
+ if (fetchedRelationships) {
129
+ let p = {};
130
+ if (fetchedRelationships) {
131
+ p.fetchedRelationships = fetchedRelationships.join(",");
132
+ }
133
+ params = new URLSearchParams(p);
134
+ }
35
135
  let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${dataElementId}/${key}`;
36
136
  console.log("Sending GET request to " + url + " with token " + exports.authToken);
37
137
  let response = yield axios_1.default.get(url, {
38
138
  headers: { "Authorization": `Bearer ${exports.authToken}` },
139
+ params: params,
39
140
  });
40
141
  return response.data;
41
142
  });
42
143
  }
43
- exports.getObject = getObject;
144
+ /**
145
+ * getObjectAsObservable retrieves a single object from the database by its data element ID and key.
146
+ *
147
+ * @param dataElementId - The ID of the data element
148
+ * @param key - The key of the object
149
+ * @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
150
+ * object will include the specified related objects as nested objects
151
+ *
152
+ * @returns Observable resolving to the object data
153
+ */
154
+ function getObjectAsObservable(dataElementId, key, fetchedRelationships) {
155
+ return (0, rxjs_1.from)(getObject(dataElementId, key, fetchedRelationships));
156
+ }
157
+ /**
158
+ * saveRelatedObject saves a related object to the database. The objectToSave is saved, and its
159
+ * relationship to the parent object is established based on the relationship specified in the
160
+ * schema. The objectToSave must have a relationship to the parent object and the user must have
161
+ * scope access to the parent object.
162
+ *
163
+ * @param parentElementId - The ID of the parent element
164
+ * @param parentKey - The key of the parent object
165
+ * @param elementId - The element ID of the object to save
166
+ * @param objectToSave - The object data to save (as a JSON string)
167
+ * @param opts - Optional save options
168
+ *
169
+ * @returns Promise resolving to saved object, including any updates made to the object during the
170
+ * save operation (such as assigning an objKey if the object is new), or the assignment of
171
+ * calculated values
172
+ */
44
173
  function saveRelatedObject(parentElementId, parentKey, elementId, objectToSave, opts) {
45
174
  return __awaiter(this, void 0, void 0, function* () {
46
175
  let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
@@ -54,10 +183,33 @@ function saveRelatedObject(parentElementId, parentKey, elementId, objectToSave,
54
183
  return response.data;
55
184
  });
56
185
  }
57
- exports.saveRelatedObject = saveRelatedObject;
58
- /*
59
- * Sorts the passed array in place by the given attributes. Sorting by nested attributes in the form of a delimited
60
- * attribute string are supported (e.g., "attribute.nestedAttribute").
186
+ /**
187
+ * saveRelatedObjectAsObservable saves a related object to the database. The objectToSave is saved,
188
+ * and its relationship to the parent object is established based on the relationship specified in
189
+ * the schema. The objectToSave must have a relationship to the parent object and the user must have
190
+ * scope access to the parent object.
191
+ *
192
+ * @param parentElementId - The ID of the parent element
193
+ * @param parentKey - The key of the parent object
194
+ * @param elementId - The element ID of the object to save
195
+ * @param objectToSave - The object data to save (as a JSON string)
196
+ * @param opts - Optional save options
197
+ *
198
+ * @returns Observable resolving to saved object, including any updates made to the object during
199
+ * the save operation (such as assigning an objKey if the object is new), or the assignment of
200
+ * calculated values
201
+ */
202
+ function saveRelatedObjectAsObservable(parentElementId, parentKey, elementId, objectToSave, opts) {
203
+ return (0, rxjs_1.from)(saveRelatedObject(parentElementId, parentKey, elementId, objectToSave, opts));
204
+ }
205
+ /**
206
+ * sortObjectArray is a helper function that sorts the passed array in place by the given
207
+ * attributes. Sorting by nested attributes in the form of a delimited attribute string are
208
+ * supported (e.g., "attribute.nestedAttribute").
209
+ *
210
+ * @param array - The array to sort
211
+ * @param sort - Array of sort field specifications
212
+ * @returns The sorted array
61
213
  */
62
214
  function sortObjectArray(array, sort) {
63
215
  return array.sort((a, b) => {
@@ -73,7 +225,18 @@ function sortObjectArray(array, sort) {
73
225
  return comparison;
74
226
  });
75
227
  }
76
- exports.sortObjectArray = sortObjectArray;
228
+ /**
229
+ * compareValues is a helper function that compares two values for sorting purposes. If the values
230
+ * are strings, the comparison is case-insensitive. If the values are numbers, the comparison is
231
+ * performed numerically.
232
+ *
233
+ * @param valueA - First value to compare
234
+ * @param valueB - Second value to compare
235
+ * @param descending - Whether to sort in descending order
236
+ * @param caseInsensitive - Whether to perform case-insensitive comparison for strings
237
+ *
238
+ * @returns Comparison result (-1, 0, or 1)
239
+ */
77
240
  function compareValues(valueA, valueB, descending, caseInsensitive) {
78
241
  if (caseInsensitive && (typeof valueA === 'string' || valueA instanceof String)) {
79
242
  if (valueA && valueB) {
@@ -103,7 +266,19 @@ function compareValues(valueA, valueB, descending, caseInsensitive) {
103
266
  }
104
267
  return 0;
105
268
  }
106
- exports.compareValues = compareValues;
269
+ /**
270
+ * getValueFromObject is a helper function that extracts a value from an object using a dot-notation
271
+ * path. The path can include relationships. Relationship IDs may include a colon delimiter (e.g.,
272
+ * "accountMember:ownerAccountMemberKey") to specify the key of the related object. This is useful
273
+ * when an element has more than one relationship to the same object type. Otherwise, if only one
274
+ * relationship to the same object type exists, the key may be specified without the relationship ID
275
+ * (e.g., simply, "accountMember").
276
+ *
277
+ * @param object - The object to extract value from
278
+ * @param attribute - The attribute path (e.g., "user.address.city")
279
+ *
280
+ * @returns The extracted value
281
+ */
107
282
  function getValueFromObject(object, attribute) {
108
283
  let components = attribute.split(".");
109
284
  let value = object;
@@ -125,17 +300,35 @@ function getValueFromObject(object, attribute) {
125
300
  }
126
301
  return value;
127
302
  }
128
- exports.getValueFromObject = getValueFromObject;
129
- function prepareSuccessResponse(returnVal) {
303
+ /**
304
+ * prepareSuccessResponse prepares a success response in the appropriate format. The action handler
305
+ * should return an ActionResponse response when the action is successful. If useBody is true, the
306
+ * response will be returned as an object with the HTTP response code and the ActionResponse in the
307
+ * body field. If useBody is false, the ActionResponse will be returned directly.
308
+ *
309
+ * @param successResponse - The value to return
310
+ *
311
+ * @returns Formatted success response; an ActionResponse unless useBody is true
312
+ */
313
+ function prepareSuccessResponse(successResponse) {
130
314
  if (exports.useBody) {
131
315
  return {
132
316
  statusCode: 200,
133
- body: JSON.stringify(returnVal)
317
+ body: JSON.stringify(successResponse)
134
318
  };
135
319
  }
136
- return returnVal;
320
+ return successResponse;
137
321
  }
138
- exports.prepareSuccessResponse = prepareSuccessResponse;
322
+ /**
323
+ * prepareErrorResponse prepares an error response in the appropriate format. The action handler
324
+ * should return an ErrorResponse response when the action is not successful. If useBody is true,
325
+ * the response will be returned as an object with the HTTP response code and the ErrorResponse in
326
+ * the body field. If useBody is false, the ErrorResponse will be returned directly.
327
+ *
328
+ * @param errorMessage - The error message
329
+ *
330
+ * @returns Formatted error response; an ErrorResponse unless useBody is true
331
+ */
139
332
  function prepareErrorResponse(errorMessage) {
140
333
  if (exports.useBody) {
141
334
  return {
@@ -145,13 +338,20 @@ function prepareErrorResponse(errorMessage) {
145
338
  }
146
339
  return { errorMessage, responseType: "error" };
147
340
  }
148
- exports.prepareErrorResponse = prepareErrorResponse;
341
+ /**
342
+ * initialize initializes the SDK with event data. This should be called at the beginning of the
343
+ * action handler to set up the SDK with incoming information, including context information, input
344
+ * parameters, and authentication information needed to make API requests to the Halix service.
345
+ *
346
+ * @param event - The event object containing authentication and context information
347
+ */
149
348
  function initialize(event) {
150
349
  let body = event;
151
350
  if (event.body) {
152
351
  body = event.body;
153
352
  exports.useBody = true;
154
353
  }
155
- ({ authToken: exports.authToken, sandboxKey: exports.sandboxKey, serviceAddress: exports.serviceAddress, actionSubject: exports.actionSubject, userContext: exports.userContext, params: exports.params } = body);
354
+ if (body) {
355
+ ({ authToken: exports.authToken, sandboxKey: exports.sandboxKey, serviceAddress: exports.serviceAddress, actionSubject: exports.actionSubject, userContext: exports.userContext, params: exports.params } = body);
356
+ }
156
357
  }
157
- exports.initialize = initialize;