@nocobase/plugin-data-visualization 1.3.39-beta → 1.4.0-alpha

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.
Files changed (80) hide show
  1. package/dist/client/block/ChartBlockProvider.d.ts +10 -0
  2. package/dist/client/block/GlobalAutoRefreshProvider.d.ts +19 -0
  3. package/dist/client/block/index.d.ts +2 -0
  4. package/dist/client/chart/chart.d.ts +9 -6
  5. package/dist/client/chart/configs.d.ts +212 -19
  6. package/dist/client/chart/group.d.ts +9 -4
  7. package/dist/client/configure/schemas/configure.d.ts +1 -1
  8. package/dist/client/filter/utils.d.ts +2 -1
  9. package/dist/client/hooks/chart.d.ts +20 -0
  10. package/dist/client/hooks/index.d.ts +1 -0
  11. package/dist/client/index.d.ts +1 -0
  12. package/dist/client/index.js +30 -30
  13. package/dist/client/initializers/BlockRefreshAction.d.ts +14 -0
  14. package/dist/client/initializers/RefreshAction.d.ts +14 -0
  15. package/dist/client/initializers/chartActions.d.ts +10 -0
  16. package/dist/client/initializers/chartBlockActions.d.ts +10 -0
  17. package/dist/client/renderer/ChartRendererDesigner.d.ts +10 -0
  18. package/dist/client/renderer/ChartRendererProvider.d.ts +6 -0
  19. package/dist/client/settings/AutoRefreshItem.d.ts +13 -0
  20. package/dist/client/settings/chartActionRefresh.d.ts +10 -0
  21. package/dist/client/settings/chartBlockActionRefresh.d.ts +10 -0
  22. package/dist/client/utils.d.ts +42 -0
  23. package/dist/externalVersion.js +8 -8
  24. package/dist/locale/en-US.json +15 -14
  25. package/dist/locale/zh-CN.json +10 -9
  26. package/dist/node_modules/koa-compose/package.json +1 -1
  27. package/dist/node_modules/moment-timezone/LICENSE +20 -0
  28. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.js +1548 -0
  29. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.min.js +1 -0
  30. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.js +1548 -0
  31. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.min.js +1 -0
  32. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.js +1560 -0
  33. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.min.js +1 -0
  34. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.js +1548 -0
  35. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.min.js +1 -0
  36. package/dist/node_modules/moment-timezone/builds/moment-timezone.min.js +1 -0
  37. package/dist/node_modules/moment-timezone/composer.json +43 -0
  38. package/dist/node_modules/moment-timezone/data/meta/latest.json +5889 -0
  39. package/dist/node_modules/moment-timezone/data/packed/latest.json +852 -0
  40. package/dist/node_modules/moment-timezone/index.d.ts +78 -0
  41. package/dist/node_modules/moment-timezone/index.js +15 -0
  42. package/dist/node_modules/moment-timezone/moment-timezone-utils.d.ts +70 -0
  43. package/dist/node_modules/moment-timezone/moment-timezone-utils.js +339 -0
  44. package/dist/node_modules/moment-timezone/moment-timezone.js +696 -0
  45. package/dist/node_modules/moment-timezone/package.json +1 -0
  46. package/dist/server/actions/query.d.ts +0 -1
  47. package/dist/server/actions/query.js +11 -75
  48. package/dist/server/formatter/formatter.d.ts +27 -0
  49. package/dist/server/formatter/formatter.js +85 -0
  50. package/dist/server/formatter/mysql-formatter.d.ts +14 -0
  51. package/dist/server/formatter/mysql-formatter.js +86 -0
  52. package/dist/server/formatter/oracle-formatter.d.ts +14 -0
  53. package/dist/server/formatter/oracle-formatter.js +74 -0
  54. package/dist/server/formatter/postgres-formatter.d.ts +14 -0
  55. package/dist/server/formatter/postgres-formatter.js +74 -0
  56. package/dist/server/formatter/sqlite-formatter.d.ts +15 -0
  57. package/dist/server/formatter/sqlite-formatter.js +83 -0
  58. package/dist/server/migrations/20240921214400-rename-charttype.d.ts +14 -0
  59. package/dist/server/migrations/20240921214400-rename-charttype.js +64 -0
  60. package/dist/server/plugin.js +1 -1
  61. package/dist/server/query-parser/index.d.ts +11 -0
  62. package/dist/server/query-parser/index.js +56 -0
  63. package/dist/server/query-parser/mysql-query-parser.d.ts +15 -0
  64. package/dist/server/query-parser/mysql-query-parser.js +43 -0
  65. package/dist/server/query-parser/oracle-query-parser.d.ts +18 -0
  66. package/dist/server/query-parser/oracle-query-parser.js +60 -0
  67. package/dist/server/query-parser/postgres-query-parser.d.ts +15 -0
  68. package/dist/server/query-parser/postgres-query-parser.js +43 -0
  69. package/dist/server/query-parser/query-parser.d.ts +31 -0
  70. package/dist/server/query-parser/query-parser.js +134 -0
  71. package/dist/server/query-parser/sqlite-query-parser.d.ts +15 -0
  72. package/dist/server/query-parser/sqlite-query-parser.js +43 -0
  73. package/dist/server/types.d.ts +46 -0
  74. package/dist/server/types.js +24 -0
  75. package/package.json +2 -2
  76. package/dist/client/chart/g2plot/configs.d.ts +0 -122
  77. package/dist/server/actions/formatter.d.ts +0 -12
  78. package/dist/server/actions/formatter.js +0 -101
  79. /package/dist/locale/{ja_JP.json → ja-JP.json} +0 -0
  80. /package/dist/locale/{ko_KR.json → ko-KR.json} +0 -0
