@tachybase/plugin-block-map 0.23.8
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/.turbo/turbo-build.log +14 -0
- package/LICENSE +201 -0
- package/README.md +13 -0
- package/README.zh-CN.md +13 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/block/MapActionInitializers.d.ts +2 -0
- package/dist/client/block/MapBlock.Settings.d.ts +2 -0
- package/dist/client/block/MapBlock.d.ts +2 -0
- package/dist/client/block/MapBlockDesigner.d.ts +2 -0
- package/dist/client/block/MapBlockInitializer.d.ts +2 -0
- package/dist/client/block/MapBlockProvider.d.ts +5 -0
- package/dist/client/block/createMapBlockUISchema.d.ts +6 -0
- package/dist/client/block/index.d.ts +2 -0
- package/dist/client/block/utils.d.ts +1 -0
- package/dist/client/components/AMap/Block.d.ts +2 -0
- package/dist/client/components/AMap/Map.d.ts +39 -0
- package/dist/client/components/AMap/Search.d.ts +7 -0
- package/dist/client/components/AMap/index.d.ts +2 -0
- package/dist/client/components/Configuration.d.ts +2 -0
- package/dist/client/components/Designer.d.ts +3 -0
- package/dist/client/components/GoogleMaps/Block.d.ts +2 -0
- package/dist/client/components/GoogleMaps/Map.d.ts +30 -0
- package/dist/client/components/GoogleMaps/Search.d.ts +7 -0
- package/dist/client/components/GoogleMaps/index.d.ts +2 -0
- package/dist/client/components/GoogleMaps/utils.d.ts +5 -0
- package/dist/client/components/Map.d.ts +8 -0
- package/dist/client/components/MapBlock.d.ts +2 -0
- package/dist/client/components/MapComponent.d.ts +2 -0
- package/dist/client/components/ReadPretty.d.ts +3 -0
- package/dist/client/components/index.d.ts +6 -0
- package/dist/client/constants.d.ts +6 -0
- package/dist/client/fields/circle.d.ts +20 -0
- package/dist/client/fields/index.d.ts +2 -0
- package/dist/client/fields/lineString.d.ts +20 -0
- package/dist/client/fields/point.d.ts +20 -0
- package/dist/client/fields/polygon.d.ts +20 -0
- package/dist/client/fields/schema.d.ts +43 -0
- package/dist/client/hooks/index.d.ts +1 -0
- package/dist/client/hooks/useMapConfiguration.d.ts +3 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +98 -0
- package/dist/client/locale/index.d.ts +4 -0
- package/dist/client/types.d.ts +1 -0
- package/dist/client/utils.d.ts +1 -0
- package/dist/externalVersion.js +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +51 -0
- package/dist/locale/ko_KR.json +51 -0
- package/dist/locale/pt-BR.json +45 -0
- package/dist/locale/zh-CN.json +51 -0
- package/dist/server/actions/index.d.ts +3 -0
- package/dist/server/actions/index.js +65 -0
- package/dist/server/collections/mapConfiguration.d.ts +2 -0
- package/dist/server/collections/mapConfiguration.js +51 -0
- package/dist/server/constants.d.ts +1 -0
- package/dist/server/constants.js +27 -0
- package/dist/server/fields/circle.d.ts +12 -0
- package/dist/server/fields/circle.js +67 -0
- package/dist/server/fields/index.d.ts +4 -0
- package/dist/server/fields/index.js +27 -0
- package/dist/server/fields/lineString.d.ts +12 -0
- package/dist/server/fields/lineString.js +74 -0
- package/dist/server/fields/point.d.ts +12 -0
- package/dist/server/fields/point.js +77 -0
- package/dist/server/fields/polygon.d.ts +12 -0
- package/dist/server/fields/polygon.js +73 -0
- package/dist/server/helpers/index.d.ts +6 -0
- package/dist/server/helpers/index.js +56 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/plugin.d.ts +11 -0
- package/dist/server/plugin.js +86 -0
- package/dist/server/value-parsers/index.d.ts +13 -0
- package/dist/server/value-parsers/index.js +77 -0
- package/dist/swagger/index.d.ts +77 -0
- package/dist/swagger/index.js +100 -0
- package/docs/en-US/changelog.md +1 -0
- package/docs/en-US/index.md +1 -0
- package/docs/en-US/installation.md +1 -0
- package/docs/en-US/tabs.json +18 -0
- package/docs/en-US/usage.md +1 -0
- package/docs/zh-CN/changelog.md +1 -0
- package/docs/zh-CN/index.md +1 -0
- package/docs/zh-CN/installation.md +1 -0
- package/docs/zh-CN/tabs.json +18 -0
- package/docs/zh-CN/usage.md +1 -0
- package/package.json +42 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
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 mapConfiguration_exports = {};
|
|
19
|
+
__export(mapConfiguration_exports, {
|
|
20
|
+
default: () => mapConfiguration_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(mapConfiguration_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var import_constants = require("../constants");
|
|
25
|
+
var mapConfiguration_default = (0, import_database.defineCollection)({
|
|
26
|
+
dumpRules: {
|
|
27
|
+
group: "third-party"
|
|
28
|
+
},
|
|
29
|
+
name: import_constants.MapConfigurationCollectionName,
|
|
30
|
+
shared: true,
|
|
31
|
+
fields: [
|
|
32
|
+
{
|
|
33
|
+
title: "Access key",
|
|
34
|
+
comment: "\u8BBF\u95EE\u5BC6\u94A5",
|
|
35
|
+
name: "accessKey",
|
|
36
|
+
type: "string"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: "securityJsCode",
|
|
40
|
+
comment: "securityJsCode or serviceHOST",
|
|
41
|
+
name: "securityJsCode",
|
|
42
|
+
type: "string"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: "Map type",
|
|
46
|
+
comment: "\u5730\u56FE\u7C7B\u578B",
|
|
47
|
+
name: "type",
|
|
48
|
+
type: "string"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MapConfigurationCollectionName = "mapConfiguration";
|
|
@@ -0,0 +1,27 @@
|
|
|
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 constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
MapConfigurationCollectionName: () => MapConfigurationCollectionName
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(constants_exports);
|
|
23
|
+
const MapConfigurationCollectionName = "mapConfiguration";
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
MapConfigurationCollectionName
|
|
27
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseColumnFieldOptions, DataTypes, Field, FieldContext } from '@tachybase/database';
|
|
2
|
+
declare class Circle extends DataTypes.ABSTRACT {
|
|
3
|
+
key: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class CircleField extends Field {
|
|
6
|
+
constructor(options?: any, context?: FieldContext);
|
|
7
|
+
get dataType(): typeof Circle;
|
|
8
|
+
}
|
|
9
|
+
export interface CircleFieldOptions extends BaseColumnFieldOptions {
|
|
10
|
+
type: 'circle';
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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 circle_exports = {};
|
|
19
|
+
__export(circle_exports, {
|
|
20
|
+
CircleField: () => CircleField
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(circle_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var import_helpers = require("../helpers");
|
|
25
|
+
class Circle extends import_database.DataTypes.ABSTRACT {
|
|
26
|
+
key = "Circle";
|
|
27
|
+
}
|
|
28
|
+
class CircleField extends import_database.Field {
|
|
29
|
+
constructor(options, context) {
|
|
30
|
+
const { name } = options;
|
|
31
|
+
super(
|
|
32
|
+
{
|
|
33
|
+
get() {
|
|
34
|
+
const value = this.getDataValue(name);
|
|
35
|
+
if ((0, import_helpers.isPg)(context)) {
|
|
36
|
+
if (typeof value === "string") {
|
|
37
|
+
return (0, import_helpers.toValue)(`(${value})`);
|
|
38
|
+
}
|
|
39
|
+
return value ? [value.x, value.y, value.radius] : null;
|
|
40
|
+
} else {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
set(value) {
|
|
45
|
+
if (!(value == null ? void 0 : value.length)) value = null;
|
|
46
|
+
else if ((0, import_helpers.isPg)(context)) {
|
|
47
|
+
value = value.join(",");
|
|
48
|
+
}
|
|
49
|
+
this.setDataValue(name, value);
|
|
50
|
+
},
|
|
51
|
+
...options
|
|
52
|
+
},
|
|
53
|
+
context
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
get dataType() {
|
|
57
|
+
if ((0, import_helpers.isPg)(this.context)) {
|
|
58
|
+
return Circle;
|
|
59
|
+
} else {
|
|
60
|
+
return import_database.DataTypes.JSON;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
CircleField
|
|
67
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var fields_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(fields_exports);
|
|
17
|
+
__reExport(fields_exports, require("./point"), module.exports);
|
|
18
|
+
__reExport(fields_exports, require("./lineString"), module.exports);
|
|
19
|
+
__reExport(fields_exports, require("./polygon"), module.exports);
|
|
20
|
+
__reExport(fields_exports, require("./circle"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./point"),
|
|
24
|
+
...require("./lineString"),
|
|
25
|
+
...require("./polygon"),
|
|
26
|
+
...require("./circle")
|
|
27
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseColumnFieldOptions, DataTypes, Field, FieldContext } from '@tachybase/database';
|
|
2
|
+
declare class LineString extends DataTypes.ABSTRACT {
|
|
3
|
+
key: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class LineStringField extends Field {
|
|
6
|
+
constructor(options?: any, context?: FieldContext);
|
|
7
|
+
get dataType(): DataTypes.GeometryDataType | typeof LineString;
|
|
8
|
+
}
|
|
9
|
+
export interface LineStringOptions extends BaseColumnFieldOptions {
|
|
10
|
+
type: 'lineString';
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
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 lineString_exports = {};
|
|
19
|
+
__export(lineString_exports, {
|
|
20
|
+
LineStringField: () => LineStringField
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(lineString_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var import_helpers = require("../helpers");
|
|
25
|
+
class LineString extends import_database.DataTypes.ABSTRACT {
|
|
26
|
+
key = "Path";
|
|
27
|
+
}
|
|
28
|
+
class LineStringField extends import_database.Field {
|
|
29
|
+
constructor(options, context) {
|
|
30
|
+
const { name } = options;
|
|
31
|
+
super(
|
|
32
|
+
{
|
|
33
|
+
get() {
|
|
34
|
+
const value = this.getDataValue(name);
|
|
35
|
+
if ((0, import_helpers.isPg)(context)) {
|
|
36
|
+
return (0, import_helpers.toValue)(value);
|
|
37
|
+
} else if ((0, import_helpers.isMysql)(context)) {
|
|
38
|
+
return (value == null ? void 0 : value.coordinates) || null;
|
|
39
|
+
} else {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
set(value) {
|
|
44
|
+
if (!(value == null ? void 0 : value.length)) value = null;
|
|
45
|
+
else if ((0, import_helpers.isPg)(context)) {
|
|
46
|
+
value = (0, import_helpers.joinComma)(value.map(import_helpers.joinComma));
|
|
47
|
+
} else if ((0, import_helpers.isMysql)(context)) {
|
|
48
|
+
value = {
|
|
49
|
+
type: "LineString",
|
|
50
|
+
coordinates: value
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
this.setDataValue(name, value);
|
|
54
|
+
},
|
|
55
|
+
...options
|
|
56
|
+
},
|
|
57
|
+
context
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
get dataType() {
|
|
61
|
+
if ((0, import_helpers.isPg)(this.context)) {
|
|
62
|
+
return LineString;
|
|
63
|
+
}
|
|
64
|
+
if ((0, import_helpers.isMysql)(this.context)) {
|
|
65
|
+
return import_database.DataTypes.GEOMETRY("LINESTRING");
|
|
66
|
+
} else {
|
|
67
|
+
return import_database.DataTypes.JSON;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
LineStringField
|
|
74
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseColumnFieldOptions, DataTypes, Field, FieldContext } from '@tachybase/database';
|
|
2
|
+
declare class Point extends DataTypes.ABSTRACT {
|
|
3
|
+
key: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class PointField extends Field {
|
|
6
|
+
constructor(options?: any, context?: FieldContext);
|
|
7
|
+
get dataType(): typeof Point | DataTypes.GeometryDataType;
|
|
8
|
+
}
|
|
9
|
+
export interface PointFieldOptions extends BaseColumnFieldOptions {
|
|
10
|
+
type: 'point';
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
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 point_exports = {};
|
|
19
|
+
__export(point_exports, {
|
|
20
|
+
PointField: () => PointField
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(point_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var import_helpers = require("../helpers");
|
|
25
|
+
class Point extends import_database.DataTypes.ABSTRACT {
|
|
26
|
+
key = "Point";
|
|
27
|
+
}
|
|
28
|
+
class PointField extends import_database.Field {
|
|
29
|
+
constructor(options, context) {
|
|
30
|
+
const { name } = options;
|
|
31
|
+
super(
|
|
32
|
+
{
|
|
33
|
+
get() {
|
|
34
|
+
const value = this.getDataValue(name);
|
|
35
|
+
if ((0, import_helpers.isPg)(context)) {
|
|
36
|
+
if (typeof value === "string") {
|
|
37
|
+
return (0, import_helpers.toValue)(value);
|
|
38
|
+
}
|
|
39
|
+
return value ? [value.x, value.y] : null;
|
|
40
|
+
} else if ((0, import_helpers.isMysql)(context)) {
|
|
41
|
+
return (value == null ? void 0 : value.coordinates) || null;
|
|
42
|
+
} else {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
set(value) {
|
|
47
|
+
if (!(value == null ? void 0 : value.length)) value = null;
|
|
48
|
+
else if ((0, import_helpers.isPg)(context)) {
|
|
49
|
+
value = (0, import_helpers.joinComma)(value);
|
|
50
|
+
} else if ((0, import_helpers.isMysql)(context)) {
|
|
51
|
+
value = {
|
|
52
|
+
type: "Point",
|
|
53
|
+
coordinates: value
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
this.setDataValue(name, value);
|
|
57
|
+
},
|
|
58
|
+
...options
|
|
59
|
+
},
|
|
60
|
+
context
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
get dataType() {
|
|
64
|
+
if ((0, import_helpers.isPg)(this.context)) {
|
|
65
|
+
return Point;
|
|
66
|
+
}
|
|
67
|
+
if ((0, import_helpers.isMysql)(this.context)) {
|
|
68
|
+
return import_database.DataTypes.GEOMETRY("POINT");
|
|
69
|
+
} else {
|
|
70
|
+
return import_database.DataTypes.JSON;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
PointField
|
|
77
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseColumnFieldOptions, DataTypes, Field, FieldContext } from '@tachybase/database';
|
|
2
|
+
declare class Polygon extends DataTypes.ABSTRACT {
|
|
3
|
+
key: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class PolygonField extends Field {
|
|
6
|
+
constructor(options?: any, context?: FieldContext);
|
|
7
|
+
get dataType(): DataTypes.GeometryDataType | typeof Polygon;
|
|
8
|
+
}
|
|
9
|
+
export interface PolygonFieldOptions extends BaseColumnFieldOptions {
|
|
10
|
+
type: 'polygon';
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
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("@tachybase/database");
|
|
24
|
+
var import_helpers = require("../helpers");
|
|
25
|
+
class Polygon extends import_database.DataTypes.ABSTRACT {
|
|
26
|
+
key = "Polygon";
|
|
27
|
+
}
|
|
28
|
+
class PolygonField extends import_database.Field {
|
|
29
|
+
constructor(options, context) {
|
|
30
|
+
const { name } = options;
|
|
31
|
+
super(
|
|
32
|
+
{
|
|
33
|
+
get() {
|
|
34
|
+
const value = this.getDataValue(name);
|
|
35
|
+
if ((0, import_helpers.isPg)(context)) {
|
|
36
|
+
return (0, import_helpers.toValue)(value);
|
|
37
|
+
} else if ((0, import_helpers.isMysql)(context)) {
|
|
38
|
+
return (value == null ? void 0 : value.coordinates[0].slice(0, -1)) || null;
|
|
39
|
+
} else {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
set(value) {
|
|
44
|
+
if (!(value == null ? void 0 : value.length)) value = null;
|
|
45
|
+
else if ((0, import_helpers.isPg)(context)) {
|
|
46
|
+
value = (0, import_helpers.joinComma)(value.map((item) => (0, import_helpers.joinComma)(item)));
|
|
47
|
+
} else if ((0, import_helpers.isMysql)(context)) {
|
|
48
|
+
value = {
|
|
49
|
+
type: "Polygon",
|
|
50
|
+
coordinates: [value.concat([value[0]])]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
this.setDataValue(name, value);
|
|
54
|
+
},
|
|
55
|
+
...options
|
|
56
|
+
},
|
|
57
|
+
context
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
get dataType() {
|
|
61
|
+
if ((0, import_helpers.isPg)(this.context)) {
|
|
62
|
+
return Polygon;
|
|
63
|
+
} else if ((0, import_helpers.isMysql)(this.context)) {
|
|
64
|
+
return import_database.DataTypes.GEOMETRY("POLYGON");
|
|
65
|
+
} else {
|
|
66
|
+
return import_database.DataTypes.JSON;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
PolygonField
|
|
73
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const joinComma: (value: any[]) => string;
|
|
2
|
+
export declare const toValue: (value?: string) => any;
|
|
3
|
+
export declare const getDialect: (ctx: any) => any;
|
|
4
|
+
export declare const isPg: (ctx: any) => boolean;
|
|
5
|
+
export declare const isSqlite: (ctx: any) => boolean;
|
|
6
|
+
export declare const isMysql: (ctx: any) => boolean;
|
|
@@ -0,0 +1,56 @@
|
|
|
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);
|
|
28
|
+
const joinComma = (value) => {
|
|
29
|
+
if (!value) return null;
|
|
30
|
+
return `(${value.join(",")})`;
|
|
31
|
+
};
|
|
32
|
+
const toValue = (value) => {
|
|
33
|
+
if (!value) return null;
|
|
34
|
+
return JSON.parse(value.replace(/\(/g, "[").replace(/\)/g, "]"));
|
|
35
|
+
};
|
|
36
|
+
const getDialect = (ctx) => {
|
|
37
|
+
return (ctx.db || ctx.database).sequelize.getDialect();
|
|
38
|
+
};
|
|
39
|
+
const isPg = (ctx) => {
|
|
40
|
+
return getDialect(ctx) === "postgres";
|
|
41
|
+
};
|
|
42
|
+
const isSqlite = (ctx) => {
|
|
43
|
+
return getDialect(ctx) === "sqlite";
|
|
44
|
+
};
|
|
45
|
+
const isMysql = (ctx) => {
|
|
46
|
+
return getDialect(ctx) === "mysql";
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
getDialect,
|
|
51
|
+
isMysql,
|
|
52
|
+
isPg,
|
|
53
|
+
isSqlite,
|
|
54
|
+
joinComma,
|
|
55
|
+
toValue
|
|
56
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,33 @@
|
|
|
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"));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstallOptions, Plugin } from '@tachybase/server';
|
|
2
|
+
export declare class MapPlugin extends Plugin {
|
|
3
|
+
afterAdd(): void;
|
|
4
|
+
beforeLoad(): void;
|
|
5
|
+
load(): Promise<void>;
|
|
6
|
+
install(options?: InstallOptions): Promise<void>;
|
|
7
|
+
afterEnable(): Promise<void>;
|
|
8
|
+
afterDisable(): Promise<void>;
|
|
9
|
+
remove(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export default MapPlugin;
|
|
@@ -0,0 +1,86 @@
|
|
|
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 plugin_exports = {};
|
|
29
|
+
__export(plugin_exports, {
|
|
30
|
+
MapPlugin: () => MapPlugin,
|
|
31
|
+
default: () => plugin_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_server = require("@tachybase/server");
|
|
36
|
+
var import_actions = require("./actions");
|
|
37
|
+
var import_fields = require("./fields");
|
|
38
|
+
var import_value_parsers = require("./value-parsers");
|
|
39
|
+
class MapPlugin extends import_server.Plugin {
|
|
40
|
+
afterAdd() {
|
|
41
|
+
}
|
|
42
|
+
beforeLoad() {
|
|
43
|
+
const fields = {
|
|
44
|
+
point: import_fields.PointField,
|
|
45
|
+
polygon: import_fields.PolygonField,
|
|
46
|
+
lineString: import_fields.LineStringField,
|
|
47
|
+
circle: import_fields.CircleField
|
|
48
|
+
};
|
|
49
|
+
this.db.registerFieldTypes(fields);
|
|
50
|
+
this.db.registerFieldValueParsers({
|
|
51
|
+
point: import_value_parsers.PointValueParser,
|
|
52
|
+
polygon: import_value_parsers.PolygonValueParser,
|
|
53
|
+
lineString: import_value_parsers.LineStringValueParser,
|
|
54
|
+
circle: import_value_parsers.CircleValueParser
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async load() {
|
|
58
|
+
await this.importCollections(import_path.default.resolve(__dirname, "collections"));
|
|
59
|
+
this.app.resource({
|
|
60
|
+
name: "map-configuration",
|
|
61
|
+
actions: {
|
|
62
|
+
get: import_actions.getConfiguration,
|
|
63
|
+
set: import_actions.setConfiguration
|
|
64
|
+
},
|
|
65
|
+
only: ["get", "set"]
|
|
66
|
+
});
|
|
67
|
+
this.app.acl.registerSnippet({
|
|
68
|
+
name: `pm.${this.name}.configuration`,
|
|
69
|
+
actions: ["map-configuration:set"]
|
|
70
|
+
});
|
|
71
|
+
this.app.acl.allow("map-configuration", "get", "loggedIn");
|
|
72
|
+
}
|
|
73
|
+
async install(options) {
|
|
74
|
+
}
|
|
75
|
+
async afterEnable() {
|
|
76
|
+
}
|
|
77
|
+
async afterDisable() {
|
|
78
|
+
}
|
|
79
|
+
async remove() {
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
var plugin_default = MapPlugin;
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
MapPlugin
|
|
86
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseValueParser } from '@tachybase/database';
|
|
2
|
+
export declare class PointValueParser extends BaseValueParser {
|
|
3
|
+
setValue(value: any): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export declare class PolygonValueParser extends BaseValueParser {
|
|
6
|
+
setValue(value: any): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class LineStringValueParser extends BaseValueParser {
|
|
9
|
+
setValue(value: any): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare class CircleValueParser extends BaseValueParser {
|
|
12
|
+
setValue(value: any): Promise<void>;
|
|
13
|
+
}
|