@nocobase/plugin-data-visualization 2.1.0-alpha.12 → 2.1.0-alpha.14
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/flow/models/ChartBlockModel.d.ts +1 -0
- package/dist/client/flow/models/ChartOptionsBuilder.d.ts +4 -0
- package/dist/client/flow/models/QueryBuilder.d.ts +1 -4
- package/dist/client/flow/resources/ChartResource.d.ts +1 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +12 -11
- package/dist/node_modules/koa-compose/package.json +1 -1
- package/dist/server/actions/query.d.ts +2 -4
- package/dist/server/actions/query.js +48 -183
- package/dist/server/plugin.d.ts +0 -2
- package/dist/server/plugin.js +2 -6
- package/dist/server/types.d.ts +3 -0
- package/package.json +4 -2
- package/dist/client/flow/components/AntdFilterSelector.d.ts +0 -35
- package/dist/node_modules/moment-timezone/LICENSE +0 -20
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.js +0 -1548
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.min.js +0 -1
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.js +0 -1548
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.min.js +0 -1
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.js +0 -1560
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.min.js +0 -1
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.js +0 -1548
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.min.js +0 -1
- package/dist/node_modules/moment-timezone/builds/moment-timezone.min.js +0 -1
- package/dist/node_modules/moment-timezone/composer.json +0 -43
- package/dist/node_modules/moment-timezone/data/meta/latest.json +0 -5889
- package/dist/node_modules/moment-timezone/data/packed/latest.json +0 -852
- package/dist/node_modules/moment-timezone/index.d.ts +0 -78
- package/dist/node_modules/moment-timezone/index.js +0 -15
- package/dist/node_modules/moment-timezone/moment-timezone-utils.d.ts +0 -70
- package/dist/node_modules/moment-timezone/moment-timezone-utils.js +0 -339
- package/dist/node_modules/moment-timezone/moment-timezone.js +0 -696
- package/dist/node_modules/moment-timezone/package.json +0 -1
- package/dist/server/flow-schema-contributions/index.d.ts +0 -10
- package/dist/server/flow-schema-contributions/index.js +0 -240
- package/dist/server/formatter/formatter.d.ts +0 -27
- package/dist/server/formatter/formatter.js +0 -85
- package/dist/server/formatter/mysql-formatter.d.ts +0 -14
- package/dist/server/formatter/mysql-formatter.js +0 -93
- package/dist/server/formatter/oracle-formatter.d.ts +0 -14
- package/dist/server/formatter/oracle-formatter.js +0 -74
- package/dist/server/formatter/postgres-formatter.d.ts +0 -14
- package/dist/server/formatter/postgres-formatter.js +0 -74
- package/dist/server/formatter/sqlite-formatter.d.ts +0 -15
- package/dist/server/formatter/sqlite-formatter.js +0 -83
- package/dist/server/query-parser/index.d.ts +0 -11
- package/dist/server/query-parser/index.js +0 -56
- package/dist/server/query-parser/mysql-query-parser.d.ts +0 -15
- package/dist/server/query-parser/mysql-query-parser.js +0 -43
- package/dist/server/query-parser/oracle-query-parser.d.ts +0 -18
- package/dist/server/query-parser/oracle-query-parser.js +0 -60
- package/dist/server/query-parser/postgres-query-parser.d.ts +0 -15
- package/dist/server/query-parser/postgres-query-parser.js +0 -43
- package/dist/server/query-parser/query-parser.d.ts +0 -31
- package/dist/server/query-parser/query-parser.js +0 -146
- package/dist/server/query-parser/sqlite-query-parser.d.ts +0 -15
- package/dist/server/query-parser/sqlite-query-parser.js +0 -43
|
@@ -1,83 +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_formatter_exports = {};
|
|
28
|
-
__export(sqlite_formatter_exports, {
|
|
29
|
-
SQLiteFormatter: () => SQLiteFormatter
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(sqlite_formatter_exports);
|
|
32
|
-
var import_formatter = require("./formatter");
|
|
33
|
-
class SQLiteFormatter extends import_formatter.Formatter {
|
|
34
|
-
convertFormat(format) {
|
|
35
|
-
return format.replace(/YYYY/g, "%Y").replace(/MM/g, "%m").replace(/DD/g, "%d").replace(/hh/g, "%H").replace(/mm/g, "%M").replace(/ss/g, "%S");
|
|
36
|
-
}
|
|
37
|
-
getOffsetMinutesFromTimezone(timezone) {
|
|
38
|
-
const sign = timezone.charAt(0);
|
|
39
|
-
timezone = timezone.slice(1);
|
|
40
|
-
const [hours, minutes] = timezone.split(":");
|
|
41
|
-
const hoursNum = Number(hours);
|
|
42
|
-
const minutesNum = Number(minutes);
|
|
43
|
-
const offset = hoursNum * 60 + minutesNum;
|
|
44
|
-
return `${sign}${offset} minutes`;
|
|
45
|
-
}
|
|
46
|
-
formatDate(field, format, timezone) {
|
|
47
|
-
format = this.convertFormat(format);
|
|
48
|
-
if (timezone) {
|
|
49
|
-
return this.sequelize.fn("strftime", format, field, this.getOffsetMinutesFromTimezone(timezone));
|
|
50
|
-
}
|
|
51
|
-
return this.sequelize.fn("strftime", format, field);
|
|
52
|
-
}
|
|
53
|
-
formatUnixTimeStamp(field, format, accuracy = "second", timezone) {
|
|
54
|
-
format = this.convertFormat(format);
|
|
55
|
-
const col = this.sequelize.getQueryInterface().quoteIdentifiers(field);
|
|
56
|
-
if (accuracy === "millisecond") {
|
|
57
|
-
return this.sequelize.fn(
|
|
58
|
-
"strftime",
|
|
59
|
-
format,
|
|
60
|
-
this.sequelize.fn(
|
|
61
|
-
"DATETIME",
|
|
62
|
-
this.sequelize.literal(`ROUND(${col} / 1000)`),
|
|
63
|
-
"unixepoch",
|
|
64
|
-
this.getOffsetMinutesFromTimezone(timezone)
|
|
65
|
-
)
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
return this.sequelize.fn(
|
|
69
|
-
"strftime",
|
|
70
|
-
format,
|
|
71
|
-
this.sequelize.fn(
|
|
72
|
-
"DATETIME",
|
|
73
|
-
this.sequelize.col(field),
|
|
74
|
-
"unixepoch",
|
|
75
|
-
this.getOffsetMinutesFromTimezone(timezone)
|
|
76
|
-
)
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
-
0 && (module.exports = {
|
|
82
|
-
SQLiteFormatter
|
|
83
|
-
});
|
|
@@ -1,11 +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 { QueryParser } from './query-parser';
|
|
11
|
-
export declare const createQueryParser: (db: Database) => QueryParser;
|
|
@@ -1,56 +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
|
-
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
|
-
});
|
|
@@ -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 { 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
|
-
}
|
|
@@ -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 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
|
-
});
|
|
@@ -1,18 +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 { 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
|
-
}
|
|
@@ -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
|
-
});
|