@halix/action-sdk 1.0.4 → 1.0.6
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
|
@@ -14,11 +14,18 @@ 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.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.authToken = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
17
|
+
function getRelatedObjects(parentElementId, parentKey, elementId, filter, fetchedRelationships) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
let params;
|
|
20
|
-
if (filter) {
|
|
21
|
-
|
|
20
|
+
if (filter || fetchedRelationships) {
|
|
21
|
+
let p = {};
|
|
22
|
+
if (filter) {
|
|
23
|
+
p.filter = filter;
|
|
24
|
+
}
|
|
25
|
+
if (fetchedRelationships) {
|
|
26
|
+
p.fetchedRelationships = fetchedRelationships.join(",");
|
|
27
|
+
}
|
|
28
|
+
params = new URLSearchParams(p);
|
|
22
29
|
}
|
|
23
30
|
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
|
|
24
31
|
console.log("Sending GET request to " + url + " with token " + exports.authToken);
|
|
@@ -30,12 +37,21 @@ function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
|
30
37
|
});
|
|
31
38
|
}
|
|
32
39
|
exports.getRelatedObjects = getRelatedObjects;
|
|
33
|
-
function getObject(dataElementId, key) {
|
|
40
|
+
function getObject(dataElementId, key, fetchedRelationships) {
|
|
34
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
let params;
|
|
43
|
+
if (fetchedRelationships) {
|
|
44
|
+
let p = {};
|
|
45
|
+
if (fetchedRelationships) {
|
|
46
|
+
p.fetchedRelationships = fetchedRelationships.join(",");
|
|
47
|
+
}
|
|
48
|
+
params = new URLSearchParams(p);
|
|
49
|
+
}
|
|
35
50
|
let url = `${exports.serviceAddress}/schema/sandboxes/${exports.sandboxKey}/${dataElementId}/${key}`;
|
|
36
51
|
console.log("Sending GET request to " + url + " with token " + exports.authToken);
|
|
37
52
|
let response = yield axios_1.default.get(url, {
|
|
38
53
|
headers: { "Authorization": `Bearer ${exports.authToken}` },
|
|
54
|
+
params: params,
|
|
39
55
|
});
|
|
40
56
|
return response.data;
|
|
41
57
|
});
|
|
@@ -143,7 +159,7 @@ function prepareErrorResponse(errorMessage) {
|
|
|
143
159
|
body: JSON.stringify({ errorMessage })
|
|
144
160
|
};
|
|
145
161
|
}
|
|
146
|
-
return { errorMessage };
|
|
162
|
+
return { errorMessage, responseType: "error" };
|
|
147
163
|
}
|
|
148
164
|
exports.prepareErrorResponse = prepareErrorResponse;
|
|
149
165
|
function initialize(event) {
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare let authToken: string, sandboxKey: string, serviceAddress: string, actionSubject: string, userContext: string, params: string, useBody: boolean;
|
|
2
|
-
export declare function getRelatedObjects(parentElementId: string, parentKey: string, elementId: string, filter: string): Promise<any>;
|
|
3
|
-
export declare function getObject(dataElementId: string, key: string): Promise<any>;
|
|
2
|
+
export declare function getRelatedObjects(parentElementId: string, parentKey: string, elementId: string, filter: string, fetchedRelationships?: string[]): Promise<any>;
|
|
3
|
+
export declare function getObject(dataElementId: string, key: string, fetchedRelationships?: string[]): Promise<any>;
|
|
4
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;
|
|
@@ -10,8 +10,10 @@ export declare function prepareErrorResponse(errorMessage: string): {
|
|
|
10
10
|
statusCode: number;
|
|
11
11
|
body: string;
|
|
12
12
|
errorMessage?: undefined;
|
|
13
|
+
responseType?: undefined;
|
|
13
14
|
} | {
|
|
14
15
|
errorMessage: string;
|
|
16
|
+
responseType: string;
|
|
15
17
|
statusCode?: undefined;
|
|
16
18
|
body?: undefined;
|
|
17
19
|
};
|
|
@@ -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,EAAE,OAAO,EAAE,OAAO,CAAC;AAEvJ,wBAAsB,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,
|
|
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,EAAE,oBAAoB,CAAC,EAAE,MAAM,EAAE,gBAyBrJ;AAED,wBAAsB,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,MAAM,EAAE,gBAsBlG;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,9 +1,16 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
export let authToken, sandboxKey, serviceAddress, actionSubject, userContext, params, useBody;
|
|
3
|
-
export async function getRelatedObjects(parentElementId, parentKey, elementId, filter) {
|
|
3
|
+
export async function getRelatedObjects(parentElementId, parentKey, elementId, filter, fetchedRelationships) {
|
|
4
4
|
let params;
|
|
5
|
-
if (filter) {
|
|
6
|
-
|
|
5
|
+
if (filter || fetchedRelationships) {
|
|
6
|
+
let p = {};
|
|
7
|
+
if (filter) {
|
|
8
|
+
p.filter = filter;
|
|
9
|
+
}
|
|
10
|
+
if (fetchedRelationships) {
|
|
11
|
+
p.fetchedRelationships = fetchedRelationships.join(",");
|
|
12
|
+
}
|
|
13
|
+
params = new URLSearchParams(p);
|
|
7
14
|
}
|
|
8
15
|
let url = `${serviceAddress}/schema/sandboxes/${sandboxKey}/${parentElementId}/${parentKey}/${elementId}`;
|
|
9
16
|
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
@@ -13,11 +20,20 @@ export async function getRelatedObjects(parentElementId, parentKey, elementId, f
|
|
|
13
20
|
});
|
|
14
21
|
return response.data;
|
|
15
22
|
}
|
|
16
|
-
export async function getObject(dataElementId, key) {
|
|
23
|
+
export async function getObject(dataElementId, key, fetchedRelationships) {
|
|
24
|
+
let params;
|
|
25
|
+
if (fetchedRelationships) {
|
|
26
|
+
let p = {};
|
|
27
|
+
if (fetchedRelationships) {
|
|
28
|
+
p.fetchedRelationships = fetchedRelationships.join(",");
|
|
29
|
+
}
|
|
30
|
+
params = new URLSearchParams(p);
|
|
31
|
+
}
|
|
17
32
|
let url = `${serviceAddress}/schema/sandboxes/${sandboxKey}/${dataElementId}/${key}`;
|
|
18
33
|
console.log("Sending GET request to " + url + " with token " + authToken);
|
|
19
34
|
let response = await axios.get(url, {
|
|
20
35
|
headers: { "Authorization": `Bearer ${authToken}` },
|
|
36
|
+
params: params,
|
|
21
37
|
});
|
|
22
38
|
return response.data;
|
|
23
39
|
}
|
|
@@ -116,7 +132,7 @@ export function prepareErrorResponse(errorMessage) {
|
|
|
116
132
|
body: JSON.stringify({ errorMessage })
|
|
117
133
|
};
|
|
118
134
|
}
|
|
119
|
-
return { errorMessage };
|
|
135
|
+
return { errorMessage, responseType: "error" };
|
|
120
136
|
}
|
|
121
137
|
export function initialize(event) {
|
|
122
138
|
let body = event;
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare let authToken: string, sandboxKey: string, serviceAddress: string, actionSubject: string, userContext: string, params: string, useBody: boolean;
|
|
2
|
-
export declare function getRelatedObjects(parentElementId: string, parentKey: string, elementId: string, filter: string): Promise<any>;
|
|
3
|
-
export declare function getObject(dataElementId: string, key: string): Promise<any>;
|
|
2
|
+
export declare function getRelatedObjects(parentElementId: string, parentKey: string, elementId: string, filter: string, fetchedRelationships?: string[]): Promise<any>;
|
|
3
|
+
export declare function getObject(dataElementId: string, key: string, fetchedRelationships?: string[]): Promise<any>;
|
|
4
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;
|
|
@@ -10,8 +10,10 @@ export declare function prepareErrorResponse(errorMessage: string): {
|
|
|
10
10
|
statusCode: number;
|
|
11
11
|
body: string;
|
|
12
12
|
errorMessage?: undefined;
|
|
13
|
+
responseType?: undefined;
|
|
13
14
|
} | {
|
|
14
15
|
errorMessage: string;
|
|
16
|
+
responseType: string;
|
|
15
17
|
statusCode?: undefined;
|
|
16
18
|
body?: undefined;
|
|
17
19
|
};
|
|
@@ -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,EAAE,OAAO,EAAE,OAAO,CAAC;AAEvJ,wBAAsB,iBAAiB,CAAC,eAAe,E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