@halix/action-sdk 1.0.0 → 1.0.2
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 +20 -10
- package/lib/cjs/types/index.d.ts +7 -5
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/esm/index.mjs +20 -10
- package/lib/esm/types/index.d.ts +7 -5
- package/lib/esm/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.initialize = exports.prepareErrorResponse = exports.prepareSuccessResponse = exports.getValueFromObject = exports.compareValues = exports.sortObjectArray = exports.saveRelatedObject = exports.getObject = exports.getRelatedObjects = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.authToken = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
let useBody = false;
|
|
17
18
|
function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
20
|
let params;
|
|
@@ -124,22 +125,31 @@ function getValueFromObject(object, attribute) {
|
|
|
124
125
|
}
|
|
125
126
|
exports.getValueFromObject = getValueFromObject;
|
|
126
127
|
function prepareSuccessResponse(returnVal) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
if (useBody) {
|
|
129
|
+
return {
|
|
130
|
+
statusCode: 200,
|
|
131
|
+
body: JSON.stringify(returnVal)
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return returnVal;
|
|
131
135
|
}
|
|
132
136
|
exports.prepareSuccessResponse = prepareSuccessResponse;
|
|
133
137
|
function prepareErrorResponse(errorMessage) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
if (useBody) {
|
|
139
|
+
return {
|
|
140
|
+
statusCode: 400,
|
|
141
|
+
body: JSON.stringify({ errorMessage })
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return { errorMessage };
|
|
138
145
|
}
|
|
139
146
|
exports.prepareErrorResponse = prepareErrorResponse;
|
|
140
147
|
function initialize(event) {
|
|
141
|
-
|
|
148
|
+
let body = event;
|
|
149
|
+
if (event.body) {
|
|
150
|
+
body = event.body;
|
|
151
|
+
useBody = true;
|
|
152
|
+
}
|
|
142
153
|
({ authToken: exports.authToken, sandboxKey: exports.sandboxKey, serviceAddress: exports.serviceAddress, actionSubject: exports.actionSubject, userContext: exports.userContext, params: exports.params } = body);
|
|
143
|
-
// ({ userProxy, orgProxy, user } = userContext);
|
|
144
154
|
}
|
|
145
155
|
exports.initialize = initialize;
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -5,16 +5,18 @@ export declare function saveRelatedObject(parentElementId: string, parentKey: st
|
|
|
5
5
|
export declare function sortObjectArray<T>(array: Array<T>, sort: SortField[]): T[];
|
|
6
6
|
export declare function compareValues(valueA: any, valueB: any, descending: boolean, caseInsensitive: boolean): number;
|
|
7
7
|
export declare function getValueFromObject(object: any, attribute: string): any;
|
|
8
|
-
export declare function prepareSuccessResponse(returnVal: any):
|
|
9
|
-
statusCode: number;
|
|
10
|
-
body: string;
|
|
11
|
-
};
|
|
8
|
+
export declare function prepareSuccessResponse(returnVal: any): any;
|
|
12
9
|
export declare function prepareErrorResponse(errorMessage: string): {
|
|
13
10
|
statusCode: number;
|
|
14
11
|
body: string;
|
|
12
|
+
errorMessage?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
errorMessage: string;
|
|
15
|
+
statusCode?: undefined;
|
|
16
|
+
body?: undefined;
|
|
15
17
|
};
|
|
16
18
|
export declare function initialize(event: {
|
|
17
|
-
body
|
|
19
|
+
body?: any;
|
|
18
20
|
}): void;
|
|
19
21
|
export interface SortField {
|
|
20
22
|
attributeId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,IAAI,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,IAAI,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;AAGrI,wBAAsB,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAiBpH;AAED,wBAAsB,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAWjE;AAED,wBAAsB,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAW1H;AAMD,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAiBpE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CA2B7G;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAuBhE;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,GAAG,OASpD;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM;;;;;;;;EASxD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,GAAG,CAAA;CAAE,QAS/C;AAED,MAAM,WAAW,SAAS;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
export let authToken, sandboxKey, serviceAddress, actionSubject, userContext, params;
|
|
3
|
+
let useBody = false;
|
|
3
4
|
export async function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
4
5
|
let params;
|
|
5
6
|
if (filter) {
|
|
@@ -98,19 +99,28 @@ export function getValueFromObject(object, attribute) {
|
|
|
98
99
|
return value;
|
|
99
100
|
}
|
|
100
101
|
export function prepareSuccessResponse(returnVal) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (useBody) {
|
|
103
|
+
return {
|
|
104
|
+
statusCode: 200,
|
|
105
|
+
body: JSON.stringify(returnVal)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return returnVal;
|
|
105
109
|
}
|
|
106
110
|
export function prepareErrorResponse(errorMessage) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
if (useBody) {
|
|
112
|
+
return {
|
|
113
|
+
statusCode: 400,
|
|
114
|
+
body: JSON.stringify({ errorMessage })
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return { errorMessage };
|
|
111
118
|
}
|
|
112
119
|
export function initialize(event) {
|
|
113
|
-
|
|
120
|
+
let body = event;
|
|
121
|
+
if (event.body) {
|
|
122
|
+
body = event.body;
|
|
123
|
+
useBody = true;
|
|
124
|
+
}
|
|
114
125
|
({ authToken, sandboxKey, serviceAddress, actionSubject, userContext, params } = body);
|
|
115
|
-
// ({ userProxy, orgProxy, user } = userContext);
|
|
116
126
|
}
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -5,16 +5,18 @@ export declare function saveRelatedObject(parentElementId: string, parentKey: st
|
|
|
5
5
|
export declare function sortObjectArray<T>(array: Array<T>, sort: SortField[]): T[];
|
|
6
6
|
export declare function compareValues(valueA: any, valueB: any, descending: boolean, caseInsensitive: boolean): number;
|
|
7
7
|
export declare function getValueFromObject(object: any, attribute: string): any;
|
|
8
|
-
export declare function prepareSuccessResponse(returnVal: any):
|
|
9
|
-
statusCode: number;
|
|
10
|
-
body: string;
|
|
11
|
-
};
|
|
8
|
+
export declare function prepareSuccessResponse(returnVal: any): any;
|
|
12
9
|
export declare function prepareErrorResponse(errorMessage: string): {
|
|
13
10
|
statusCode: number;
|
|
14
11
|
body: string;
|
|
12
|
+
errorMessage?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
errorMessage: string;
|
|
15
|
+
statusCode?: undefined;
|
|
16
|
+
body?: undefined;
|
|
15
17
|
};
|
|
16
18
|
export declare function initialize(event: {
|
|
17
|
-
body
|
|
19
|
+
body?: any;
|
|
18
20
|
}): void;
|
|
19
21
|
export interface SortField {
|
|
20
22
|
attributeId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,IAAI,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,IAAI,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,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