@nocobase/plugin-map 0.13.0-alpha.4 → 0.13.0-alpha.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/dist/client/index.js +33 -3072
- package/dist/index.js +37 -16
- package/dist/locale/en-US.js +22 -4
- package/dist/locale/fr-FR.js +22 -4
- package/dist/locale/pt-BR.js +22 -4
- package/dist/locale/zh-CN.js +22 -4
- package/dist/server/actions/index.js +31 -9
- package/dist/server/collections/mapConfiguration.js +24 -7
- package/dist/server/constants.js +26 -4
- package/dist/server/fields/circle.js +35 -14
- package/dist/server/fields/index.js +26 -32
- package/dist/server/fields/lineString.js +40 -19
- package/dist/server/fields/point.js +40 -19
- package/dist/server/fields/polygon.js +40 -19
- package/dist/server/helpers/index.js +36 -9
- package/dist/server/index.js +33 -11
- package/dist/server/plugin.js +46 -27
- package/dist/server/value-parsers/index.js +37 -13
- package/dist/swagger/index.js +22 -4
- package/package.json +2 -2
|
@@ -1,21 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var polygon_exports = {};
|
|
19
|
+
__export(polygon_exports, {
|
|
20
|
+
PolygonField: () => PolygonField
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(polygon_exports);
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var import_helpers = require("../helpers");
|
|
25
|
+
class Polygon extends import_database.DataTypes.ABSTRACT {
|
|
7
26
|
key = "Polygon";
|
|
8
27
|
}
|
|
9
|
-
class PolygonField extends
|
|
28
|
+
class PolygonField extends import_database.Field {
|
|
10
29
|
constructor(options, context) {
|
|
11
30
|
const { name } = options;
|
|
12
31
|
super(
|
|
13
32
|
{
|
|
14
33
|
get() {
|
|
15
34
|
const value = this.getDataValue(name);
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
18
|
-
} else if (
|
|
35
|
+
if ((0, import_helpers.isPg)(context)) {
|
|
36
|
+
return (0, import_helpers.toValue)(value);
|
|
37
|
+
} else if ((0, import_helpers.isMysql)(context)) {
|
|
19
38
|
return (value == null ? void 0 : value.coordinates[0].slice(0, -1)) || null;
|
|
20
39
|
} else {
|
|
21
40
|
return value;
|
|
@@ -24,9 +43,9 @@ class PolygonField extends database.Field {
|
|
|
24
43
|
set(value) {
|
|
25
44
|
if (!(value == null ? void 0 : value.length))
|
|
26
45
|
value = null;
|
|
27
|
-
else if (
|
|
28
|
-
value =
|
|
29
|
-
} else if (
|
|
46
|
+
else if ((0, import_helpers.isPg)(context)) {
|
|
47
|
+
value = (0, import_helpers.joinComma)(value.map((item) => (0, import_helpers.joinComma)(item)));
|
|
48
|
+
} else if ((0, import_helpers.isMysql)(context)) {
|
|
30
49
|
value = {
|
|
31
50
|
type: "Polygon",
|
|
32
51
|
coordinates: [value.concat([value[0]])]
|
|
@@ -40,14 +59,16 @@ class PolygonField extends database.Field {
|
|
|
40
59
|
);
|
|
41
60
|
}
|
|
42
61
|
get dataType() {
|
|
43
|
-
if (
|
|
62
|
+
if ((0, import_helpers.isPg)(this.context)) {
|
|
44
63
|
return Polygon;
|
|
45
|
-
} else if (
|
|
46
|
-
return
|
|
64
|
+
} else if ((0, import_helpers.isMysql)(this.context)) {
|
|
65
|
+
return import_database.DataTypes.GEOMETRY("POLYGON");
|
|
47
66
|
} else {
|
|
48
|
-
return
|
|
67
|
+
return import_database.DataTypes.JSON;
|
|
49
68
|
}
|
|
50
69
|
}
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
exports
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
PolygonField
|
|
74
|
+
});
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var helpers_exports = {};
|
|
19
|
+
__export(helpers_exports, {
|
|
20
|
+
getDialect: () => getDialect,
|
|
21
|
+
isMysql: () => isMysql,
|
|
22
|
+
isPg: () => isPg,
|
|
23
|
+
isSqlite: () => isSqlite,
|
|
24
|
+
joinComma: () => joinComma,
|
|
25
|
+
toValue: () => toValue
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(helpers_exports);
|
|
3
28
|
const joinComma = (value) => {
|
|
4
29
|
if (!value)
|
|
5
30
|
return null;
|
|
@@ -22,10 +47,12 @@ const isSqlite = (ctx) => {
|
|
|
22
47
|
const isMysql = (ctx) => {
|
|
23
48
|
return getDialect(ctx) === "mysql";
|
|
24
49
|
};
|
|
25
|
-
|
|
26
|
-
exports
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
getDialect,
|
|
53
|
+
isMysql,
|
|
54
|
+
isPg,
|
|
55
|
+
isSqlite,
|
|
56
|
+
joinComma,
|
|
57
|
+
toValue
|
|
58
|
+
});
|
package/dist/server/index.js
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var server_exports = {};
|
|
29
|
+
__export(server_exports, {
|
|
30
|
+
default: () => import_plugin.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(server_exports);
|
|
33
|
+
var import_plugin = __toESM(require("./plugin"));
|
package/dist/server/plugin.js
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var plugin_exports = {};
|
|
19
|
+
__export(plugin_exports, {
|
|
20
|
+
MapPlugin: () => MapPlugin,
|
|
21
|
+
default: () => plugin_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
24
|
+
var import_server = require("@nocobase/server");
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_actions = require("./actions");
|
|
27
|
+
var import_fields = require("./fields");
|
|
28
|
+
var import_value_parsers = require("./value-parsers");
|
|
29
|
+
class MapPlugin extends import_server.Plugin {
|
|
12
30
|
afterAdd() {
|
|
13
31
|
}
|
|
14
32
|
beforeLoad() {
|
|
15
|
-
const fields
|
|
16
|
-
point:
|
|
17
|
-
polygon:
|
|
18
|
-
lineString:
|
|
19
|
-
circle:
|
|
33
|
+
const fields = {
|
|
34
|
+
point: import_fields.PointField,
|
|
35
|
+
polygon: import_fields.PolygonField,
|
|
36
|
+
lineString: import_fields.LineStringField,
|
|
37
|
+
circle: import_fields.CircleField
|
|
20
38
|
};
|
|
21
|
-
this.db.registerFieldTypes(fields
|
|
39
|
+
this.db.registerFieldTypes(fields);
|
|
22
40
|
this.db.registerFieldValueParsers({
|
|
23
|
-
point:
|
|
24
|
-
polygon:
|
|
25
|
-
lineString:
|
|
26
|
-
circle:
|
|
41
|
+
point: import_value_parsers.PointValueParser,
|
|
42
|
+
polygon: import_value_parsers.PolygonValueParser,
|
|
43
|
+
lineString: import_value_parsers.LineStringValueParser,
|
|
44
|
+
circle: import_value_parsers.CircleValueParser
|
|
27
45
|
});
|
|
28
46
|
}
|
|
29
47
|
async load() {
|
|
30
48
|
await this.db.import({
|
|
31
|
-
directory:
|
|
49
|
+
directory: (0, import_path.resolve)(__dirname, "collections")
|
|
32
50
|
});
|
|
33
51
|
this.app.resource({
|
|
34
52
|
name: "map-configuration",
|
|
35
53
|
actions: {
|
|
36
|
-
get:
|
|
37
|
-
set:
|
|
54
|
+
get: import_actions.getConfiguration,
|
|
55
|
+
set: import_actions.setConfiguration
|
|
38
56
|
},
|
|
39
57
|
only: ["get", "set"]
|
|
40
58
|
});
|
|
@@ -54,6 +72,7 @@ class MapPlugin extends server.Plugin {
|
|
|
54
72
|
}
|
|
55
73
|
}
|
|
56
74
|
var plugin_default = MapPlugin;
|
|
57
|
-
|
|
58
|
-
exports
|
|
59
|
-
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
MapPlugin
|
|
78
|
+
});
|
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var value_parsers_exports = {};
|
|
19
|
+
__export(value_parsers_exports, {
|
|
20
|
+
CircleValueParser: () => CircleValueParser,
|
|
21
|
+
LineStringValueParser: () => LineStringValueParser,
|
|
22
|
+
PointValueParser: () => PointValueParser,
|
|
23
|
+
PolygonValueParser: () => PolygonValueParser
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(value_parsers_exports);
|
|
26
|
+
var import_database = require("@nocobase/database");
|
|
27
|
+
class PointValueParser extends import_database.BaseValueParser {
|
|
6
28
|
async setValue(value) {
|
|
7
29
|
if (Array.isArray(value)) {
|
|
8
30
|
this.value = value;
|
|
@@ -13,7 +35,7 @@ class PointValueParser extends database.BaseValueParser {
|
|
|
13
35
|
}
|
|
14
36
|
}
|
|
15
37
|
}
|
|
16
|
-
class PolygonValueParser extends
|
|
38
|
+
class PolygonValueParser extends import_database.BaseValueParser {
|
|
17
39
|
async setValue(value) {
|
|
18
40
|
if (Array.isArray(value)) {
|
|
19
41
|
this.value = value;
|
|
@@ -24,7 +46,7 @@ class PolygonValueParser extends database.BaseValueParser {
|
|
|
24
46
|
}
|
|
25
47
|
}
|
|
26
48
|
}
|
|
27
|
-
class LineStringValueParser extends
|
|
49
|
+
class LineStringValueParser extends import_database.BaseValueParser {
|
|
28
50
|
async setValue(value) {
|
|
29
51
|
if (Array.isArray(value)) {
|
|
30
52
|
this.value = value;
|
|
@@ -35,7 +57,7 @@ class LineStringValueParser extends database.BaseValueParser {
|
|
|
35
57
|
}
|
|
36
58
|
}
|
|
37
59
|
}
|
|
38
|
-
class CircleValueParser extends
|
|
60
|
+
class CircleValueParser extends import_database.BaseValueParser {
|
|
39
61
|
async setValue(value) {
|
|
40
62
|
if (Array.isArray(value)) {
|
|
41
63
|
this.value = value;
|
|
@@ -46,8 +68,10 @@ class CircleValueParser extends database.BaseValueParser {
|
|
|
46
68
|
}
|
|
47
69
|
}
|
|
48
70
|
}
|
|
49
|
-
|
|
50
|
-
exports
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
CircleValueParser,
|
|
74
|
+
LineStringValueParser,
|
|
75
|
+
PointValueParser,
|
|
76
|
+
PolygonValueParser
|
|
77
|
+
});
|
package/dist/swagger/index.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var swagger_exports = {};
|
|
19
|
+
__export(swagger_exports, {
|
|
20
|
+
default: () => swagger_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(swagger_exports);
|
|
3
23
|
var swagger_default = {
|
|
4
24
|
info: {
|
|
5
25
|
title: "NocoBase API - Map plugin"
|
|
@@ -78,5 +98,3 @@ var swagger_default = {
|
|
|
78
98
|
}
|
|
79
99
|
}
|
|
80
100
|
};
|
|
81
|
-
|
|
82
|
-
module.exports = swagger_default;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-map",
|
|
3
3
|
"displayName": "Map",
|
|
4
4
|
"displayName.zh-CN": "地图",
|
|
5
|
-
"version": "0.13.0-alpha.
|
|
5
|
+
"version": "0.13.0-alpha.6",
|
|
6
6
|
"description": "Provide map fields and blocks",
|
|
7
7
|
"description.zh-CN": "提供地图字段和区块",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"@nocobase/test": "0.x",
|
|
35
35
|
"@nocobase/utils": "0.x"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "49ef71c8bdaab986f47c8a84bcf15e2123ba9b59"
|
|
38
38
|
}
|