@@ -0,0 +1,64 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var rename_charttype_exports = {};
28
+ __export(rename_charttype_exports, {
29
+ default: () => rename_charttype_default
30
+ });
31
+ module.exports = __toCommonJS(rename_charttype_exports);
32
+ var import_server = require("@nocobase/server");
33
+ class rename_charttype_default extends import_server.Migration {
34
+ on = "afterLoad";
35
+ // 'beforeLoad' or 'afterLoad'
36
+ appVersion = "<=1.5.0-beta";
37
+ async up() {
38
+ const r = this.db.getRepository("uiSchemas");
39
+ const items = await r.find({
40
+ filter: {
41
+ "schema.x-decorator": "ChartRendererProvider"
42
+ }
43
+ });
44
+ await this.db.sequelize.transaction(async (transaction) => {
45
+ var _a, _b;
46
+ for (const item of items) {
47
+ const schema = item.schema;
48
+ const chartType = (_b = (_a = schema["x-decorator-props"]) == null ? void 0 : _a.config) == null ? void 0 : _b.chartType;
49
+ if (!chartType) {
50
+ continue;
51
+ }
52
+ if (chartType.startsWith("Built-in.")) {
53
+ if (chartType === "Built-in.statistic" || chartType === "Built-in.table") {
54
+ schema["x-decorator-props"].config.chartType = chartType.replace("Built-in", "antd");
55
+ } else {
56
+ schema["x-decorator-props"].config.chartType = chartType.replace("Built-in", "ant-design-charts");
57
+ }
58
+ item.set("schema", schema);
59
+ await item.save({ transaction });
60
+ }
61
+ }
62
+ });
63
+ }
64
+ }
@@ -37,7 +37,7 @@ class PluginDataVisualizationServer extends import_server.Plugin {
37
37
  afterAdd() {
38
38
  }
39
39
  beforeLoad() {
40
- this.app.resource({
40
+ this.app.resourceManager.define({
41
41
  name: "charts",
42
42
  actions: {
43
43
  query: import_query.query
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Database } from '@nocobase/database';
10
+ import { QueryParser } from './query-parser';
11
+ export declare const createQueryParser: (db: Database) => QueryParser;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var query_parser_exports = {};
28
+ __export(query_parser_exports, {
29
+ createQueryParser: () => createQueryParser
30
+ });
31
+ module.exports = __toCommonJS(query_parser_exports);
32
+ var import_sqlite_query_parser = require("./sqlite-query-parser");
33
+ var import_postgres_query_parser = require("./postgres-query-parser");
34
+ var import_mysql_query_parser = require("./mysql-query-parser");
35
+ var import_query_parser = require("./query-parser");
36
+ var import_oracle_query_parser = require("./oracle-query-parser");
37
+ const createQueryParser = (db) => {
38
+ const dialect = db.sequelize.getDialect();
39
+ switch (dialect) {
40
+ case "sqlite":
41
+ return new import_sqlite_query_parser.SQLiteQueryParser(db);
42
+ case "postgres":
43
+ return new import_postgres_query_parser.PostgresQueryParser(db);
44
+ case "mysql":
45
+ case "mariadb":
46
+ return new import_mysql_query_parser.MySQLQueryParser(db);
47
+ case "oracle":
48
+ return new import_oracle_query_parser.OracleQueryParser(db);
49
+ default:
50
+ return new import_query_parser.QueryParser(db);
51
+ }
52
+ };
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ createQueryParser
56
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Database } from '@nocobase/database';
10
+ import { MySQLFormatter } from '../formatter/mysql-formatter';
11
+ import { QueryParser } from './query-parser';
12
+ export declare class MySQLQueryParser extends QueryParser {
13
+ formatter: MySQLFormatter;
14
+ constructor(db: Database);
15
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var mysql_query_parser_exports = {};
28
+ __export(mysql_query_parser_exports, {
29
+ MySQLQueryParser: () => MySQLQueryParser
30
+ });
31
+ module.exports = __toCommonJS(mysql_query_parser_exports);
32
+ var import_mysql_formatter = require("../formatter/mysql-formatter");
33
+ var import_query_parser = require("./query-parser");
34
+ class MySQLQueryParser extends import_query_parser.QueryParser {
35
+ constructor(db) {
36
+ super(db);
37
+ this.formatter = new import_mysql_formatter.MySQLFormatter(db.sequelize);
38
+ }
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ MySQLQueryParser
43
+ });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { QueryParser } from './query-parser';
10
+ import { OrderProps } from '../types';
11
+ import { Context } from '@nocobase/actions';
12
+ import { OracleFormatter } from '../formatter/oracle-formatter';
13
+ import { Database } from '@nocobase/database';
14
+ export declare class OracleQueryParser extends QueryParser {
15
+ formatter: OracleFormatter;
16
+ constructor(db: Database);
17
+ parseOrders(ctx: Context, orders: OrderProps[], hasAgg: boolean): any[];
18
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var oracle_query_parser_exports = {};
28
+ __export(oracle_query_parser_exports, {
29
+ OracleQueryParser: () => OracleQueryParser
30
+ });
31
+ module.exports = __toCommonJS(oracle_query_parser_exports);
32
+ var import_query_parser = require("./query-parser");
33
+ var import_oracle_formatter = require("../formatter/oracle-formatter");
34
+ class OracleQueryParser extends import_query_parser.QueryParser {
35
+ constructor(db) {
36
+ super(db);
37
+ this.formatter = new import_oracle_formatter.OracleFormatter(db.sequelize);
38
+ }
39
+ parseOrders(ctx, orders, hasAgg) {
40
+ const { collection: collectionName, dimensions } = ctx.action.params.values;
41
+ const collection = this.db.getCollection(collectionName);
42
+ if (!orders.length) {
43
+ if (dimensions.length) {
44
+ orders.push(dimensions[0]);
45
+ } else {
46
+ let filterTks = collection.filterTargetKey;
47
+ if (!Array.isArray(filterTks)) {
48
+ filterTks = [filterTks];
49
+ }
50
+ orders.push(...filterTks.map((field) => ({ field, alias: field })));
51
+ }
52
+ }
53
+ const order = super.parseOrders(ctx, orders, hasAgg);
54
+ return order;
55
+ }
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ OracleQueryParser
60
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Database } from '@nocobase/database';
10
+ import { PostgresFormatter } from '../formatter/postgres-formatter';
11
+ import { QueryParser } from './query-parser';
12
+ export declare class PostgresQueryParser extends QueryParser {
13
+ formatter: PostgresFormatter;
14
+ constructor(db: Database);
15
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var postgres_query_parser_exports = {};
28
+ __export(postgres_query_parser_exports, {
29
+ PostgresQueryParser: () => PostgresQueryParser
30
+ });
31
+ module.exports = __toCommonJS(postgres_query_parser_exports);
32
+ var import_postgres_formatter = require("../formatter/postgres-formatter");
33
+ var import_query_parser = require("./query-parser");
34
+ class PostgresQueryParser extends import_query_parser.QueryParser {
35
+ constructor(db) {
36
+ super(db);
37
+ this.formatter = new import_postgres_formatter.PostgresFormatter(db.sequelize);
38
+ }
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ PostgresQueryParser
43
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Context, Next } from '@nocobase/actions';
10
+ import { DimensionProps, MeasureProps, OrderProps } from '../types';
11
+ import { Formatter } from '../formatter/formatter';
12
+ import { Database } from '@nocobase/database';
13
+ export declare class QueryParser {
14
+ db: Database;
15
+ formatter: Formatter;
16
+ constructor(db: Database);
17
+ parseMeasures(ctx: Context, measures: MeasureProps[]): {
18
+ attributes: any[];
19
+ fieldMap: {};
20
+ hasAgg: boolean;
21
+ };
22
+ parseDimensions(ctx: Context, dimensions: (DimensionProps & {
23
+ field: string;
24
+ })[], hasAgg: boolean, timezone: string): {
25
+ attributes: any[];
26
+ group: any[];
27
+ fieldMap: {};
28
+ };
29
+ parseOrders(ctx: Context, orders: OrderProps[], hasAgg: boolean): any[];
30
+ parse(): (ctx: Context, next: Next) => Promise<void>;
31
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var query_parser_exports = {};
28
+ __export(query_parser_exports, {
29
+ QueryParser: () => QueryParser
30
+ });
31
+ module.exports = __toCommonJS(query_parser_exports);
32
+ const AllowedAggFuncs = ["sum", "count", "avg", "min", "max"];
33
+ class QueryParser {
34
+ db;
35
+ formatter;
36
+ constructor(db) {
37
+ this.db = db;
38
+ this.formatter = {
39
+ format: ({ field }) => db.sequelize.col(field)
40
+ };
41
+ }
42
+ parseMeasures(ctx, measures) {
43
+ let hasAgg = false;
44
+ const sequelize = this.db.sequelize;
45
+ const attributes = [];
46
+ const fieldMap = {};
47
+ measures.forEach((measure) => {
48
+ const { field, aggregation, alias, distinct } = measure;
49
+ const attribute = [];
50
+ const col = sequelize.col(field);
51
+ if (aggregation) {
52
+ if (!AllowedAggFuncs.includes(aggregation)) {
53
+ throw new Error(`Invalid aggregation function: ${aggregation}`);
54
+ }
55
+ hasAgg = true;
56
+ attribute.push(sequelize.fn(aggregation, distinct ? sequelize.fn("DISTINCT", col) : col));
57
+ } else {
58
+ attribute.push(col);
59
+ }
60
+ if (alias) {
61
+ attribute.push(alias);
62
+ }
63
+ attributes.push(attribute.length > 1 ? attribute : attribute[0]);
64
+ fieldMap[alias || field] = measure;
65
+ });
66
+ return { attributes, fieldMap, hasAgg };
67
+ }
68
+ parseDimensions(ctx, dimensions, hasAgg, timezone) {
69
+ const sequelize = this.db.sequelize;
70
+ const attributes = [];
71
+ const group = [];
72
+ const fieldMap = {};
73
+ dimensions.forEach((dimension) => {
74
+ const { field, format, alias, type, options } = dimension;
75
+ const attribute = [];
76
+ const col = sequelize.col(field);
77
+ if (format) {
78
+ attribute.push(this.formatter.format({ type, field, format, timezone, options }));
79
+ } else {
80
+ attribute.push(col);
81
+ }
82
+ if (alias) {
83
+ attribute.push(alias);
84
+ }
85
+ attributes.push(attribute.length > 1 ? attribute : attribute[0]);
86
+ if (hasAgg) {
87
+ group.push(attribute[0]);
88
+ }
89
+ fieldMap[alias || field] = dimension;
90
+ });
91
+ return { attributes, group, fieldMap };
92
+ }
93
+ parseOrders(ctx, orders, hasAgg) {
94
+ const sequelize = this.db.sequelize;
95
+ const order = [];
96
+ orders.forEach((item) => {
97
+ const alias = sequelize.getQueryInterface().quoteIdentifier(item.alias);
98
+ const name = hasAgg ? sequelize.literal(alias) : sequelize.col(item.field);
99
+ order.push([name, item.order || "ASC"]);
100
+ });
101
+ return order;
102
+ }
103
+ parse() {
104
+ return async (ctx, next) => {
105
+ const { measures, dimensions, orders, include, where, limit } = ctx.action.params.values;
106
+ const { attributes: measureAttributes, fieldMap: measureFieldMap, hasAgg } = this.parseMeasures(ctx, measures);
107
+ const {
108
+ attributes: dimensionAttributes,
109
+ group,
110
+ fieldMap: dimensionFieldMap
111
+ } = this.parseDimensions(ctx, dimensions, hasAgg, ctx.timezone);
112
+ const order = this.parseOrders(ctx, orders, hasAgg);
113
+ ctx.action.params.values = {
114
+ ...ctx.action.params.values,
115
+ queryParams: {
116
+ where,
117
+ attributes: [...measureAttributes, ...dimensionAttributes],
118
+ include,
119
+ group,
120
+ order,
121
+ limit: limit || 2e3,
122
+ subQuery: false,
123
+ raw: true
124
+ },
125
+ fieldMap: { ...measureFieldMap, ...dimensionFieldMap }
126
+ };
127
+ await next();
128
+ };
129
+ }
130
+ }
131
+ // Annotate the CommonJS export names for ESM import in node:
132
+ 0 && (module.exports = {
133
+ QueryParser
134
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Database } from '@nocobase/database';
10
+ import { SQLiteFormatter } from '../formatter/sqlite-formatter';
11
+ import { QueryParser } from './query-parser';
12
+ export declare class SQLiteQueryParser extends QueryParser {
13
+ formatter: SQLiteFormatter;
14
+ constructor(db: Database);
15
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var sqlite_query_parser_exports = {};
28
+ __export(sqlite_query_parser_exports, {
29
+ SQLiteQueryParser: () => SQLiteQueryParser
30
+ });
31
+ module.exports = __toCommonJS(sqlite_query_parser_exports);
32
+ var import_sqlite_formatter = require("../formatter/sqlite-formatter");
33
+ var import_query_parser = require("./query-parser");
34
+ class SQLiteQueryParser extends import_query_parser.QueryParser {
35
+ constructor(db) {
36
+ super(db);
37
+ this.formatter = new import_sqlite_formatter.SQLiteFormatter(db.sequelize);
38
+ }
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ SQLiteQueryParser
43
+ });
@@ -0,0 +1,46 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export type MeasureProps = {
10
+ field: string | string[];
11
+ type?: string;
12
+ aggregation?: string;
13
+ alias?: string;
14
+ distinct?: boolean;
15
+ };
16
+ export type DimensionProps = {
17
+ field: string | string[];
18
+ type?: string;
19
+ alias?: string;
20
+ format?: string;
21
+ options?: any;
22
+ };
23
+ export type OrderProps = {
24
+ field: string | string[];
25
+ alias?: string;
26
+ order?: 'asc' | 'desc';
27
+ };
28
+ export type QueryParams = Partial<{
29
+ uid: string;
30
+ dataSource: string;
31
+ collection: string;
32
+ measures: MeasureProps[];
33
+ dimensions: DimensionProps[];
34
+ orders: OrderProps[];
35
+ filter: any;
36
+ limit: number;
37
+ sql: {
38
+ fields?: string;
39
+ clauses?: string;
40
+ };
41
+ cache: {
42
+ enabled: boolean;
43
+ ttl: number;
44
+ };
45
+ refresh: boolean;
46
+ }>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var types_exports = {};
24
+ module.exports = __toCommonJS(types_exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-visualization",
3
- "version": "1.3.39-beta",
3
+ "version": "1.4.0-alpha",
4
4
  "displayName": "Data visualization",
5
5
  "displayName.zh-CN": "数据可视化",
6
6
  "description": "Provides data visualization feature, including chart block and chart filter block, support line charts, area charts, bar charts and more than a dozen kinds of charts, you can also extend more chart types.",
@@ -34,7 +34,7 @@
34
34
  "@nocobase/test": "1.x",
35
35
  "@nocobase/utils": "1.x"
36
36
  },
37
- "gitHead": "68daadf8575cddf9eeb09a1a672f9baf7aabe67a",
37
+ "gitHead": "f097a2bddec152522b5645bd5d451f4c866d2060",
38
38
  "keywords": [
39
39
  "Blocks"
40
40
  ]