@halix/action-sdk 1.0.1 → 1.0.3
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
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
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.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.authToken = void 0;
|
|
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;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -124,23 +124,30 @@ function getValueFromObject(object, attribute) {
|
|
|
124
124
|
}
|
|
125
125
|
exports.getValueFromObject = getValueFromObject;
|
|
126
126
|
function prepareSuccessResponse(returnVal) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
if (exports.useBody) {
|
|
128
|
+
return {
|
|
129
|
+
statusCode: 200,
|
|
130
|
+
body: JSON.stringify(returnVal)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return returnVal;
|
|
131
134
|
}
|
|
132
135
|
exports.prepareSuccessResponse = prepareSuccessResponse;
|
|
133
136
|
function prepareErrorResponse(errorMessage) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
if (exports.useBody) {
|
|
138
|
+
return {
|
|
139
|
+
statusCode: 400,
|
|
140
|
+
body: JSON.stringify({ errorMessage })
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return { errorMessage };
|
|
138
144
|
}
|
|
139
145
|
exports.prepareErrorResponse = prepareErrorResponse;
|
|
140
146
|
function initialize(event) {
|
|
141
147
|
let body = event;
|
|
142
148
|
if (event.body) {
|
|
143
149
|
body = event.body;
|
|
150
|
+
exports.useBody = true;
|
|
144
151
|
}
|
|
145
152
|
({ authToken: exports.authToken, sandboxKey: exports.sandboxKey, serviceAddress: exports.serviceAddress, actionSubject: exports.actionSubject, userContext: exports.userContext, params: exports.params } = body);
|
|
146
153
|
}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
export declare let authToken: string, sandboxKey: string, serviceAddress: string, actionSubject: string, userContext: string, params: string;
|
|
1
|
+
export declare let authToken: string, sandboxKey: string, serviceAddress: string, actionSubject: string, userContext: string, params: string, useBody: boolean;
|
|
2
2
|
export declare function getRelatedObjects(parentElementId: string, parentKey: string, elementId: string, filter: string): Promise<any>;
|
|
3
3
|
export declare function getObject(dataElementId: string, key: string): Promise<any>;
|
|
4
4
|
export declare function saveRelatedObject(parentElementId: string, parentKey: string, elementId: string, objectToSave: string): Promise<any>;
|
|
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
19
|
body?: any;
|
|
@@ -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,EAAE,OAAO,EAAE,OAAO,CAAC;AAEvJ,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,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
export let authToken, sandboxKey, serviceAddress, actionSubject, userContext, params;
|
|
2
|
+
export let authToken, sandboxKey, serviceAddress, actionSubject, userContext, params, useBody;
|
|
3
3
|
export async function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
4
4
|
let params;
|
|
5
5
|
if (filter) {
|
|
@@ -98,21 +98,28 @@ export function getValueFromObject(object, attribute) {
|
|
|
98
98
|
return value;
|
|
99
99
|
}
|
|
100
100
|
export function prepareSuccessResponse(returnVal) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
if (useBody) {
|
|
102
|
+
return {
|
|
103
|
+
statusCode: 200,
|
|
104
|
+
body: JSON.stringify(returnVal)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return returnVal;
|
|
105
108
|
}
|
|
106
109
|
export function prepareErrorResponse(errorMessage) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
if (useBody) {
|
|
111
|
+
return {
|
|
112
|
+
statusCode: 400,
|
|
113
|
+
body: JSON.stringify({ errorMessage })
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return { errorMessage };
|
|
111
117
|
}
|
|
112
118
|
export function initialize(event) {
|
|
113
119
|
let body = event;
|
|
114
120
|
if (event.body) {
|
|
115
121
|
body = event.body;
|
|
122
|
+
useBody = true;
|
|
116
123
|
}
|
|
117
124
|
({ authToken, sandboxKey, serviceAddress, actionSubject, userContext, params } = body);
|
|
118
125
|
}
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
export declare let authToken: string, sandboxKey: string, serviceAddress: string, actionSubject: string, userContext: string, params: string;
|
|
1
|
+
export declare let authToken: string, sandboxKey: string, serviceAddress: string, actionSubject: string, userContext: string, params: string, useBody: boolean;
|
|
2
2
|
export declare function getRelatedObjects(parentElementId: string, parentKey: string, elementId: string, filter: string): Promise<any>;
|
|
3
3
|
export declare function getObject(dataElementId: string, key: string): Promise<any>;
|
|
4
4
|
export declare function saveRelatedObject(parentElementId: string, parentKey: string, elementId: string, objectToSave: string): Promise<any>;
|
|
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
19
|
body?: any;
|
|
@@ -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,EAAE,OAAO,EAAE,OAAO,CAAC;AAEvJ,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"}
|