@halix/action-sdk 1.0.2 → 1.0.4
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,9 +12,8 @@ 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
|
-
let useBody = false;
|
|
18
17
|
function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
19
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
19
|
let params;
|
|
@@ -42,9 +41,12 @@ function getObject(dataElementId, key) {
|
|
|
42
41
|
});
|
|
43
42
|
}
|
|
44
43
|
exports.getObject = getObject;
|
|
45
|
-
function saveRelatedObject(parentElementId, parentKey, elementId, objectToSave) {
|
|
44
|
+
function saveRelatedObject(parentElementId, parentKey, elementId, objectToSave, opts) {
|
|
46
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
46
|
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
|
|
47
|
+
if (opts === null || opts === void 0 ? void 0 : opts.bypassValidation) {
|
|
48
|
+
url += "?bypassValidation=true";
|
|
49
|
+
}
|
|
48
50
|
console.log("Sending POST request to " + url + " with token " + exports.authToken);
|
|
49
51
|
let response = yield axios_1.default.post(url, objectToSave, {
|
|
50
52
|
headers: { "Authorization": `Bearer ${exports.authToken}` },
|
|
@@ -125,7 +127,7 @@ function getValueFromObject(object, attribute) {
|
|
|
125
127
|
}
|
|
126
128
|
exports.getValueFromObject = getValueFromObject;
|
|
127
129
|
function prepareSuccessResponse(returnVal) {
|
|
128
|
-
if (useBody) {
|
|
130
|
+
if (exports.useBody) {
|
|
129
131
|
return {
|
|
130
132
|
statusCode: 200,
|
|
131
133
|
body: JSON.stringify(returnVal)
|
|
@@ -135,7 +137,7 @@ function prepareSuccessResponse(returnVal) {
|
|
|
135
137
|
}
|
|
136
138
|
exports.prepareSuccessResponse = prepareSuccessResponse;
|
|
137
139
|
function prepareErrorResponse(errorMessage) {
|
|
138
|
-
if (useBody) {
|
|
140
|
+
if (exports.useBody) {
|
|
139
141
|
return {
|
|
140
142
|
statusCode: 400,
|
|
141
143
|
body: JSON.stringify({ errorMessage })
|
|
@@ -148,7 +150,7 @@ function initialize(event) {
|
|
|
148
150
|
let body = event;
|
|
149
151
|
if (event.body) {
|
|
150
152
|
body = event.body;
|
|
151
|
-
useBody = true;
|
|
153
|
+
exports.useBody = true;
|
|
152
154
|
}
|
|
153
155
|
({ authToken: exports.authToken, sandboxKey: exports.sandboxKey, serviceAddress: exports.serviceAddress, actionSubject: exports.actionSubject, userContext: exports.userContext, params: exports.params } = body);
|
|
154
156
|
}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
export declare function saveRelatedObject(parentElementId: string, parentKey: string, elementId: string, objectToSave: string): Promise<any>;
|
|
4
|
+
export declare function saveRelatedObject(parentElementId: string, parentKey: string, elementId: string, objectToSave: string, opts?: SaveOptions): 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;
|
|
@@ -24,4 +24,7 @@ export interface SortField {
|
|
|
24
24
|
caseInsensitive?: boolean;
|
|
25
25
|
autoSequence?: boolean;
|
|
26
26
|
}
|
|
27
|
+
export interface SaveOptions {
|
|
28
|
+
bypassValidation?: boolean;
|
|
29
|
+
}
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,EAAE,IAAI,CAAC,EAAE,WAAW,gBAc9I;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;AAED,MAAM,WAAW,WAAW;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B"}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
export let authToken, sandboxKey, serviceAddress, actionSubject, userContext, params;
|
|
3
|
-
let useBody = false;
|
|
2
|
+
export let authToken, sandboxKey, serviceAddress, actionSubject, userContext, params, useBody;
|
|
4
3
|
export async function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
5
4
|
let params;
|
|
6
5
|
if (filter) {
|
|
@@ -22,8 +21,11 @@ export async function getObject(dataElementId, key) {
|
|
|
22
21
|
});
|
|
23
22
|
return response.data;
|
|
24
23
|
}
|
|
25
|
-
export async function saveRelatedObject(parentElementId, parentKey, elementId, objectToSave) {
|
|
24
|
+
export async function saveRelatedObject(parentElementId, parentKey, elementId, objectToSave, opts) {
|
|
26
25
|
let url = `${serviceAddress}/schema/sandboxes/${sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
|
|
26
|
+
if (opts?.bypassValidation) {
|
|
27
|
+
url += "?bypassValidation=true";
|
|
28
|
+
}
|
|
27
29
|
console.log("Sending POST request to " + url + " with token " + authToken);
|
|
28
30
|
let response = await axios.post(url, objectToSave, {
|
|
29
31
|
headers: { "Authorization": `Bearer ${authToken}` },
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
export declare function saveRelatedObject(parentElementId: string, parentKey: string, elementId: string, objectToSave: string): Promise<any>;
|
|
4
|
+
export declare function saveRelatedObject(parentElementId: string, parentKey: string, elementId: string, objectToSave: string, opts?: SaveOptions): 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;
|
|
@@ -24,4 +24,7 @@ export interface SortField {
|
|
|
24
24
|
caseInsensitive?: boolean;
|
|
25
25
|
autoSequence?: boolean;
|
|
26
26
|
}
|
|
27
|
+
export interface SaveOptions {
|
|
28
|
+
bypassValidation?: boolean;
|
|
29
|
+
}
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,EAAE,IAAI,CAAC,EAAE,WAAW,gBAc9I;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;AAED,MAAM,WAAW,WAAW;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B"}
|