@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.
- package/lib/cjs/content.js +257 -0
- package/lib/cjs/data-crud.js +297 -0
- package/lib/cjs/index.js +53 -678
- package/lib/cjs/lists.js +175 -0
- package/lib/cjs/sdk-general.js +92 -0
- package/lib/cjs/types/content.d.ts +119 -0
- package/lib/cjs/types/content.d.ts.map +1 -0
- package/lib/cjs/types/data-crud.d.ts +156 -0
- package/lib/cjs/types/data-crud.d.ts.map +1 -0
- package/lib/cjs/types/index.d.ts +8 -578
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/lists.d.ts +212 -0
- package/lib/cjs/types/lists.d.ts.map +1 -0
- package/lib/cjs/types/sdk-general.d.ts +263 -0
- package/lib/cjs/types/sdk-general.d.ts.map +1 -0
- package/lib/cjs/types/utilities.d.ts +73 -0
- package/lib/cjs/types/utilities.d.ts.map +1 -0
- package/lib/cjs/utilities.js +131 -0
- package/lib/esm/content.js +228 -0
- package/lib/esm/content.js.map +1 -0
- package/lib/esm/data-crud.js +264 -0
- package/lib/esm/data-crud.js.map +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +26 -673
- package/lib/esm/lists.js +157 -0
- package/lib/esm/lists.js.map +1 -0
- package/lib/esm/sdk-general.js +138 -0
- package/lib/esm/sdk-general.js.map +1 -0
- package/lib/esm/types/content.d.ts +118 -0
- package/lib/esm/types/data-crud.d.ts +155 -0
- package/lib/esm/types/index.d.ts +8 -578
- package/lib/esm/types/lists.d.ts +211 -0
- package/lib/esm/types/sdk-general.d.ts +262 -0
- package/lib/esm/types/utilities.d.ts +72 -0
- package/lib/esm/utilities.js +126 -0
- package/lib/esm/utilities.js.map +1 -0
- package/package.json +12 -1
package/lib/cjs/index.js
CHANGED
|
@@ -7,697 +7,72 @@
|
|
|
7
7
|
//
|
|
8
8
|
// Unauthorized use outside the Halix platform is prohibited.
|
|
9
9
|
// Full license terms available in the LICENSE file.
|
|
10
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
|
-
};
|
|
22
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.getAuthToken = void 0;
|
|
24
|
-
exports.initialize = initialize;
|
|
25
|
-
exports.prepareSuccessResponse = prepareSuccessResponse;
|
|
26
|
-
exports.prepareErrorResponse = prepareErrorResponse;
|
|
27
|
-
exports.getObject = getObject;
|
|
28
|
-
exports.getObjectAsObservable = getObjectAsObservable;
|
|
29
|
-
exports.getRelatedObjects = getRelatedObjects;
|
|
30
|
-
exports.getRelatedObjectsAsObservable = getRelatedObjectsAsObservable;
|
|
31
|
-
exports.saveRelatedObject = saveRelatedObject;
|
|
32
|
-
exports.saveRelatedObjectAsObservable = saveRelatedObjectAsObservable;
|
|
33
|
-
exports.deleteRelatedObject = deleteRelatedObject;
|
|
34
|
-
exports.deleteRelatedObjectAsObservable = deleteRelatedObjectAsObservable;
|
|
35
|
-
exports.deleteRelatedObjects = deleteRelatedObjects;
|
|
36
|
-
exports.deleteRelatedObjectsAsObservable = deleteRelatedObjectsAsObservable;
|
|
37
|
-
exports.getOrCreateResource = getOrCreateResource;
|
|
38
|
-
exports.getOrCreateResourceAsObservable = getOrCreateResourceAsObservable;
|
|
39
|
-
exports.saveResource = saveResource;
|
|
40
|
-
exports.saveResourceAsObservable = saveResourceAsObservable;
|
|
41
|
-
exports.sendFileContents = sendFileContents;
|
|
42
|
-
exports.sendFileContentsAsObservable = sendFileContentsAsObservable;
|
|
43
|
-
exports.createOrUpdateResource = createOrUpdateResource;
|
|
44
|
-
exports.createOrUpdateResourceAsObservable = createOrUpdateResourceAsObservable;
|
|
45
|
-
exports.sortObjectArray = sortObjectArray;
|
|
46
|
-
exports.compareValues = compareValues;
|
|
47
|
-
exports.getValueFromObject = getValueFromObject;
|
|
48
|
-
exports.debounceFn = debounceFn;
|
|
11
|
+
exports.debounceFn = exports.getValueFromObject = exports.compareValues = exports.sortObjectArray = exports.getListDataAsObservable = exports.getListData = exports.createOrUpdateResourceAsObservable = exports.createOrUpdateResource = exports.sendFileContentsAsObservable = exports.sendFileContents = exports.saveResourceAsObservable = exports.saveResource = exports.getOrCreateResourceAsObservable = exports.getOrCreateResource = exports.deleteRelatedObjectsAsObservable = exports.deleteRelatedObjects = exports.deleteRelatedObjectAsObservable = exports.deleteRelatedObject = exports.saveRelatedObjectAsObservable = exports.saveRelatedObject = exports.getRelatedObjectsAsObservable = exports.getRelatedObjects = exports.getObjectAsObservable = exports.getObject = exports.prepareErrorResponse = exports.prepareSuccessResponse = exports.initialize = exports.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.getAuthToken = void 0;
|
|
49
12
|
/**
|
|
50
13
|
* @module @halix/action-sdk
|
|
51
14
|
* @description Halix Platform action SDK for developing NodeJS Lambda-based actions on the Halix
|
|
52
|
-
* platform.
|
|
53
|
-
* requests to the Halix data service, and returning structured action responses back to the Halix
|
|
54
|
-
* platform.
|
|
15
|
+
* platform. This is the main entry point that provides a unified interface for all SDK functionality.
|
|
55
16
|
*/
|
|
56
|
-
const axios_1 = __importDefault(require("axios"));
|
|
57
|
-
const rxjs_1 = require("rxjs");
|
|
58
|
-
/**
|
|
59
|
-
* initialize initializes the SDK with event data. This should be called at the beginning of the
|
|
60
|
-
* action handler to set up the SDK with incoming information, including context information, input
|
|
61
|
-
* parameters, and authentication information needed to make API requests to the Halix service.
|
|
62
|
-
*
|
|
63
|
-
* @param event - The event object containing authentication and context information
|
|
64
|
-
*/
|
|
65
|
-
function initialize(event) {
|
|
66
|
-
let body = event;
|
|
67
|
-
if (event.body) {
|
|
68
|
-
body = event.body;
|
|
69
|
-
exports.useBody = true;
|
|
70
|
-
}
|
|
71
|
-
if (body) {
|
|
72
|
-
({ sandboxKey: exports.sandboxKey, serviceAddress: exports.serviceAddress, actionSubject: exports.actionSubject, userContext: exports.userContext, params: exports.params } = body);
|
|
73
|
-
if (body.authToken) {
|
|
74
|
-
exports.getAuthToken = () => (0, rxjs_1.of)(body.authToken);
|
|
75
|
-
}
|
|
76
|
-
else if (body.authTokenRetriever) {
|
|
77
|
-
exports.getAuthToken = body.authTokenRetriever;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
17
|
// ================================================================================
|
|
82
|
-
//
|
|
83
|
-
// ================================================================================
|
|
84
|
-
/**
|
|
85
|
-
* prepareSuccessResponse prepares a success response in the appropriate format. The action handler
|
|
86
|
-
* should return an ActionResponse response when the action is successful. If useBody is true, the
|
|
87
|
-
* response will be returned as an object with the HTTP response code and the ActionResponse in the
|
|
88
|
-
* body field. If useBody is false, the ActionResponse will be returned directly.
|
|
89
|
-
*
|
|
90
|
-
* @param successResponse - The value to return
|
|
91
|
-
*
|
|
92
|
-
* @returns Formatted success response; an ActionResponse unless useBody is true
|
|
93
|
-
*/
|
|
94
|
-
function prepareSuccessResponse(successResponse) {
|
|
95
|
-
if (exports.useBody) {
|
|
96
|
-
return {
|
|
97
|
-
statusCode: 200,
|
|
98
|
-
body: JSON.stringify(successResponse)
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return successResponse;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* prepareErrorResponse prepares an error response in the appropriate format. The action handler
|
|
105
|
-
* should return an ErrorResponse response when the action is not successful. If useBody is true,
|
|
106
|
-
* the response will be returned as an object with the HTTP response code and the ErrorResponse in
|
|
107
|
-
* the body field. If useBody is false, the ErrorResponse will be returned directly.
|
|
108
|
-
*
|
|
109
|
-
* @param errorMessage - The error message
|
|
110
|
-
*
|
|
111
|
-
* @returns Formatted error response; an ErrorResponse unless useBody is true
|
|
112
|
-
*/
|
|
113
|
-
function prepareErrorResponse(errorMessage) {
|
|
114
|
-
if (exports.useBody) {
|
|
115
|
-
return {
|
|
116
|
-
statusCode: 400,
|
|
117
|
-
body: JSON.stringify({ errorMessage })
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
return { errorMessage, responseType: "error" };
|
|
121
|
-
}
|
|
18
|
+
// SDK GENERAL - GLOBALS, INITIALIZATION, COMMON TYPES
|
|
122
19
|
// ================================================================================
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (fetchedRelationships) {
|
|
138
|
-
let p = {};
|
|
139
|
-
if (fetchedRelationships) {
|
|
140
|
-
p.fetchedRelationships = fetchedRelationships.join(",");
|
|
141
|
-
}
|
|
142
|
-
params = new URLSearchParams(p);
|
|
143
|
-
}
|
|
144
|
-
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${dataElementId}/${key}`;
|
|
145
|
-
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
146
|
-
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
147
|
-
let response = yield axios_1.default.get(url, {
|
|
148
|
-
headers: { "Authorization": `Bearer ${authToken}` },
|
|
149
|
-
params: params,
|
|
150
|
-
});
|
|
151
|
-
return response.data;
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* getObjectAsObservable retrieves a single object from the database by its data element ID and key.
|
|
156
|
-
*
|
|
157
|
-
* @param dataElementId - The ID of the data element
|
|
158
|
-
* @param key - The key of the object
|
|
159
|
-
* @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
|
|
160
|
-
* object will include the specified related objects as nested objects
|
|
161
|
-
*
|
|
162
|
-
* @returns Observable resolving to the object data
|
|
163
|
-
*/
|
|
164
|
-
function getObjectAsObservable(dataElementId, key, fetchedRelationships) {
|
|
165
|
-
return (0, rxjs_1.from)(getObject(dataElementId, key, fetchedRelationships));
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* getRelatedObjects retrieves an array of objects from the the database. The objects returned are
|
|
169
|
-
* related to a parent through a defined relationship in the schema. In a typical setup, action's
|
|
170
|
-
* auth token must have scope access to the parent object in order to access all of its related
|
|
171
|
-
* objects.
|
|
172
|
-
*
|
|
173
|
-
* It is common to use getRelatedObjects to retrieve all objects belonging to the current user proxy
|
|
174
|
-
* or organization proxy. For example, in a user context where the current user proxy element is
|
|
175
|
-
* "customer," an action might want to retrieve all "purchase" objects related to the current
|
|
176
|
-
* customer. Similarly, in an organization context where the current organization proxy is
|
|
177
|
-
* "business," an action might want to retrieve all "employee" objects related to the current
|
|
178
|
-
* business.
|
|
179
|
-
*
|
|
180
|
-
* @param parentElementId - The ID of the parent element
|
|
181
|
-
* @param parentKey - The key of the parent object
|
|
182
|
-
* @param elementId - The ID of the element
|
|
183
|
-
* @param filter - Optional filter criteria for the query; if not provided, all related objects will
|
|
184
|
-
* be returned
|
|
185
|
-
* @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
|
|
186
|
-
* objects will include the specified related objects as nested objects
|
|
187
|
-
*
|
|
188
|
-
* @returns Promise resolving to an array of objects
|
|
189
|
-
*/
|
|
190
|
-
function getRelatedObjects(parentElementId, parentKey, elementId, filter, fetchedRelationships) {
|
|
191
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
-
let params;
|
|
193
|
-
if (filter || fetchedRelationships) {
|
|
194
|
-
let p = {};
|
|
195
|
-
if (filter) {
|
|
196
|
-
p.filter = filter;
|
|
197
|
-
}
|
|
198
|
-
if (fetchedRelationships) {
|
|
199
|
-
p.fetchedRelationships = fetchedRelationships.join(",");
|
|
200
|
-
}
|
|
201
|
-
params = new URLSearchParams(p);
|
|
202
|
-
}
|
|
203
|
-
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
|
|
204
|
-
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
205
|
-
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
206
|
-
let response = yield axios_1.default.get(url, {
|
|
207
|
-
headers: { "Authorization": `Bearer ${authToken}` },
|
|
208
|
-
params: params,
|
|
209
|
-
});
|
|
210
|
-
return response.data;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* getRelatedObjectsAsObservable retrieves an array of objects from the the database. The objects
|
|
215
|
-
* returned are related to a parent through a defined relationship in the schema. In a typical
|
|
216
|
-
* setup, action's auth token must have scope access to the parent object in order to access all of
|
|
217
|
-
* its related objects.
|
|
218
|
-
*
|
|
219
|
-
* It is common to use getRelatedObjects to retrieve all objects belonging to the current user proxy
|
|
220
|
-
* or organization proxy. For example, in a user context where the current user proxy element is
|
|
221
|
-
* "customer," an action might want to retrieve all "purchase" objects related to the current
|
|
222
|
-
* customer. Similarly, in an organization context where the current organization proxy is
|
|
223
|
-
* "business," an action might want to retrieve all "employee" objects related to the current
|
|
224
|
-
* business.
|
|
225
|
-
*
|
|
226
|
-
* @param parentElementId - The ID of the parent element
|
|
227
|
-
* @param parentKey - The key of the parent element
|
|
228
|
-
* @param elementId - The ID of the element
|
|
229
|
-
* @param filter - Optional filter criteria for the query; if not provided, all related objects will
|
|
230
|
-
* be returned
|
|
231
|
-
* @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
|
|
232
|
-
* objects will include the specified related objects as nested objects
|
|
233
|
-
*
|
|
234
|
-
* @returns Observable resolving to an array of objects
|
|
235
|
-
*/
|
|
236
|
-
function getRelatedObjectsAsObservable(parentElementId, parentKey, elementId, filter, fetchedRelationships) {
|
|
237
|
-
return (0, rxjs_1.from)(getRelatedObjects(parentElementId, parentKey, elementId, filter, fetchedRelationships));
|
|
238
|
-
}
|
|
20
|
+
var sdk_general_1 = require("./sdk-general");
|
|
21
|
+
// Globals
|
|
22
|
+
Object.defineProperty(exports, "getAuthToken", { enumerable: true, get: function () { return sdk_general_1.getAuthToken; } });
|
|
23
|
+
Object.defineProperty(exports, "sandboxKey", { enumerable: true, get: function () { return sdk_general_1.sandboxKey; } });
|
|
24
|
+
Object.defineProperty(exports, "serviceAddress", { enumerable: true, get: function () { return sdk_general_1.serviceAddress; } });
|
|
25
|
+
Object.defineProperty(exports, "actionSubject", { enumerable: true, get: function () { return sdk_general_1.actionSubject; } });
|
|
26
|
+
Object.defineProperty(exports, "userContext", { enumerable: true, get: function () { return sdk_general_1.userContext; } });
|
|
27
|
+
Object.defineProperty(exports, "params", { enumerable: true, get: function () { return sdk_general_1.params; } });
|
|
28
|
+
Object.defineProperty(exports, "useBody", { enumerable: true, get: function () { return sdk_general_1.useBody; } });
|
|
29
|
+
// Initialization
|
|
30
|
+
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return sdk_general_1.initialize; } });
|
|
31
|
+
// Response Helpers
|
|
32
|
+
Object.defineProperty(exports, "prepareSuccessResponse", { enumerable: true, get: function () { return sdk_general_1.prepareSuccessResponse; } });
|
|
33
|
+
Object.defineProperty(exports, "prepareErrorResponse", { enumerable: true, get: function () { return sdk_general_1.prepareErrorResponse; } });
|
|
239
34
|
// ================================================================================
|
|
240
|
-
// DATA
|
|
35
|
+
// DATA CRUD FUNCTIONS
|
|
241
36
|
// ================================================================================
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
* calculated values
|
|
257
|
-
*/
|
|
258
|
-
function saveRelatedObject(parentElementId, parentKey, elementId, objectToSave, opts) {
|
|
259
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
260
|
-
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
|
|
261
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.bypassValidation) === false) {
|
|
262
|
-
url += "?bypassValidation=false";
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
url += "?bypassValidation=true";
|
|
266
|
-
}
|
|
267
|
-
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
268
|
-
console.log("Sending POST request to " + url + " with token " + authToken);
|
|
269
|
-
let response = yield axios_1.default.post(url, objectToSave, {
|
|
270
|
-
headers: { "Authorization": `Bearer ${authToken}` },
|
|
271
|
-
});
|
|
272
|
-
return response.data;
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* saveRelatedObjectAsObservable saves a related object to the database. The objectToSave is saved,
|
|
277
|
-
* and its relationship to the parent object is established based on the relationship specified in
|
|
278
|
-
* the schema. The objectToSave must have a relationship to the parent object and the user must have
|
|
279
|
-
* scope access to the parent object.
|
|
280
|
-
*
|
|
281
|
-
* @param parentElementId - The ID of the parent element
|
|
282
|
-
* @param parentKey - The key of the parent object
|
|
283
|
-
* @param elementId - The element ID of the object to save
|
|
284
|
-
* @param objectToSave - The object data to save (as a JSON string)
|
|
285
|
-
* @param opts - Optional save options
|
|
286
|
-
*
|
|
287
|
-
* @returns Observable resolving to saved object, including any updates made to the object during
|
|
288
|
-
* the save operation (such as assigning an objKey if the object is new), or the assignment of
|
|
289
|
-
* calculated values
|
|
290
|
-
*/
|
|
291
|
-
function saveRelatedObjectAsObservable(parentElementId, parentKey, elementId, objectToSave, opts) {
|
|
292
|
-
return (0, rxjs_1.from)(saveRelatedObject(parentElementId, parentKey, elementId, objectToSave, opts));
|
|
293
|
-
}
|
|
37
|
+
var data_crud_1 = require("./data-crud");
|
|
38
|
+
// Data Retrieval
|
|
39
|
+
Object.defineProperty(exports, "getObject", { enumerable: true, get: function () { return data_crud_1.getObject; } });
|
|
40
|
+
Object.defineProperty(exports, "getObjectAsObservable", { enumerable: true, get: function () { return data_crud_1.getObjectAsObservable; } });
|
|
41
|
+
Object.defineProperty(exports, "getRelatedObjects", { enumerable: true, get: function () { return data_crud_1.getRelatedObjects; } });
|
|
42
|
+
Object.defineProperty(exports, "getRelatedObjectsAsObservable", { enumerable: true, get: function () { return data_crud_1.getRelatedObjectsAsObservable; } });
|
|
43
|
+
// Data Save
|
|
44
|
+
Object.defineProperty(exports, "saveRelatedObject", { enumerable: true, get: function () { return data_crud_1.saveRelatedObject; } });
|
|
45
|
+
Object.defineProperty(exports, "saveRelatedObjectAsObservable", { enumerable: true, get: function () { return data_crud_1.saveRelatedObjectAsObservable; } });
|
|
46
|
+
// Data Delete
|
|
47
|
+
Object.defineProperty(exports, "deleteRelatedObject", { enumerable: true, get: function () { return data_crud_1.deleteRelatedObject; } });
|
|
48
|
+
Object.defineProperty(exports, "deleteRelatedObjectAsObservable", { enumerable: true, get: function () { return data_crud_1.deleteRelatedObjectAsObservable; } });
|
|
49
|
+
Object.defineProperty(exports, "deleteRelatedObjects", { enumerable: true, get: function () { return data_crud_1.deleteRelatedObjects; } });
|
|
50
|
+
Object.defineProperty(exports, "deleteRelatedObjectsAsObservable", { enumerable: true, get: function () { return data_crud_1.deleteRelatedObjectsAsObservable; } });
|
|
294
51
|
// ================================================================================
|
|
295
|
-
//
|
|
52
|
+
// CONTENT FUNCTIONS
|
|
296
53
|
// ================================================================================
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
function deleteRelatedObject(parentElementId, parentKey, childElementId, childKey) {
|
|
308
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
-
if (!exports.userContext) {
|
|
310
|
-
throw new Error("userContext is required but not available; check that the initialize function has been called");
|
|
311
|
-
}
|
|
312
|
-
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${childElementId}/${childKey}`;
|
|
313
|
-
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
314
|
-
console.log("Sending DELETE request to " + url + " with token " + authToken);
|
|
315
|
-
let response = yield axios_1.default.delete(url, {
|
|
316
|
-
headers: { "Authorization": `Bearer ${authToken}` },
|
|
317
|
-
});
|
|
318
|
-
return response.status === 204;
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* deleteRelatedObjectAsObservable deletes a single object related to a specific parent.
|
|
323
|
-
*
|
|
324
|
-
* @param parentElementId - The ID of the parent element
|
|
325
|
-
* @param parentKey - The key of the parent object
|
|
326
|
-
* @param childElementId - The ID of the child element to delete
|
|
327
|
-
* @param childKey - The key of the child object to delete
|
|
328
|
-
*
|
|
329
|
-
* @returns Observable resolving to true if deletion was successful
|
|
330
|
-
*/
|
|
331
|
-
function deleteRelatedObjectAsObservable(parentElementId, parentKey, childElementId, childKey) {
|
|
332
|
-
return (0, rxjs_1.from)(deleteRelatedObject(parentElementId, parentKey, childElementId, childKey));
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* deleteRelatedObjects deletes multiple objects related to a specific parent.
|
|
336
|
-
*
|
|
337
|
-
* @param parentElementId - The ID of the parent element
|
|
338
|
-
* @param parentKey - The key of the parent object
|
|
339
|
-
* @param childElementId - The ID of the child element to delete
|
|
340
|
-
* @param childKeys - Array of keys of the child objects to delete
|
|
341
|
-
*
|
|
342
|
-
* @returns Promise resolving to true if deletion was successful
|
|
343
|
-
*/
|
|
344
|
-
function deleteRelatedObjects(parentElementId, parentKey, childElementId, childKeys) {
|
|
345
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
346
|
-
if (!exports.userContext) {
|
|
347
|
-
throw new Error("userContext is required but not available; check that the initialize function has been called");
|
|
348
|
-
}
|
|
349
|
-
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${childElementId}`;
|
|
350
|
-
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
351
|
-
console.log("Sending DELETE request to " + url + " with token " + authToken);
|
|
352
|
-
let response = yield axios_1.default.delete(url, {
|
|
353
|
-
headers: { "Authorization": `Bearer ${authToken}` },
|
|
354
|
-
params: { keys: childKeys.join(",") },
|
|
355
|
-
});
|
|
356
|
-
return response.status === 204;
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* deleteRelatedObjectsAsObservable deletes multiple objects related to a specific parent.
|
|
361
|
-
*
|
|
362
|
-
* @param parentElementId - The ID of the parent element
|
|
363
|
-
* @param parentKey - The key of the parent object
|
|
364
|
-
* @param childElementId - The ID of the child element to delete
|
|
365
|
-
* @param childKeys - Array of keys of the child objects to delete
|
|
366
|
-
*
|
|
367
|
-
* @returns Observable resolving to true if deletion was successful
|
|
368
|
-
*/
|
|
369
|
-
function deleteRelatedObjectsAsObservable(parentElementId, parentKey, childElementId, childKeys) {
|
|
370
|
-
return (0, rxjs_1.from)(deleteRelatedObjects(parentElementId, parentKey, childElementId, childKeys));
|
|
371
|
-
}
|
|
54
|
+
var content_1 = require("./content");
|
|
55
|
+
// Content Functions
|
|
56
|
+
Object.defineProperty(exports, "getOrCreateResource", { enumerable: true, get: function () { return content_1.getOrCreateResource; } });
|
|
57
|
+
Object.defineProperty(exports, "getOrCreateResourceAsObservable", { enumerable: true, get: function () { return content_1.getOrCreateResourceAsObservable; } });
|
|
58
|
+
Object.defineProperty(exports, "saveResource", { enumerable: true, get: function () { return content_1.saveResource; } });
|
|
59
|
+
Object.defineProperty(exports, "saveResourceAsObservable", { enumerable: true, get: function () { return content_1.saveResourceAsObservable; } });
|
|
60
|
+
Object.defineProperty(exports, "sendFileContents", { enumerable: true, get: function () { return content_1.sendFileContents; } });
|
|
61
|
+
Object.defineProperty(exports, "sendFileContentsAsObservable", { enumerable: true, get: function () { return content_1.sendFileContentsAsObservable; } });
|
|
62
|
+
Object.defineProperty(exports, "createOrUpdateResource", { enumerable: true, get: function () { return content_1.createOrUpdateResource; } });
|
|
63
|
+
Object.defineProperty(exports, "createOrUpdateResourceAsObservable", { enumerable: true, get: function () { return content_1.createOrUpdateResourceAsObservable; } });
|
|
372
64
|
// ================================================================================
|
|
373
|
-
//
|
|
65
|
+
// LIST DATA FUNCTIONS
|
|
374
66
|
// ================================================================================
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
* properties.
|
|
380
|
-
*
|
|
381
|
-
* @param resourceKey - Optional key of the existing resource to retrieve
|
|
382
|
-
* @param fileToUpload - Optional file or blob to upload
|
|
383
|
-
* @param publicFlag - Whether the resource should be public
|
|
384
|
-
* @param resourceType - The type of resource
|
|
385
|
-
* @param tags - Array of tags for the resource
|
|
386
|
-
*
|
|
387
|
-
* @returns Promise resolving to a ContentResource
|
|
388
|
-
*/
|
|
389
|
-
function getOrCreateResource(resourceKey, fileToUpload, publicFlag, resourceType, tags) {
|
|
390
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
391
|
-
if (!exports.userContext) {
|
|
392
|
-
throw new Error("userContext is required but not available; check that the initialize function has been called");
|
|
393
|
-
}
|
|
394
|
-
if (resourceKey) {
|
|
395
|
-
let url = `${exports.serviceAddress}/sandboxes/${exports.sandboxKey}/contentResource/${resourceKey}`;
|
|
396
|
-
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
397
|
-
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
398
|
-
let response = yield axios_1.default.get(url, {
|
|
399
|
-
headers: { "Authorization": `Bearer ${authToken}` },
|
|
400
|
-
});
|
|
401
|
-
let resource = response.data;
|
|
402
|
-
if (fileToUpload) {
|
|
403
|
-
resource.contentType = fileToUpload.type;
|
|
404
|
-
// Null out the name and extension; the server will set these if they are blank
|
|
405
|
-
resource.name = null;
|
|
406
|
-
resource.extension = null;
|
|
407
|
-
}
|
|
408
|
-
return resource;
|
|
409
|
-
}
|
|
410
|
-
let newResource = {
|
|
411
|
-
isPublic: publicFlag,
|
|
412
|
-
resourceType: resourceType,
|
|
413
|
-
tags: tags,
|
|
414
|
-
organizationKey: exports.userContext.orgKey,
|
|
415
|
-
sandboxKey: exports.sandboxKey,
|
|
416
|
-
userKey: exports.userContext.user.objKey
|
|
417
|
-
};
|
|
418
|
-
if (fileToUpload) {
|
|
419
|
-
newResource.contentType = fileToUpload.type;
|
|
420
|
-
// Null out the name and extension; the server will set these if they are blank
|
|
421
|
-
newResource.name = null;
|
|
422
|
-
newResource.extension = null;
|
|
423
|
-
}
|
|
424
|
-
return newResource;
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* getOrCreateResourceAsObservable retrieves an existing content resource by its key, or creates a new one
|
|
429
|
-
* if the key is not provided. If a resource key is provided, it attempts to fetch the existing
|
|
430
|
-
* resource from the server. If no key is provided, it creates a new resource with the specified
|
|
431
|
-
* properties.
|
|
432
|
-
*
|
|
433
|
-
* @param resourceKey - Optional key of the existing resource to retrieve
|
|
434
|
-
* @param fileToUpload - Optional file or blob to upload
|
|
435
|
-
* @param publicFlag - Whether the resource should be public
|
|
436
|
-
* @param resourceType - The type of resource
|
|
437
|
-
* @param tags - Array of tags for the resource
|
|
438
|
-
*
|
|
439
|
-
* @returns Observable resolving to a ContentResource
|
|
440
|
-
*/
|
|
441
|
-
function getOrCreateResourceAsObservable(resourceKey, fileToUpload, publicFlag, resourceType, tags) {
|
|
442
|
-
return (0, rxjs_1.from)(getOrCreateResource(resourceKey, fileToUpload, publicFlag, resourceType, tags));
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* saveResource saves a content resource to the server. The resource is saved with appropriate
|
|
446
|
-
* ownership parameters based on the current context (solution builder vs regular organization view).
|
|
447
|
-
*
|
|
448
|
-
* @param resource - The ContentResource to save
|
|
449
|
-
*
|
|
450
|
-
* @returns Promise resolving to the saved ContentResource
|
|
451
|
-
*/
|
|
452
|
-
function saveResource(resource) {
|
|
453
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
454
|
-
if (!exports.userContext) {
|
|
455
|
-
throw new Error("userContext is required but not available; check that the initialize function has been called");
|
|
456
|
-
}
|
|
457
|
-
let params = {};
|
|
458
|
-
if (exports.userContext.orgProxy.objType === "Solution") {
|
|
459
|
-
// When in the solution builder view, content is owned by the solution. The solution key is the org proxy key in
|
|
460
|
-
// the builder view.
|
|
461
|
-
params.solutionKey = exports.userContext.orgProxyKey;
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
params.organizationKey = exports.userContext.orgKey;
|
|
465
|
-
params.userKey = exports.userContext.user.objKey;
|
|
466
|
-
}
|
|
467
|
-
let url = `${exports.serviceAddress}/sandboxes/${exports.sandboxKey}/contentResource`;
|
|
468
|
-
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
469
|
-
console.log("Sending POST request to " + url + " with token " + authToken);
|
|
470
|
-
let response = yield axios_1.default.post(url, JSON.stringify(resource), {
|
|
471
|
-
headers: { "Authorization": `Bearer ${authToken}` },
|
|
472
|
-
params: params,
|
|
473
|
-
});
|
|
474
|
-
return response.data;
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* saveResourceAsObservable saves a content resource to the server. The resource is saved with appropriate
|
|
479
|
-
* ownership parameters based on the current context (solution builder vs regular organization view).
|
|
480
|
-
*
|
|
481
|
-
* @param resource - The ContentResource to save
|
|
482
|
-
*
|
|
483
|
-
* @returns Observable resolving to the saved ContentResource
|
|
484
|
-
*/
|
|
485
|
-
function saveResourceAsObservable(resource) {
|
|
486
|
-
return (0, rxjs_1.from)(saveResource(resource));
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* sendFileContents uploads file contents to the server for a specific resource. The file is uploaded
|
|
490
|
-
* via FormData with the appropriate scope and public flag settings.
|
|
491
|
-
*
|
|
492
|
-
* @param resourceKey - The key of the resource to upload file contents for
|
|
493
|
-
* @param fileToUpload - The file or blob to upload
|
|
494
|
-
* @param publicFlag - Whether the file should be public
|
|
495
|
-
*
|
|
496
|
-
* @returns Promise resolving to true if upload was successful
|
|
497
|
-
*/
|
|
498
|
-
function sendFileContents(resourceKey, fileToUpload, publicFlag) {
|
|
499
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
500
|
-
if (!exports.userContext) {
|
|
501
|
-
throw new Error("userContext is required but not available; check that the initialize function has been called");
|
|
502
|
-
}
|
|
503
|
-
let url = `${exports.serviceAddress}/filecontent/${exports.sandboxKey}/${resourceKey}`;
|
|
504
|
-
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
505
|
-
console.log("Sending file upload request to " + url + " with token " + authToken);
|
|
506
|
-
let formData = new FormData();
|
|
507
|
-
formData.append("fileUpload", fileToUpload);
|
|
508
|
-
formData.append("scopeKeyPath", exports.userContext.orgProxyKey);
|
|
509
|
-
formData.append("public", String(publicFlag));
|
|
510
|
-
let response = yield axios_1.default.post(url, formData, {
|
|
511
|
-
headers: {
|
|
512
|
-
"Authorization": `Bearer ${authToken}`,
|
|
513
|
-
"Content-Type": "multipart/form-data"
|
|
514
|
-
},
|
|
515
|
-
});
|
|
516
|
-
return response.status === 204;
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* sendFileContentsAsObservable uploads file contents to the server for a specific resource. The file is uploaded
|
|
521
|
-
* via FormData with the appropriate scope and public flag settings.
|
|
522
|
-
*
|
|
523
|
-
* @param resourceKey - The key of the resource to upload file contents for
|
|
524
|
-
* @param fileToUpload - The file or blob to upload
|
|
525
|
-
* @param publicFlag - Whether the file should be public
|
|
526
|
-
*
|
|
527
|
-
* @returns Observable resolving to true if upload was successful
|
|
528
|
-
*/
|
|
529
|
-
function sendFileContentsAsObservable(resourceKey, fileToUpload, publicFlag) {
|
|
530
|
-
return (0, rxjs_1.from)(sendFileContents(resourceKey, fileToUpload, publicFlag));
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* createOrUpdateResource creates a new content resource or updates an existing one, then uploads
|
|
534
|
-
* the file contents to that resource. If a resourceKey is provided, it updates the existing resource;
|
|
535
|
-
* otherwise, it creates a new resource and uploads the file to the newly created resource.
|
|
536
|
-
*
|
|
537
|
-
* @param resourceKey - Optional key of the existing resource to update; if not provided, a new resource is created
|
|
538
|
-
* @param fileToUpload - The file or blob to upload
|
|
539
|
-
* @param publicFlag - Whether the resource should be public
|
|
540
|
-
* @param resourceType - The type of resource
|
|
541
|
-
* @param tags - Array of tags for the resource
|
|
542
|
-
*
|
|
543
|
-
* @returns Promise resolving to the ContentResource with uploaded file
|
|
544
|
-
*/
|
|
545
|
-
function createOrUpdateResource(resourceKey, fileToUpload, publicFlag, resourceType, tags) {
|
|
546
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
547
|
-
if (!exports.userContext) {
|
|
548
|
-
throw new Error("userContext is required but not available; check that the initialize function has been called");
|
|
549
|
-
}
|
|
550
|
-
// Get or create the resource
|
|
551
|
-
let resource = yield getOrCreateResource(resourceKey, fileToUpload, publicFlag, resourceType, tags);
|
|
552
|
-
// Save the resource to get the objKey if it's new
|
|
553
|
-
let savedResource = yield saveResource(resource);
|
|
554
|
-
// Upload the file contents
|
|
555
|
-
if (!savedResource.objKey) {
|
|
556
|
-
throw new Error("Resource was saved but no objKey was returned");
|
|
557
|
-
}
|
|
558
|
-
let uploadSuccess = yield sendFileContents(savedResource.objKey, fileToUpload, publicFlag);
|
|
559
|
-
if (!uploadSuccess) {
|
|
560
|
-
throw new Error("Failed to upload file contents");
|
|
561
|
-
}
|
|
562
|
-
// Get the updated resource with file metadata
|
|
563
|
-
let updatedResource = yield getOrCreateResource(savedResource.objKey, fileToUpload, publicFlag, resourceType, []);
|
|
564
|
-
// Set the name if it's not set and we have a File with a name
|
|
565
|
-
if (updatedResource && !updatedResource.name && fileToUpload instanceof File) {
|
|
566
|
-
updatedResource.name = fileToUpload.name;
|
|
567
|
-
}
|
|
568
|
-
return updatedResource;
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* createOrUpdateResourceAsObservable creates a new content resource or updates an existing one, then uploads
|
|
573
|
-
* the file contents to that resource. If a resourceKey is provided, it updates the existing resource;
|
|
574
|
-
* otherwise, it creates a new resource and uploads the file to the newly created resource.
|
|
575
|
-
*
|
|
576
|
-
* @param resourceKey - Optional key of the existing resource to update; if not provided, a new resource is created
|
|
577
|
-
* @param fileToUpload - The file or blob to upload
|
|
578
|
-
* @param publicFlag - Whether the resource should be public
|
|
579
|
-
* @param resourceType - The type of resource
|
|
580
|
-
* @param tags - Array of tags for the resource
|
|
581
|
-
*
|
|
582
|
-
* @returns Observable resolving to the ContentResource with uploaded file
|
|
583
|
-
*/
|
|
584
|
-
function createOrUpdateResourceAsObservable(resourceKey, fileToUpload, publicFlag, resourceType, tags) {
|
|
585
|
-
return (0, rxjs_1.from)(createOrUpdateResource(resourceKey, fileToUpload, publicFlag, resourceType, tags));
|
|
586
|
-
}
|
|
67
|
+
var lists_1 = require("./lists");
|
|
68
|
+
// Functions
|
|
69
|
+
Object.defineProperty(exports, "getListData", { enumerable: true, get: function () { return lists_1.getListData; } });
|
|
70
|
+
Object.defineProperty(exports, "getListDataAsObservable", { enumerable: true, get: function () { return lists_1.getListDataAsObservable; } });
|
|
587
71
|
// ================================================================================
|
|
588
72
|
// UTILITY FUNCTIONS
|
|
589
73
|
// ================================================================================
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
* @param array - The array to sort
|
|
596
|
-
* @param sort - Array of sort field specifications
|
|
597
|
-
* @returns The sorted array
|
|
598
|
-
*/
|
|
599
|
-
function sortObjectArray(array, sort) {
|
|
600
|
-
return array.sort((a, b) => {
|
|
601
|
-
let comparison = 0;
|
|
602
|
-
for (let s of sort) {
|
|
603
|
-
let valueA = getValueFromObject(a, s.attributeId);
|
|
604
|
-
let valueB = getValueFromObject(b, s.attributeId);
|
|
605
|
-
comparison = compareValues(valueA, valueB, !!s.descending, !!s.caseInsensitive);
|
|
606
|
-
if (comparison !== 0) {
|
|
607
|
-
break;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
return comparison;
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* compareValues is a helper function that compares two values for sorting purposes. If the values
|
|
615
|
-
* are strings, the comparison is case-insensitive. If the values are numbers, the comparison is
|
|
616
|
-
* performed numerically.
|
|
617
|
-
*
|
|
618
|
-
* @param valueA - First value to compare
|
|
619
|
-
* @param valueB - Second value to compare
|
|
620
|
-
* @param descending - Whether to sort in descending order
|
|
621
|
-
* @param caseInsensitive - Whether to perform case-insensitive comparison for strings
|
|
622
|
-
*
|
|
623
|
-
* @returns Comparison result (-1, 0, or 1)
|
|
624
|
-
*/
|
|
625
|
-
function compareValues(valueA, valueB, descending, caseInsensitive) {
|
|
626
|
-
if (caseInsensitive && (typeof valueA === 'string' || valueA instanceof String)) {
|
|
627
|
-
if (valueA && valueB) {
|
|
628
|
-
let comp = valueA.toLowerCase().localeCompare(valueB.toLowerCase());
|
|
629
|
-
if (descending) {
|
|
630
|
-
comp = comp * -1;
|
|
631
|
-
}
|
|
632
|
-
return comp;
|
|
633
|
-
}
|
|
634
|
-
else if (valueA && !valueB) {
|
|
635
|
-
return -1;
|
|
636
|
-
}
|
|
637
|
-
else if (!valueA && valueB) {
|
|
638
|
-
return 1;
|
|
639
|
-
}
|
|
640
|
-
else {
|
|
641
|
-
return 0;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
if (valueA < valueB) {
|
|
646
|
-
return (descending ? 1 : -1);
|
|
647
|
-
}
|
|
648
|
-
if (valueA > valueB) {
|
|
649
|
-
return (descending ? -1 : 1);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
return 0;
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* getValueFromObject is a helper function that extracts a value from an object using a dot-notation
|
|
656
|
-
* path. The path can include relationships. Relationship IDs may include a colon delimiter (e.g.,
|
|
657
|
-
* "accountMember:ownerAccountMemberKey") to specify the key of the related object. This is useful
|
|
658
|
-
* when an element has more than one relationship to the same object type. Otherwise, if only one
|
|
659
|
-
* relationship to the same object type exists, the key may be specified without the relationship ID
|
|
660
|
-
* (e.g., simply, "accountMember").
|
|
661
|
-
*
|
|
662
|
-
* @param object - The object to extract value from
|
|
663
|
-
* @param attribute - The attribute path (e.g., "user.address.city")
|
|
664
|
-
*
|
|
665
|
-
* @returns The extracted value
|
|
666
|
-
*/
|
|
667
|
-
function getValueFromObject(object, attribute) {
|
|
668
|
-
let components = attribute.split(".");
|
|
669
|
-
let value = object;
|
|
670
|
-
for (let component of components) {
|
|
671
|
-
if (value) {
|
|
672
|
-
// If a relationship specifies a key, it will be in the format [datatype]:[key]. Otherwise the colon
|
|
673
|
-
// delimiter will not be present.
|
|
674
|
-
// The related value will be in a field named after the key. For example: accountMember:ownerAccountMemberKey
|
|
675
|
-
// the related owner account member will be in a field called "ownerAccountMember".
|
|
676
|
-
let compSplit = component.split(":");
|
|
677
|
-
if (compSplit.length > 1) {
|
|
678
|
-
let keyField = compSplit[1];
|
|
679
|
-
value = value[keyField.replace("Key", "")];
|
|
680
|
-
}
|
|
681
|
-
else {
|
|
682
|
-
value = value[component];
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
return value;
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* debounceFn is a utility function that debounces a function call. It is used to prevent multiple
|
|
690
|
-
* calls to the same function within a short period of time.
|
|
691
|
-
*
|
|
692
|
-
* @param fn - The function to debounce
|
|
693
|
-
* @param wait - The number of milliseconds to wait before calling the function
|
|
694
|
-
*
|
|
695
|
-
* @returns The debounced function
|
|
696
|
-
*/
|
|
697
|
-
function debounceFn(fn, wait = 200) {
|
|
698
|
-
let timeout;
|
|
699
|
-
return (...args) => {
|
|
700
|
-
clearTimeout(timeout);
|
|
701
|
-
timeout = setTimeout(() => fn(...args), wait);
|
|
702
|
-
};
|
|
703
|
-
}
|
|
74
|
+
var utilities_1 = require("./utilities");
|
|
75
|
+
Object.defineProperty(exports, "sortObjectArray", { enumerable: true, get: function () { return utilities_1.sortObjectArray; } });
|
|
76
|
+
Object.defineProperty(exports, "compareValues", { enumerable: true, get: function () { return utilities_1.compareValues; } });
|
|
77
|
+
Object.defineProperty(exports, "getValueFromObject", { enumerable: true, get: function () { return utilities_1.getValueFromObject; } });
|
|
78
|
+
Object.defineProperty(exports, "debounceFn", { enumerable: true, get: function () { return utilities_1.debounceFn; } });
|