@halix/action-sdk 1.0.9 → 1.0.10
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/index.js +35 -8
- package/lib/cjs/types/index.d.ts +76 -5
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +29 -4
- package/lib/esm/types/index.d.ts +76 -5
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.
|
|
23
|
+
exports.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.getAuthToken = void 0;
|
|
24
24
|
exports.getRelatedObjects = getRelatedObjects;
|
|
25
25
|
exports.getRelatedObjectsAsObservable = getRelatedObjectsAsObservable;
|
|
26
26
|
exports.getObject = getObject;
|
|
@@ -33,6 +33,7 @@ exports.getValueFromObject = getValueFromObject;
|
|
|
33
33
|
exports.prepareSuccessResponse = prepareSuccessResponse;
|
|
34
34
|
exports.prepareErrorResponse = prepareErrorResponse;
|
|
35
35
|
exports.initialize = initialize;
|
|
36
|
+
exports.initializeFromCustomElement = initializeFromCustomElement;
|
|
36
37
|
/**
|
|
37
38
|
* @module @halix/action-sdk
|
|
38
39
|
* @description Halix Platform action SDK for developing NodeJS Lambda-based actions on the Halix
|
|
@@ -79,9 +80,10 @@ function getRelatedObjects(parentElementId, parentKey, elementId, filter, fetche
|
|
|
79
80
|
params = new URLSearchParams(p);
|
|
80
81
|
}
|
|
81
82
|
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
|
|
82
|
-
|
|
83
|
+
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
84
|
+
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
83
85
|
let response = yield axios_1.default.get(url, {
|
|
84
|
-
headers: { "Authorization": `Bearer ${
|
|
86
|
+
headers: { "Authorization": `Bearer ${authToken}` },
|
|
85
87
|
params: params,
|
|
86
88
|
});
|
|
87
89
|
return response.data;
|
|
@@ -133,9 +135,10 @@ function getObject(dataElementId, key, fetchedRelationships) {
|
|
|
133
135
|
params = new URLSearchParams(p);
|
|
134
136
|
}
|
|
135
137
|
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${dataElementId}/${key}`;
|
|
136
|
-
|
|
138
|
+
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
139
|
+
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
137
140
|
let response = yield axios_1.default.get(url, {
|
|
138
|
-
headers: { "Authorization": `Bearer ${
|
|
141
|
+
headers: { "Authorization": `Bearer ${authToken}` },
|
|
139
142
|
params: params,
|
|
140
143
|
});
|
|
141
144
|
return response.data;
|
|
@@ -179,9 +182,10 @@ function saveRelatedObject(parentElementId, parentKey, elementId, objectToSave,
|
|
|
179
182
|
else {
|
|
180
183
|
url += "?bypassValidation=true";
|
|
181
184
|
}
|
|
182
|
-
|
|
185
|
+
let authToken = yield (0, rxjs_1.lastValueFrom)((0, exports.getAuthToken)());
|
|
186
|
+
console.log("Sending POST request to " + url + " with token " + authToken);
|
|
183
187
|
let response = yield axios_1.default.post(url, objectToSave, {
|
|
184
|
-
headers: { "Authorization": `Bearer ${
|
|
188
|
+
headers: { "Authorization": `Bearer ${authToken}` },
|
|
185
189
|
});
|
|
186
190
|
return response.data;
|
|
187
191
|
});
|
|
@@ -355,6 +359,29 @@ function initialize(event) {
|
|
|
355
359
|
exports.useBody = true;
|
|
356
360
|
}
|
|
357
361
|
if (body) {
|
|
358
|
-
({
|
|
362
|
+
({ sandboxKey: exports.sandboxKey, serviceAddress: exports.serviceAddress, actionSubject: exports.actionSubject, userContext: exports.userContext, params: exports.params } = body);
|
|
363
|
+
exports.getAuthToken = () => (0, rxjs_1.of)(body.authToken);
|
|
359
364
|
}
|
|
360
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* initializeFromCustomElement initializes the SDK from a custom element context. This should be called
|
|
368
|
+
* at the beginning of the action handler to set up the SDK with incoming information, including context
|
|
369
|
+
* information, input parameters, and authentication information needed to make API requests to the Halix service.
|
|
370
|
+
*
|
|
371
|
+
* @param context - The custom element context
|
|
372
|
+
*/
|
|
373
|
+
function initializeFromCustomElement(context) {
|
|
374
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
375
|
+
exports.sandboxKey = (_b = (_a = context.session) === null || _a === void 0 ? void 0 : _a.sandbox) === null || _b === void 0 ? void 0 : _b.objKey;
|
|
376
|
+
exports.serviceAddress = context.serviceAddress;
|
|
377
|
+
exports.actionSubject = context.pageContext;
|
|
378
|
+
exports.userContext = {
|
|
379
|
+
user: (_c = context.session) === null || _c === void 0 ? void 0 : _c.user,
|
|
380
|
+
userProxy: (_d = context.session) === null || _d === void 0 ? void 0 : _d.userProxy,
|
|
381
|
+
orgProxy: (_e = context.session) === null || _e === void 0 ? void 0 : _e.organizationProxy,
|
|
382
|
+
orgProxyKey: (_f = context.session) === null || _f === void 0 ? void 0 : _f.organizationProxyKey,
|
|
383
|
+
orgKey: (_g = context.session) === null || _g === void 0 ? void 0 : _g.organizationKey,
|
|
384
|
+
userProxyKey: (_j = (_h = context.session) === null || _h === void 0 ? void 0 : _h.userProxy) === null || _j === void 0 ? void 0 : _j.objKey,
|
|
385
|
+
};
|
|
386
|
+
exports.getAuthToken = () => context.authTokenRetriever();
|
|
387
|
+
}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
1
|
+
import { Observable, BehaviorSubject } from 'rxjs';
|
|
2
2
|
/**
|
|
3
3
|
* authToken contains the authentication token that the action handler can use to make API requests
|
|
4
4
|
* to Halix web services. This value is set upon calling the initialize function with incoming event
|
|
5
5
|
* data.
|
|
6
6
|
*/
|
|
7
|
-
export declare let
|
|
7
|
+
export declare let getAuthToken: () => Observable<string>;
|
|
8
8
|
/**
|
|
9
9
|
* sandboxKey contains the sandbox key identifier; identifies the sandbox that the action handler is
|
|
10
10
|
* running in. The sandbox identifies the current solution. This value is set upon calling the
|
|
@@ -28,12 +28,19 @@ export declare let serviceAddress: string;
|
|
|
28
28
|
* - for calculatedFieldActions, the action subject is the object containing the calculated field
|
|
29
29
|
* - for singleValueActions, the action subject may differ depending on the caller
|
|
30
30
|
*/
|
|
31
|
-
export declare let actionSubject:
|
|
31
|
+
export declare let actionSubject: any;
|
|
32
32
|
/**
|
|
33
33
|
* userContext contains the user context information for the user that is executing the action.
|
|
34
34
|
* This value is set upon calling the initialize function with incoming event data.
|
|
35
35
|
*/
|
|
36
|
-
export declare let userContext:
|
|
36
|
+
export declare let userContext: {
|
|
37
|
+
user: any;
|
|
38
|
+
userProxy: any;
|
|
39
|
+
orgProxy: any;
|
|
40
|
+
orgProxyKey: string;
|
|
41
|
+
orgKey: string;
|
|
42
|
+
userProxyKey: string;
|
|
43
|
+
};
|
|
37
44
|
/**
|
|
38
45
|
* params contains the parameters passed to the action. If an input dialog is used, params will
|
|
39
46
|
* contain the values entered in the dialog. This value is set upon calling the initialize
|
|
@@ -42,7 +49,7 @@ export declare let userContext: string;
|
|
|
42
49
|
export declare let params: string;
|
|
43
50
|
/**
|
|
44
51
|
* useBody is a flag indicating how responses should be formatted. If true, the response will be
|
|
45
|
-
* returned an object with the HTTP response code and ActionResponse in the body field. If false,
|
|
52
|
+
* returned as an object with the HTTP response code and ActionResponse in the body field. If false,
|
|
46
53
|
* the ActionResponse will be returned directly. Typically, this does not need to be set by the
|
|
47
54
|
* action handler and should remain false.
|
|
48
55
|
*/
|
|
@@ -225,6 +232,14 @@ export declare function prepareErrorResponse(errorMessage: string): {
|
|
|
225
232
|
export declare function initialize(event: {
|
|
226
233
|
body?: IncomingEventBody;
|
|
227
234
|
}): void;
|
|
235
|
+
/**
|
|
236
|
+
* initializeFromCustomElement initializes the SDK from a custom element context. This should be called
|
|
237
|
+
* at the beginning of the action handler to set up the SDK with incoming information, including context
|
|
238
|
+
* information, input parameters, and authentication information needed to make API requests to the Halix service.
|
|
239
|
+
*
|
|
240
|
+
* @param context - The custom element context
|
|
241
|
+
*/
|
|
242
|
+
export declare function initializeFromCustomElement(context: CustomElementContext): void;
|
|
228
243
|
/**
|
|
229
244
|
* SortField is an interface for specifying sort fields.
|
|
230
245
|
*/
|
|
@@ -395,4 +410,60 @@ export interface IncomingEventBody {
|
|
|
395
410
|
userContext: string;
|
|
396
411
|
params: Record<string, any>;
|
|
397
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* CustomElementContext is an interface defining the properties of the custom element context, which represents
|
|
415
|
+
* the state of the application front-end. A CustomElementContext is provided as property bound to Lit elements
|
|
416
|
+
* that back custom page elements.
|
|
417
|
+
*/
|
|
418
|
+
export interface CustomElementContext {
|
|
419
|
+
pageContext: {
|
|
420
|
+
[key: string]: any;
|
|
421
|
+
};
|
|
422
|
+
pageContext$: Observable<{
|
|
423
|
+
[key: string]: any;
|
|
424
|
+
}>;
|
|
425
|
+
groupObject: {
|
|
426
|
+
groupObject: any;
|
|
427
|
+
parent?: any;
|
|
428
|
+
groupChange: BehaviorSubject<number>;
|
|
429
|
+
};
|
|
430
|
+
session: {
|
|
431
|
+
solution: {
|
|
432
|
+
objKey: string;
|
|
433
|
+
name: string;
|
|
434
|
+
description: string;
|
|
435
|
+
sandboxKeys: string[];
|
|
436
|
+
};
|
|
437
|
+
sandbox: {
|
|
438
|
+
objKey: string;
|
|
439
|
+
id: string;
|
|
440
|
+
solutionKey: string;
|
|
441
|
+
organizationKey: string;
|
|
442
|
+
};
|
|
443
|
+
user: {
|
|
444
|
+
objKey: string;
|
|
445
|
+
username: string;
|
|
446
|
+
firstName: string;
|
|
447
|
+
lastName: string;
|
|
448
|
+
email: string;
|
|
449
|
+
photoKey: string;
|
|
450
|
+
thumbnail: string;
|
|
451
|
+
getFormattedName(): string;
|
|
452
|
+
};
|
|
453
|
+
currentComponent: {
|
|
454
|
+
id: string;
|
|
455
|
+
name: string;
|
|
456
|
+
componentConfig: any;
|
|
457
|
+
};
|
|
458
|
+
organizationKey: string;
|
|
459
|
+
organizationProxyKey: string;
|
|
460
|
+
organizationProxy: any;
|
|
461
|
+
userProxy: any;
|
|
462
|
+
secondaryScopeKey: string;
|
|
463
|
+
secondaryScopeLabel: string;
|
|
464
|
+
isLoggedIn(): boolean;
|
|
465
|
+
};
|
|
466
|
+
serviceAddress: string;
|
|
467
|
+
authTokenRetriever: () => Observable<string>;
|
|
468
|
+
}
|
|
398
469
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAQ,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAQ,UAAU,EAAE,eAAe,EAAqB,MAAM,MAAM,CAAC;AAE5E;;;;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;;;;;;;;;;;GAWG;AACH,eAAO,IAAI,aAAa,EAAE,GAAG,CAAC;AAE9B;;;GAGG;AACH,eAAO,IAAI,WAAW,EAAE;IACpB,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,EAAE,GAAG,CAAC;I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AAe,EAAE,MAAM,CAAC;SAC3B,CAAC;QACF,IAAI,EAAE;YACF,MAAM,EAAE,MAAM,CAAC;YACf,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,KAAK,EAAE,MAAM,CAAC;YACd,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,EAAE,MAAM,CAAC;YAClB,gBAAgB,IAAI,MAAM,CAAC;SAC9B,CAAC;QACF,gBAAgB,EAAE;YACd,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,EAAE,MAAM,CAAC;YACb,eAAe,EAAE,GAAG,CAAC;SACxB,CAAA;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,iBAAiB,EAAE,GAAG,CAAC;QACvB,SAAS,EAAE,GAAG,CAAC;QACf,iBAAiB,EAAE,MAAM,CAAC;QAC1B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,UAAU,IAAI,OAAO,CAAC;KACzB,CAAC;IACF,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;CAChD"}
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7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IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI;QAC3B,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS;QACrC,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,iBAAiB;QAC5C,WAAW,EAAE,OAAO,CAAC,OAAO,EAAE,oBAAoB;QAClD,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,eAAe;QACxC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM;KACnD,CAAA;IAED,YAAY,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;AACtD,CAAC"}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
* platform.
|
|
15
15
|
*/
|
|
16
16
|
import axios from 'axios';
|
|
17
|
-
import { from } from 'rxjs';
|
|
17
|
+
import { from, of, lastValueFrom } from 'rxjs';
|
|
18
18
|
/**
|
|
19
19
|
* authToken contains the authentication token that the action handler can use to make API requests
|
|
20
20
|
* to Halix web services. This value is set upon calling the initialize function with incoming event
|
|
21
21
|
* data.
|
|
22
22
|
*/
|
|
23
|
-
export let
|
|
23
|
+
export let getAuthToken;
|
|
24
24
|
/**
|
|
25
25
|
* sandboxKey contains the sandbox key identifier; identifies the sandbox that the action handler is
|
|
26
26
|
* running in. The sandbox identifies the current solution. This value is set upon calling the
|
|
@@ -58,7 +58,7 @@ export let userContext;
|
|
|
58
58
|
export let params;
|
|
59
59
|
/**
|
|
60
60
|
* useBody is a flag indicating how responses should be formatted. If true, the response will be
|
|
61
|
-
* returned an object with the HTTP response code and ActionResponse in the body field. If false,
|
|
61
|
+
* returned as an object with the HTTP response code and ActionResponse in the body field. If false,
|
|
62
62
|
* the ActionResponse will be returned directly. Typically, this does not need to be set by the
|
|
63
63
|
* action handler and should remain false.
|
|
64
64
|
*/
|
|
@@ -99,6 +99,7 @@ export async function getRelatedObjects(parentElementId, parentKey, elementId, f
|
|
|
99
99
|
params = new URLSearchParams(p);
|
|
100
100
|
}
|
|
101
101
|
let url = `${serviceAddress}/schema/sandboxes/${sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
|
|
102
|
+
let authToken = await lastValueFrom(getAuthToken());
|
|
102
103
|
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
103
104
|
let response = await axios.get(url, {
|
|
104
105
|
headers: { "Authorization": `Bearer ${authToken}` },
|
|
@@ -151,6 +152,7 @@ export async function getObject(dataElementId, key, fetchedRelationships) {
|
|
|
151
152
|
params = new URLSearchParams(p);
|
|
152
153
|
}
|
|
153
154
|
let url = `${serviceAddress}/schema/sandboxes/${sandboxKey}/${dataElementId}/${key}`;
|
|
155
|
+
let authToken = await lastValueFrom(getAuthToken());
|
|
154
156
|
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
155
157
|
let response = await axios.get(url, {
|
|
156
158
|
headers: { "Authorization": `Bearer ${authToken}` },
|
|
@@ -195,6 +197,7 @@ export async function saveRelatedObject(parentElementId, parentKey, elementId, o
|
|
|
195
197
|
else {
|
|
196
198
|
url += "?bypassValidation=true";
|
|
197
199
|
}
|
|
200
|
+
let authToken = await lastValueFrom(getAuthToken());
|
|
198
201
|
console.log("Sending POST request to " + url + " with token " + authToken);
|
|
199
202
|
let response = await axios.post(url, objectToSave, {
|
|
200
203
|
headers: { "Authorization": `Bearer ${authToken}` },
|
|
@@ -370,7 +373,29 @@ export function initialize(event) {
|
|
|
370
373
|
useBody = true;
|
|
371
374
|
}
|
|
372
375
|
if (body) {
|
|
373
|
-
({
|
|
376
|
+
({ sandboxKey, serviceAddress, actionSubject, userContext, params } = body);
|
|
377
|
+
getAuthToken = () => of(body.authToken);
|
|
374
378
|
}
|
|
375
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* initializeFromCustomElement initializes the SDK from a custom element context. This should be called
|
|
382
|
+
* at the beginning of the action handler to set up the SDK with incoming information, including context
|
|
383
|
+
* information, input parameters, and authentication information needed to make API requests to the Halix service.
|
|
384
|
+
*
|
|
385
|
+
* @param context - The custom element context
|
|
386
|
+
*/
|
|
387
|
+
export function initializeFromCustomElement(context) {
|
|
388
|
+
sandboxKey = context.session?.sandbox?.objKey;
|
|
389
|
+
serviceAddress = context.serviceAddress;
|
|
390
|
+
actionSubject = context.pageContext;
|
|
391
|
+
userContext = {
|
|
392
|
+
user: context.session?.user,
|
|
393
|
+
userProxy: context.session?.userProxy,
|
|
394
|
+
orgProxy: context.session?.organizationProxy,
|
|
395
|
+
orgProxyKey: context.session?.organizationProxyKey,
|
|
396
|
+
orgKey: context.session?.organizationKey,
|
|
397
|
+
userProxyKey: context.session?.userProxy?.objKey,
|
|
398
|
+
};
|
|
399
|
+
getAuthToken = () => context.authTokenRetriever();
|
|
400
|
+
}
|
|
376
401
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
1
|
+
import { Observable, BehaviorSubject } from 'rxjs';
|
|
2
2
|
/**
|
|
3
3
|
* authToken contains the authentication token that the action handler can use to make API requests
|
|
4
4
|
* to Halix web services. This value is set upon calling the initialize function with incoming event
|
|
5
5
|
* data.
|
|
6
6
|
*/
|
|
7
|
-
export declare let
|
|
7
|
+
export declare let getAuthToken: () => Observable<string>;
|
|
8
8
|
/**
|
|
9
9
|
* sandboxKey contains the sandbox key identifier; identifies the sandbox that the action handler is
|
|
10
10
|
* running in. The sandbox identifies the current solution. This value is set upon calling the
|
|
@@ -28,12 +28,19 @@ export declare let serviceAddress: string;
|
|
|
28
28
|
* - for calculatedFieldActions, the action subject is the object containing the calculated field
|
|
29
29
|
* - for singleValueActions, the action subject may differ depending on the caller
|
|
30
30
|
*/
|
|
31
|
-
export declare let actionSubject:
|
|
31
|
+
export declare let actionSubject: any;
|
|
32
32
|
/**
|
|
33
33
|
* userContext contains the user context information for the user that is executing the action.
|
|
34
34
|
* This value is set upon calling the initialize function with incoming event data.
|
|
35
35
|
*/
|
|
36
|
-
export declare let userContext:
|
|
36
|
+
export declare let userContext: {
|
|
37
|
+
user: any;
|
|
38
|
+
userProxy: any;
|
|
39
|
+
orgProxy: any;
|
|
40
|
+
orgProxyKey: string;
|
|
41
|
+
orgKey: string;
|
|
42
|
+
userProxyKey: string;
|
|
43
|
+
};
|
|
37
44
|
/**
|
|
38
45
|
* params contains the parameters passed to the action. If an input dialog is used, params will
|
|
39
46
|
* contain the values entered in the dialog. This value is set upon calling the initialize
|
|
@@ -42,7 +49,7 @@ export declare let userContext: string;
|
|
|
42
49
|
export declare let params: string;
|
|
43
50
|
/**
|
|
44
51
|
* useBody is a flag indicating how responses should be formatted. If true, the response will be
|
|
45
|
-
* returned an object with the HTTP response code and ActionResponse in the body field. If false,
|
|
52
|
+
* returned as an object with the HTTP response code and ActionResponse in the body field. If false,
|
|
46
53
|
* the ActionResponse will be returned directly. Typically, this does not need to be set by the
|
|
47
54
|
* action handler and should remain false.
|
|
48
55
|
*/
|
|
@@ -225,6 +232,14 @@ export declare function prepareErrorResponse(errorMessage: string): {
|
|
|
225
232
|
export declare function initialize(event: {
|
|
226
233
|
body?: IncomingEventBody;
|
|
227
234
|
}): void;
|
|
235
|
+
/**
|
|
236
|
+
* initializeFromCustomElement initializes the SDK from a custom element context. This should be called
|
|
237
|
+
* at the beginning of the action handler to set up the SDK with incoming information, including context
|
|
238
|
+
* information, input parameters, and authentication information needed to make API requests to the Halix service.
|
|
239
|
+
*
|
|
240
|
+
* @param context - The custom element context
|
|
241
|
+
*/
|
|
242
|
+
export declare function initializeFromCustomElement(context: CustomElementContext): void;
|
|
228
243
|
/**
|
|
229
244
|
* SortField is an interface for specifying sort fields.
|
|
230
245
|
*/
|
|
@@ -395,3 +410,59 @@ export interface IncomingEventBody {
|
|
|
395
410
|
userContext: string;
|
|
396
411
|
params: Record<string, any>;
|
|
397
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* CustomElementContext is an interface defining the properties of the custom element context, which represents
|
|
415
|
+
* the state of the application front-end. A CustomElementContext is provided as property bound to Lit elements
|
|
416
|
+
* that back custom page elements.
|
|
417
|
+
*/
|
|
418
|
+
export interface CustomElementContext {
|
|
419
|
+
pageContext: {
|
|
420
|
+
[key: string]: any;
|
|
421
|
+
};
|
|
422
|
+
pageContext$: Observable<{
|
|
423
|
+
[key: string]: any;
|
|
424
|
+
}>;
|
|
425
|
+
groupObject: {
|
|
426
|
+
groupObject: any;
|
|
427
|
+
parent?: any;
|
|
428
|
+
groupChange: BehaviorSubject<number>;
|
|
429
|
+
};
|
|
430
|
+
session: {
|
|
431
|
+
solution: {
|
|
432
|
+
objKey: string;
|
|
433
|
+
name: string;
|
|
434
|
+
description: string;
|
|
435
|
+
sandboxKeys: string[];
|
|
436
|
+
};
|
|
437
|
+
sandbox: {
|
|
438
|
+
objKey: string;
|
|
439
|
+
id: string;
|
|
440
|
+
solutionKey: string;
|
|
441
|
+
organizationKey: string;
|
|
442
|
+
};
|
|
443
|
+
user: {
|
|
444
|
+
objKey: string;
|
|
445
|
+
username: string;
|
|
446
|
+
firstName: string;
|
|
447
|
+
lastName: string;
|
|
448
|
+
email: string;
|
|
449
|
+
photoKey: string;
|
|
450
|
+
thumbnail: string;
|
|
451
|
+
getFormattedName(): string;
|
|
452
|
+
};
|
|
453
|
+
currentComponent: {
|
|
454
|
+
id: string;
|
|
455
|
+
name: string;
|
|
456
|
+
componentConfig: any;
|
|
457
|
+
};
|
|
458
|
+
organizationKey: string;
|
|
459
|
+
organizationProxyKey: string;
|
|
460
|
+
organizationProxy: any;
|
|
461
|
+
userProxy: any;
|
|
462
|
+
secondaryScopeKey: string;
|
|
463
|
+
secondaryScopeLabel: string;
|
|
464
|
+
isLoggedIn(): boolean;
|
|
465
|
+
};
|
|
466
|
+
serviceAddress: string;
|
|
467
|
+
authTokenRetriever: () => Observable<string>;
|
|
468
|
+
}
|