@nocobase/plugin-data-visualization 2.1.0-alpha.13 → 2.1.0-alpha.15

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 (54) hide show
  1. package/dist/client/flow/models/ChartBlockModel.d.ts +1 -0
  2. package/dist/client/flow/models/ChartOptionsBuilder.d.ts +4 -0
  3. package/dist/client/flow/models/QueryBuilder.d.ts +1 -4
  4. package/dist/client/flow/resources/ChartResource.d.ts +1 -0
  5. package/dist/client/index.js +1 -1
  6. package/dist/externalVersion.js +12 -11
  7. package/dist/node_modules/koa-compose/package.json +1 -1
  8. package/dist/server/actions/query.d.ts +2 -4
  9. package/dist/server/actions/query.js +47 -210
  10. package/dist/server/plugin.js +2 -2
  11. package/dist/server/types.d.ts +3 -0
  12. package/package.json +4 -2
  13. package/dist/client/flow/components/AntdFilterSelector.d.ts +0 -35
  14. package/dist/node_modules/moment-timezone/LICENSE +0 -20
  15. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.js +0 -1548
  16. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.min.js +0 -1
  17. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.js +0 -1548
  18. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.min.js +0 -1
  19. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.js +0 -1560
  20. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.min.js +0 -1
  21. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.js +0 -1548
  22. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.min.js +0 -1
  23. package/dist/node_modules/moment-timezone/builds/moment-timezone.min.js +0 -1
  24. package/dist/node_modules/moment-timezone/composer.json +0 -43
  25. package/dist/node_modules/moment-timezone/data/meta/latest.json +0 -5889
  26. package/dist/node_modules/moment-timezone/data/packed/latest.json +0 -852
  27. package/dist/node_modules/moment-timezone/index.d.ts +0 -78
  28. package/dist/node_modules/moment-timezone/index.js +0 -15
  29. package/dist/node_modules/moment-timezone/moment-timezone-utils.d.ts +0 -70
  30. package/dist/node_modules/moment-timezone/moment-timezone-utils.js +0 -339
  31. package/dist/node_modules/moment-timezone/moment-timezone.js +0 -696
  32. package/dist/node_modules/moment-timezone/package.json +0 -1
  33. package/dist/server/formatter/formatter.d.ts +0 -27
  34. package/dist/server/formatter/formatter.js +0 -85
  35. package/dist/server/formatter/mysql-formatter.d.ts +0 -14
  36. package/dist/server/formatter/mysql-formatter.js +0 -93
  37. package/dist/server/formatter/oracle-formatter.d.ts +0 -14
  38. package/dist/server/formatter/oracle-formatter.js +0 -74
  39. package/dist/server/formatter/postgres-formatter.d.ts +0 -14
  40. package/dist/server/formatter/postgres-formatter.js +0 -74
  41. package/dist/server/formatter/sqlite-formatter.d.ts +0 -15
  42. package/dist/server/formatter/sqlite-formatter.js +0 -83
  43. package/dist/server/query-parser/index.d.ts +0 -11
  44. package/dist/server/query-parser/index.js +0 -56
  45. package/dist/server/query-parser/mysql-query-parser.d.ts +0 -15
  46. package/dist/server/query-parser/mysql-query-parser.js +0 -43
  47. package/dist/server/query-parser/oracle-query-parser.d.ts +0 -18
  48. package/dist/server/query-parser/oracle-query-parser.js +0 -60
  49. package/dist/server/query-parser/postgres-query-parser.d.ts +0 -15
  50. package/dist/server/query-parser/postgres-query-parser.js +0 -43
  51. package/dist/server/query-parser/query-parser.d.ts +0 -31
  52. package/dist/server/query-parser/query-parser.js +0 -146
  53. package/dist/server/query-parser/sqlite-query-parser.d.ts +0 -15
  54. package/dist/server/query-parser/sqlite-query-parser.js +0 -43
@@ -1,60 +0,0 @@
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
- });
@@ -1,15 +0,0 @@
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
- }
@@ -1,43 +0,0 @@
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
- });
@@ -1,31 +0,0 @@
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
- }
@@ -1,146 +0,0 @@
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
- let sort = item.order || "ASC";
100
- if (item.nulls === "first") {
101
- sort += " NULLS FIRST";
102
- }
103
- if (item.nulls === "last") {
104
- sort += " NULLS LAST";
105
- }
106
- order.push([name, sort]);
107
- });
108
- return order;
109
- }
110
- parse() {
111
- return async (ctx, next) => {
112
- var _a;
113
- const { measures, dimensions, orders, include, where, limit, offset } = ctx.action.params.values;
114
- const { attributes: measureAttributes, fieldMap: measureFieldMap, hasAgg } = this.parseMeasures(ctx, measures);
115
- const {
116
- attributes: dimensionAttributes,
117
- group,
118
- fieldMap: dimensionFieldMap
119
- } = this.parseDimensions(ctx, dimensions, hasAgg, (_a = ctx.get) == null ? void 0 : _a.call(ctx, "x-timezone"));
120
- const order = this.parseOrders(ctx, orders, hasAgg);
121
- const queryParams = {
122
- where,
123
- attributes: [...dimensionAttributes, ...measureAttributes],
124
- include,
125
- group,
126
- order,
127
- subQuery: false,
128
- raw: true
129
- };
130
- if (!hasAgg || dimensions.length) {
131
- queryParams["limit"] = limit || 2e3;
132
- queryParams["offset"] = offset || 0;
133
- }
134
- ctx.action.params.values = {
135
- ...ctx.action.params.values,
136
- queryParams,
137
- fieldMap: { ...measureFieldMap, ...dimensionFieldMap }
138
- };
139
- await next();
140
- };
141
- }
142
- }
143
- // Annotate the CommonJS export names for ESM import in node:
144
- 0 && (module.exports = {
145
- QueryParser
146
- });
@@ -1,15 +0,0 @@
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
- }
@@ -1,43 +0,0 @@
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
- });