@openinc/parse-server-opendash 2.4.23 → 2.4.31

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.
@@ -1,50 +1,50 @@
1
- {
2
- "fields": {
3
- "label": {
4
- "type": "String",
5
- "required": true,
6
- "defaultValue": "VKPI-Label"
7
- },
8
- "pipe": {
9
- "type": "Object",
10
- "required": false,
11
- "defaultValue": {
12
- "stages": []
13
- }
14
- },
15
- "template": {
16
- "type": "Object",
17
- "required": true,
18
- "defaultValue": {}
19
- },
20
- "tenant": {
21
- "type": "Pointer",
22
- "targetClass": "{{PREFIX}}Tenant",
23
- "required": false
24
- }
25
- },
26
- "classLevelPermissions": {
27
- "find": {
28
- "requiresAuthentication": true
29
- },
30
- "count": {
31
- "requiresAuthentication": true
32
- },
33
- "get": {
34
- "requiresAuthentication": true
35
- },
36
- "create": {
37
- "requiresAuthentication": true
38
- },
39
- "update": {
40
- "requiresAuthentication": true
41
- },
42
- "delete": {
43
- "requiresAuthentication": true
44
- },
45
- "addField": {},
46
- "protectedFields": {
47
- "*": []
48
- }
49
- }
50
- }
1
+ {
2
+ "fields": {
3
+ "label": {
4
+ "type": "String",
5
+ "required": true,
6
+ "defaultValue": "VKPI-Label"
7
+ },
8
+ "pipe": {
9
+ "type": "Object",
10
+ "required": false,
11
+ "defaultValue": {
12
+ "stages": []
13
+ }
14
+ },
15
+ "template": {
16
+ "type": "Object",
17
+ "required": true,
18
+ "defaultValue": {}
19
+ },
20
+ "tenant": {
21
+ "type": "Pointer",
22
+ "targetClass": "{{PREFIX}}Tenant",
23
+ "required": false
24
+ }
25
+ },
26
+ "classLevelPermissions": {
27
+ "find": {
28
+ "requiresAuthentication": true
29
+ },
30
+ "count": {
31
+ "requiresAuthentication": true
32
+ },
33
+ "get": {
34
+ "requiresAuthentication": true
35
+ },
36
+ "create": {
37
+ "requiresAuthentication": true
38
+ },
39
+ "update": {
40
+ "requiresAuthentication": true
41
+ },
42
+ "delete": {
43
+ "requiresAuthentication": true
44
+ },
45
+ "addField": {},
46
+ "protectedFields": {
47
+ "*": []
48
+ }
49
+ }
50
+ }
@@ -1,42 +1,42 @@
1
- {
2
- "fields": {
3
- "label": {
4
- "type": "String",
5
- "required": false,
6
- "defaultValue": ""
7
- },
8
- "subscription": {
9
- "type": "Object",
10
- "required": true
11
- },
12
- "user": {
13
- "type": "Pointer",
14
- "targetClass": "_User",
15
- "required": true
16
- }
17
- },
18
- "classLevelPermissions": {
19
- "find": {
20
- "requiresAuthentication": true
21
- },
22
- "count": {
23
- "requiresAuthentication": true
24
- },
25
- "get": {
26
- "requiresAuthentication": true
27
- },
28
- "create": {
29
- "requiresAuthentication": true
30
- },
31
- "update": {
32
- "requiresAuthentication": true
33
- },
34
- "delete": {
35
- "requiresAuthentication": true
36
- },
37
- "addField": {},
38
- "protectedFields": {
39
- "*": []
40
- }
41
- }
42
- }
1
+ {
2
+ "fields": {
3
+ "label": {
4
+ "type": "String",
5
+ "required": false,
6
+ "defaultValue": ""
7
+ },
8
+ "subscription": {
9
+ "type": "Object",
10
+ "required": true
11
+ },
12
+ "user": {
13
+ "type": "Pointer",
14
+ "targetClass": "_User",
15
+ "required": true
16
+ }
17
+ },
18
+ "classLevelPermissions": {
19
+ "find": {
20
+ "requiresAuthentication": true
21
+ },
22
+ "count": {
23
+ "requiresAuthentication": true
24
+ },
25
+ "get": {
26
+ "requiresAuthentication": true
27
+ },
28
+ "create": {
29
+ "requiresAuthentication": true
30
+ },
31
+ "update": {
32
+ "requiresAuthentication": true
33
+ },
34
+ "delete": {
35
+ "requiresAuthentication": true
36
+ },
37
+ "addField": {},
38
+ "protectedFields": {
39
+ "*": []
40
+ }
41
+ }
42
+ }
@@ -1 +0,0 @@
1
- export declare function init(name: string): Promise<void>;
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.init = void 0;
4
- const __1 = require("..");
5
- async function init(name) {
6
- Parse.Cloud.define(name, async (request) => {
7
- const API_KEY = (0, __1.getEnv)("PARSE_SERVER_GEO_GOOGLE_API_KEY");
8
- if (!API_KEY) {
9
- throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-1]`);
10
- }
11
- const limit = request.params.limit;
12
- const input = request.params.query;
13
- try {
14
- // https://developers.google.com/maps/documentation/places/web-service/autocomplete
15
- const response = await Parse.Cloud.httpRequest({
16
- url: "https://maps.googleapis.com/maps/api/place/autocomplete/json",
17
- params: {
18
- key: API_KEY,
19
- input,
20
- },
21
- });
22
- const result = [];
23
- for (const prediction of response.data.predictions) {
24
- if (result.length >= limit) {
25
- break;
26
- }
27
- // https://developers.google.com/maps/documentation/places/web-service/details
28
- const placeResponse = await Parse.Cloud.httpRequest({
29
- url: "https://maps.googleapis.com/maps/api/place/details/json",
30
- params: {
31
- key: API_KEY,
32
- fields: "name,formatted_address,geometry",
33
- sensor: true,
34
- reference: prediction.reference,
35
- },
36
- });
37
- const place = placeResponse.data.result;
38
- result.push({
39
- ref: prediction.reference,
40
- title: place.name,
41
- titleFull: prediction.description,
42
- description: removeTitle(place.name, prediction.description),
43
- address: place.formatted_address,
44
- latitude: place.geometry.location.lat,
45
- longitude: place.geometry.location.lng,
46
- });
47
- }
48
- return result;
49
- }
50
- catch (error) {
51
- console.error(error);
52
- return [];
53
- }
54
- }, {
55
- requireUser: true,
56
- fields: ["query", "limit", "latitude", "longitude"],
57
- });
58
- }
59
- exports.init = init;
60
- function removeTitle(title, description) {
61
- const prefix = `${title}, `;
62
- if (description.startsWith(prefix)) {
63
- return description.replace(prefix, "");
64
- }
65
- return description;
66
- }
@@ -1 +0,0 @@
1
- export declare function init(name: string): Promise<void>;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.init = void 0;
4
- const __1 = require("..");
5
- const opendash_geo_graphhopper_geocode_1 = require("./opendash-geo-graphhopper-geocode");
6
- async function init(name) {
7
- Parse.Cloud.define(name, async function (request) {
8
- const GRAPHHOPPER_HOST = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_HOST");
9
- if (!GRAPHHOPPER_HOST) {
10
- throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-1]`);
11
- }
12
- const GRAPHHOPPER_API_KEY = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_API_KEY");
13
- if (!GRAPHHOPPER_API_KEY) {
14
- throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-2]`);
15
- }
16
- try {
17
- const response = await Parse.Cloud.httpRequest({
18
- url: GRAPHHOPPER_HOST + "/geocode",
19
- params: {
20
- key: GRAPHHOPPER_API_KEY,
21
- locale: "de",
22
- reverse: "true",
23
- point: request.params.latitude + "," + request.params.longitude,
24
- },
25
- });
26
- return (0, opendash_geo_graphhopper_geocode_1.getGeoCodingResult)(response.data.hits);
27
- }
28
- catch (error) {
29
- console.error(error);
30
- return [];
31
- }
32
- }, {
33
- requireUser: true,
34
- fields: ["latitude", "longitude"],
35
- });
36
- }
37
- exports.init = init;
@@ -1,2 +0,0 @@
1
- export declare function init(name: string): Promise<void>;
2
- export declare function getGeoCodingResult(hits: any): any;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGeoCodingResult = exports.init = void 0;
4
- const __1 = require("..");
5
- async function init(name) {
6
- Parse.Cloud.define(name, async function (request) {
7
- const GRAPHHOPPER_HOST = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_HOST");
8
- if (!GRAPHHOPPER_HOST) {
9
- throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-1]`);
10
- }
11
- const GRAPHHOPPER_API_KEY = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_API_KEY");
12
- if (!GRAPHHOPPER_API_KEY) {
13
- throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-2]`);
14
- }
15
- try {
16
- const response = await Parse.Cloud.httpRequest({
17
- url: GRAPHHOPPER_HOST + "/geocode",
18
- params: {
19
- key: GRAPHHOPPER_API_KEY,
20
- locale: "de",
21
- limit: "3",
22
- q: request.params.query,
23
- point: request.params.latitude + "," + request.params.longitude,
24
- },
25
- });
26
- return getGeoCodingResult(response.data.hits);
27
- }
28
- catch (error) {
29
- console.error(error);
30
- return [];
31
- }
32
- }, {
33
- requireUser: true,
34
- fields: ["query", "latitude", "longitude"],
35
- });
36
- }
37
- exports.init = init;
38
- function getGeoCodingResult(hits) {
39
- return hits.map((hit) => ({
40
- title: getGeoCodingTitle(hit),
41
- description: getGeoCodingDescription(hit),
42
- latitude: hit.point.lat,
43
- longitude: hit.point.lng,
44
- }));
45
- }
46
- exports.getGeoCodingResult = getGeoCodingResult;
47
- function getGeoCodingTitle(hit) {
48
- if (hit.name && hit.housenumber) {
49
- return hit.name + " " + hit.housenumber;
50
- }
51
- return hit.name;
52
- }
53
- function getGeoCodingDescription(hit) {
54
- const country = hit.country ? `, ${hit.country}` : "";
55
- if (hit.city && hit.postcode) {
56
- return hit.postcode + " " + hit.city + country;
57
- }
58
- if (hit.city) {
59
- return hit.city + country;
60
- }
61
- if (hit.postcode) {
62
- return hit.postcode + country;
63
- }
64
- return "";
65
- }
@@ -1 +0,0 @@
1
- export declare function init(name: string): Promise<void>;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.init = void 0;
4
- async function init(name) {
5
- Parse.Cloud.define(name, async (request) => { });
6
- }
7
- exports.init = init;