@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.
- package/dist/client/block/ChartBlockProvider.d.ts +10 -0
- package/dist/client/block/GlobalAutoRefreshProvider.d.ts +19 -0
- package/dist/client/block/index.d.ts +2 -0
- package/dist/client/chart/chart.d.ts +9 -6
- package/dist/client/chart/configs.d.ts +212 -19
- package/dist/client/chart/group.d.ts +9 -4
- package/dist/client/configure/schemas/configure.d.ts +1 -1
- package/dist/client/filter/utils.d.ts +2 -1
- package/dist/client/hooks/chart.d.ts +20 -0
- package/dist/client/hooks/index.d.ts +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +30 -30
- package/dist/client/initializers/BlockRefreshAction.d.ts +14 -0
- package/dist/client/initializers/RefreshAction.d.ts +14 -0
- package/dist/client/initializers/chartActions.d.ts +10 -0
- package/dist/client/initializers/chartBlockActions.d.ts +10 -0
- package/dist/client/renderer/ChartRendererDesigner.d.ts +10 -0
- package/dist/client/renderer/ChartRendererProvider.d.ts +6 -0
- package/dist/client/settings/AutoRefreshItem.d.ts +13 -0
- package/dist/client/settings/chartActionRefresh.d.ts +10 -0
- package/dist/client/settings/chartBlockActionRefresh.d.ts +10 -0
- package/dist/client/utils.d.ts +42 -0
- package/dist/externalVersion.js +8 -8
- package/dist/locale/en-US.json +15 -14
- package/dist/locale/zh-CN.json +10 -9
- package/dist/node_modules/koa-compose/package.json +1 -1
- package/dist/node_modules/moment-timezone/LICENSE +20 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.js +1548 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.min.js +1 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.js +1548 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.min.js +1 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.js +1560 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.min.js +1 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.js +1548 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.min.js +1 -0
- package/dist/node_modules/moment-timezone/builds/moment-timezone.min.js +1 -0
- package/dist/node_modules/moment-timezone/composer.json +43 -0
- package/dist/node_modules/moment-timezone/data/meta/latest.json +5889 -0
- package/dist/node_modules/moment-timezone/data/packed/latest.json +852 -0
- package/dist/node_modules/moment-timezone/index.d.ts +78 -0
- package/dist/node_modules/moment-timezone/index.js +15 -0
- package/dist/node_modules/moment-timezone/moment-timezone-utils.d.ts +70 -0
- package/dist/node_modules/moment-timezone/moment-timezone-utils.js +339 -0
- package/dist/node_modules/moment-timezone/moment-timezone.js +696 -0
- package/dist/node_modules/moment-timezone/package.json +1 -0
- package/dist/server/actions/query.d.ts +0 -1
- package/dist/server/actions/query.js +11 -75
- package/dist/server/formatter/formatter.d.ts +27 -0
- package/dist/server/formatter/formatter.js +85 -0
- package/dist/server/formatter/mysql-formatter.d.ts +14 -0
- package/dist/server/formatter/mysql-formatter.js +86 -0
- package/dist/server/formatter/oracle-formatter.d.ts +14 -0
- package/dist/server/formatter/oracle-formatter.js +74 -0
- package/dist/server/formatter/postgres-formatter.d.ts +14 -0
- package/dist/server/formatter/postgres-formatter.js +74 -0
- package/dist/server/formatter/sqlite-formatter.d.ts +15 -0
- package/dist/server/formatter/sqlite-formatter.js +83 -0
- package/dist/server/migrations/20240921214400-rename-charttype.d.ts +14 -0
- package/dist/server/migrations/20240921214400-rename-charttype.js +64 -0
- package/dist/server/plugin.js +1 -1
- package/dist/server/query-parser/index.d.ts +11 -0
- package/dist/server/query-parser/index.js +56 -0
- package/dist/server/query-parser/mysql-query-parser.d.ts +15 -0
- package/dist/server/query-parser/mysql-query-parser.js +43 -0
- package/dist/server/query-parser/oracle-query-parser.d.ts +18 -0
- package/dist/server/query-parser/oracle-query-parser.js +60 -0
- package/dist/server/query-parser/postgres-query-parser.d.ts +15 -0
- package/dist/server/query-parser/postgres-query-parser.js +43 -0
- package/dist/server/query-parser/query-parser.d.ts +31 -0
- package/dist/server/query-parser/query-parser.js +134 -0
- package/dist/server/query-parser/sqlite-query-parser.d.ts +15 -0
- package/dist/server/query-parser/sqlite-query-parser.js +43 -0
- package/dist/server/types.d.ts +46 -0
- package/dist/server/types.js +24 -0
- package/package.json +2 -2
- package/dist/client/chart/g2plot/configs.d.ts +0 -122
- package/dist/server/actions/formatter.d.ts +0 -12
- package/dist/server/actions/formatter.js +0 -101
- /package/dist/locale/{ja_JP.json → ja-JP.json} +0 -0
- /package/dist/locale/{ko_KR.json → ko-KR.json} +0 -0
|
@@ -38,7 +38,6 @@ var query_exports = {};
|
|
|
38
38
|
__export(query_exports, {
|
|
39
39
|
cacheMiddleware: () => cacheMiddleware,
|
|
40
40
|
checkPermission: () => checkPermission,
|
|
41
|
-
parseBuilder: () => parseBuilder,
|
|
42
41
|
parseFieldAndAssociations: () => parseFieldAndAssociations,
|
|
43
42
|
parseVariables: () => parseVariables,
|
|
44
43
|
postProcess: () => postProcess,
|
|
@@ -47,10 +46,9 @@ __export(query_exports, {
|
|
|
47
46
|
});
|
|
48
47
|
module.exports = __toCommonJS(query_exports);
|
|
49
48
|
var import_database = require("@nocobase/database");
|
|
50
|
-
var import_formatter = require("./formatter");
|
|
51
49
|
var import_koa_compose = __toESM(require("koa-compose"));
|
|
52
50
|
var import_server = require("@nocobase/server");
|
|
53
|
-
|
|
51
|
+
var import_query_parser = require("../query-parser");
|
|
54
52
|
const getDB = (ctx, dataSource) => {
|
|
55
53
|
const ds = ctx.app.dataSourceManager.dataSources.get(dataSource);
|
|
56
54
|
return ds == null ? void 0 : ds.collectionManager.db;
|
|
@@ -88,73 +86,6 @@ const queryData = async (ctx, next) => {
|
|
|
88
86
|
};
|
|
89
87
|
await next();
|
|
90
88
|
};
|
|
91
|
-
const parseBuilder = async (ctx, next) => {
|
|
92
|
-
const { dataSource, measures, dimensions, orders, include, where, limit } = ctx.action.params.values;
|
|
93
|
-
const db = getDB(ctx, dataSource) || ctx.db;
|
|
94
|
-
const { sequelize } = db;
|
|
95
|
-
const attributes = [];
|
|
96
|
-
const group = [];
|
|
97
|
-
const order = [];
|
|
98
|
-
const fieldMap = {};
|
|
99
|
-
let hasAgg = false;
|
|
100
|
-
measures.forEach((measure) => {
|
|
101
|
-
const { field, aggregation, alias, distinct } = measure;
|
|
102
|
-
const attribute = [];
|
|
103
|
-
const col = sequelize.col(field);
|
|
104
|
-
if (aggregation) {
|
|
105
|
-
if (!AllowedAggFuncs.includes(aggregation)) {
|
|
106
|
-
throw new Error(`Invalid aggregation function: ${aggregation}`);
|
|
107
|
-
}
|
|
108
|
-
hasAgg = true;
|
|
109
|
-
attribute.push(sequelize.fn(aggregation, distinct ? sequelize.fn("DISTINCT", col) : col));
|
|
110
|
-
} else {
|
|
111
|
-
attribute.push(col);
|
|
112
|
-
}
|
|
113
|
-
if (alias) {
|
|
114
|
-
attribute.push(alias);
|
|
115
|
-
}
|
|
116
|
-
attributes.push(attribute.length > 1 ? attribute : attribute[0]);
|
|
117
|
-
fieldMap[alias || field] = measure;
|
|
118
|
-
});
|
|
119
|
-
dimensions.forEach((dimension) => {
|
|
120
|
-
const { field, format, alias, type } = dimension;
|
|
121
|
-
const attribute = [];
|
|
122
|
-
const col = sequelize.col(field);
|
|
123
|
-
if (format) {
|
|
124
|
-
attribute.push((0, import_formatter.formatter)(sequelize, type, field, format, ctx.timezone));
|
|
125
|
-
} else {
|
|
126
|
-
attribute.push(col);
|
|
127
|
-
}
|
|
128
|
-
if (alias) {
|
|
129
|
-
attribute.push(alias);
|
|
130
|
-
}
|
|
131
|
-
attributes.push(attribute.length > 1 ? attribute : attribute[0]);
|
|
132
|
-
if (hasAgg) {
|
|
133
|
-
group.push(attribute[0]);
|
|
134
|
-
}
|
|
135
|
-
fieldMap[alias || field] = dimension;
|
|
136
|
-
});
|
|
137
|
-
orders.forEach((item) => {
|
|
138
|
-
const alias = sequelize.getQueryInterface().quoteIdentifier(item.alias);
|
|
139
|
-
const name = hasAgg ? sequelize.literal(alias) : sequelize.col(item.field);
|
|
140
|
-
order.push([name, item.order || "ASC"]);
|
|
141
|
-
});
|
|
142
|
-
ctx.action.params.values = {
|
|
143
|
-
...ctx.action.params.values,
|
|
144
|
-
queryParams: {
|
|
145
|
-
where,
|
|
146
|
-
attributes,
|
|
147
|
-
include,
|
|
148
|
-
group,
|
|
149
|
-
order,
|
|
150
|
-
limit: limit || 2e3,
|
|
151
|
-
subQuery: false,
|
|
152
|
-
raw: true
|
|
153
|
-
},
|
|
154
|
-
fieldMap
|
|
155
|
-
};
|
|
156
|
-
await next();
|
|
157
|
-
};
|
|
158
89
|
const parseFieldAndAssociations = async (ctx, next) => {
|
|
159
90
|
const {
|
|
160
91
|
dataSource,
|
|
@@ -170,7 +101,7 @@ const parseFieldAndAssociations = async (ctx, next) => {
|
|
|
170
101
|
const associations = collection.model.associations;
|
|
171
102
|
const models = {};
|
|
172
103
|
const parseField = (selected) => {
|
|
173
|
-
var _a, _b, _c, _d;
|
|
104
|
+
var _a, _b, _c, _d, _e, _f;
|
|
174
105
|
let target;
|
|
175
106
|
let name;
|
|
176
107
|
if (!Array.isArray(selected.field)) {
|
|
@@ -183,14 +114,16 @@ const parseFieldAndAssociations = async (ctx, next) => {
|
|
|
183
114
|
const rawAttributes = collection.model.getAttributes();
|
|
184
115
|
let field = ((_a = rawAttributes[name]) == null ? void 0 : _a.field) || name;
|
|
185
116
|
let fieldType = (_b = fields.get(name)) == null ? void 0 : _b.type;
|
|
117
|
+
let fieldOptions = (_c = fields.get(name)) == null ? void 0 : _c.options;
|
|
186
118
|
if (target) {
|
|
187
119
|
const targetField = fields.get(target);
|
|
188
120
|
const targetCollection = db.getCollection(targetField.target);
|
|
189
121
|
const targetFields = targetCollection.fields;
|
|
190
|
-
fieldType = (
|
|
122
|
+
fieldType = (_d = targetFields.get(name)) == null ? void 0 : _d.type;
|
|
123
|
+
fieldOptions = (_e = targetFields.get(name)) == null ? void 0 : _e.options;
|
|
191
124
|
field = `${target}.${field}`;
|
|
192
125
|
name = `${target}.${name}`;
|
|
193
|
-
const targetType = (
|
|
126
|
+
const targetType = (_f = fields.get(target)) == null ? void 0 : _f.type;
|
|
194
127
|
if (!models[target]) {
|
|
195
128
|
models[target] = { type: targetType };
|
|
196
129
|
}
|
|
@@ -202,6 +135,7 @@ const parseFieldAndAssociations = async (ctx, next) => {
|
|
|
202
135
|
field,
|
|
203
136
|
name,
|
|
204
137
|
type: fieldType,
|
|
138
|
+
options: fieldOptions,
|
|
205
139
|
alias: selected.alias || name
|
|
206
140
|
};
|
|
207
141
|
};
|
|
@@ -284,13 +218,16 @@ const checkPermission = (ctx, next) => {
|
|
|
284
218
|
return next();
|
|
285
219
|
};
|
|
286
220
|
const query = async (ctx, next) => {
|
|
221
|
+
const { dataSource } = ctx.action.params.values;
|
|
222
|
+
const db = getDB(ctx, dataSource) || ctx.db;
|
|
223
|
+
const queryParser = (0, import_query_parser.createQueryParser)(db);
|
|
287
224
|
try {
|
|
288
225
|
await (0, import_koa_compose.default)([
|
|
289
226
|
checkPermission,
|
|
290
227
|
cacheMiddleware,
|
|
291
228
|
parseVariables,
|
|
292
229
|
parseFieldAndAssociations,
|
|
293
|
-
|
|
230
|
+
queryParser.parse(),
|
|
294
231
|
queryData,
|
|
295
232
|
postProcess
|
|
296
233
|
])(ctx, next);
|
|
@@ -302,7 +239,6 @@ const query = async (ctx, next) => {
|
|
|
302
239
|
0 && (module.exports = {
|
|
303
240
|
cacheMiddleware,
|
|
304
241
|
checkPermission,
|
|
305
|
-
parseBuilder,
|
|
306
242
|
parseFieldAndAssociations,
|
|
307
243
|
parseVariables,
|
|
308
244
|
postProcess,
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { Sequelize } from 'sequelize';
|
|
10
|
+
export type Col = ReturnType<typeof Sequelize.col>;
|
|
11
|
+
export type Literal = ReturnType<typeof Sequelize.literal>;
|
|
12
|
+
export type Fn = ReturnType<typeof Sequelize.fn>;
|
|
13
|
+
export declare abstract class Formatter {
|
|
14
|
+
sequelize: Sequelize;
|
|
15
|
+
constructor(sequelize: Sequelize);
|
|
16
|
+
abstract formatDate(field: Col, format: string, timezone?: string): Fn | Col;
|
|
17
|
+
abstract formatUnixTimeStamp(field: string, format: string, accuracy?: 'second' | 'millisecond', timezone?: string): Fn | Literal;
|
|
18
|
+
getTimezoneByOffset(offset: string): string;
|
|
19
|
+
convertFormat(format: string): string;
|
|
20
|
+
format(options: {
|
|
21
|
+
type: string;
|
|
22
|
+
field: string;
|
|
23
|
+
format: string;
|
|
24
|
+
options?: any;
|
|
25
|
+
timezone?: string;
|
|
26
|
+
}): import("sequelize/types/utils").Col | import("sequelize/types/utils").Literal | import("sequelize/types/utils").Fn;
|
|
27
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var formatter_exports = {};
|
|
38
|
+
__export(formatter_exports, {
|
|
39
|
+
Formatter: () => Formatter
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(formatter_exports);
|
|
42
|
+
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
43
|
+
class Formatter {
|
|
44
|
+
sequelize;
|
|
45
|
+
constructor(sequelize) {
|
|
46
|
+
this.sequelize = sequelize;
|
|
47
|
+
}
|
|
48
|
+
getTimezoneByOffset(offset) {
|
|
49
|
+
if (!/^[+-]\d{1,2}:\d{2}$/.test(offset)) {
|
|
50
|
+
return offset;
|
|
51
|
+
}
|
|
52
|
+
const offsetMinutes = import_moment_timezone.default.duration(offset).asMinutes();
|
|
53
|
+
return import_moment_timezone.default.tz.names().find((timezone) => {
|
|
54
|
+
return import_moment_timezone.default.tz(timezone).utcOffset() === offsetMinutes;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
convertFormat(format) {
|
|
58
|
+
return format;
|
|
59
|
+
}
|
|
60
|
+
format(options) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const { type, field, format, timezone, options: fieldOptions } = options;
|
|
63
|
+
const col = this.sequelize.col(field);
|
|
64
|
+
switch (type) {
|
|
65
|
+
case "date":
|
|
66
|
+
case "datetime":
|
|
67
|
+
case "datetimeTz":
|
|
68
|
+
return this.formatDate(col, format, timezone);
|
|
69
|
+
case "datetimeNoTz":
|
|
70
|
+
case "dateOnly":
|
|
71
|
+
case "time":
|
|
72
|
+
return this.formatDate(col, format);
|
|
73
|
+
case "unixTimestamp": {
|
|
74
|
+
const accuracy = ((_b = (_a = fieldOptions == null ? void 0 : fieldOptions.uiSchema) == null ? void 0 : _a["x-component-props"]) == null ? void 0 : _b.accuracy) || (fieldOptions == null ? void 0 : fieldOptions.accuracy) || "second";
|
|
75
|
+
return this.formatUnixTimeStamp(field, format, accuracy, timezone);
|
|
76
|
+
}
|
|
77
|
+
default:
|
|
78
|
+
return this.sequelize.col(field);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
Formatter
|
|
85
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { Col, Formatter } from './formatter';
|
|
10
|
+
export declare class MySQLFormatter extends Formatter {
|
|
11
|
+
convertFormat(format: string): string;
|
|
12
|
+
formatDate(field: Col, format: string, timezoneOffset?: string): import("sequelize/types/utils").Fn;
|
|
13
|
+
formatUnixTimeStamp(field: string, format: string, accuracy?: 'second' | 'millisecond', timezoneOffset?: string): import("sequelize/types/utils").Fn;
|
|
14
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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_formatter_exports = {};
|
|
28
|
+
__export(mysql_formatter_exports, {
|
|
29
|
+
MySQLFormatter: () => MySQLFormatter
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(mysql_formatter_exports);
|
|
32
|
+
var import_formatter = require("./formatter");
|
|
33
|
+
class MySQLFormatter 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, "%i").replace(/ss/g, "%S");
|
|
36
|
+
}
|
|
37
|
+
formatDate(field, format, timezoneOffset) {
|
|
38
|
+
const timezone = this.getTimezoneByOffset(timezoneOffset);
|
|
39
|
+
format = this.convertFormat(format);
|
|
40
|
+
if (timezone) {
|
|
41
|
+
return this.sequelize.fn(
|
|
42
|
+
"date_format",
|
|
43
|
+
this.sequelize.fn("convert_tz", field, process.env.TZ || "UTC", timezone),
|
|
44
|
+
format
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return this.sequelize.fn("date_format", field, format);
|
|
48
|
+
}
|
|
49
|
+
formatUnixTimeStamp(field, format, accuracy = "second", timezoneOffset) {
|
|
50
|
+
const col = this.sequelize.getQueryInterface().quoteIdentifiers(field);
|
|
51
|
+
const timezone = this.getTimezoneByOffset(timezoneOffset);
|
|
52
|
+
format = this.convertFormat(format);
|
|
53
|
+
if (timezone) {
|
|
54
|
+
if (accuracy === "millisecond") {
|
|
55
|
+
return this.sequelize.fn(
|
|
56
|
+
"date_format",
|
|
57
|
+
this.sequelize.fn(
|
|
58
|
+
"convert_tz",
|
|
59
|
+
this.sequelize.fn("from_unixtime", this.sequelize.literal(`ROUND(${col} / 1000)`)),
|
|
60
|
+
process.env.TZ || "UTC",
|
|
61
|
+
timezone
|
|
62
|
+
),
|
|
63
|
+
format
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return this.sequelize.fn(
|
|
67
|
+
"date_format",
|
|
68
|
+
this.sequelize.fn(
|
|
69
|
+
"convert_tz",
|
|
70
|
+
this.sequelize.fn("from_unixtime", this.sequelize.col(field)),
|
|
71
|
+
process.env.TZ || "UTC",
|
|
72
|
+
timezone
|
|
73
|
+
),
|
|
74
|
+
format
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (accuracy === "millisecond") {
|
|
78
|
+
return this.sequelize.fn("from_unixtime", this.sequelize.literal(`ROUND(${col} / 1000)`), format);
|
|
79
|
+
}
|
|
80
|
+
return this.sequelize.fn("from_unixtime", this.sequelize.col(field), format);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
MySQLFormatter
|
|
86
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { Col, Formatter } from './formatter';
|
|
10
|
+
export declare class OracleFormatter extends Formatter {
|
|
11
|
+
convertFormat(format: string): string;
|
|
12
|
+
formatDate(field: Col, format: string, timezoneOffset?: string): import("sequelize/types/utils").Fn;
|
|
13
|
+
formatUnixTimeStamp(field: string, format: string, accuracy?: 'second' | 'millisecond', timezoneOffset?: string): import("sequelize/types/utils").Fn;
|
|
14
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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_formatter_exports = {};
|
|
28
|
+
__export(oracle_formatter_exports, {
|
|
29
|
+
OracleFormatter: () => OracleFormatter
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(oracle_formatter_exports);
|
|
32
|
+
var import_formatter = require("./formatter");
|
|
33
|
+
class OracleFormatter extends import_formatter.Formatter {
|
|
34
|
+
convertFormat(format) {
|
|
35
|
+
return format.replace(/hh/g, "HH24").replace(/mm/g, "MI").replace(/ss/g, "SS");
|
|
36
|
+
}
|
|
37
|
+
formatDate(field, format, timezoneOffset) {
|
|
38
|
+
format = this.convertFormat(format);
|
|
39
|
+
const timezone = this.getTimezoneByOffset(timezoneOffset);
|
|
40
|
+
if (timezone) {
|
|
41
|
+
const col = this.sequelize.getQueryInterface().quoteIdentifiers(field.col);
|
|
42
|
+
const fieldWithTZ = this.sequelize.literal(`(${col} AT TIME ZONE '${timezone}')`);
|
|
43
|
+
return this.sequelize.fn("to_char", fieldWithTZ, format);
|
|
44
|
+
}
|
|
45
|
+
return this.sequelize.fn("to_char", field, format);
|
|
46
|
+
}
|
|
47
|
+
formatUnixTimeStamp(field, format, accuracy = "second", timezoneOffset) {
|
|
48
|
+
format = this.convertFormat(format);
|
|
49
|
+
const col = this.sequelize.getQueryInterface().quoteIdentifiers(field);
|
|
50
|
+
const timezone = this.getTimezoneByOffset(timezoneOffset);
|
|
51
|
+
if (timezone) {
|
|
52
|
+
if (accuracy === "millisecond") {
|
|
53
|
+
return this.sequelize.fn(
|
|
54
|
+
"to_char",
|
|
55
|
+
this.sequelize.literal(`to_timestamp(ROUND(${col} / 1000)) AT TIME ZONE '${timezone}'`),
|
|
56
|
+
format
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return this.sequelize.fn(
|
|
60
|
+
"to_char",
|
|
61
|
+
this.sequelize.literal(`to_timestamp(${col}) AT TIME ZONE '${timezone}'`),
|
|
62
|
+
format
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (accuracy === "millisecond") {
|
|
66
|
+
return this.sequelize.fn("to_char", this.sequelize.literal(`to_timestamp(ROUND(${col} / 1000)`), format);
|
|
67
|
+
}
|
|
68
|
+
return this.sequelize.fn("to_char", this.sequelize.literal(`to_timestamp(${col})`), format);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
OracleFormatter
|
|
74
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { Col, Formatter } from './formatter';
|
|
10
|
+
export declare class PostgresFormatter extends Formatter {
|
|
11
|
+
convertFormat(format: string): string;
|
|
12
|
+
formatDate(field: Col, format: string, timezoneOffset?: string): import("sequelize/types/utils").Fn;
|
|
13
|
+
formatUnixTimeStamp(field: string, format: string, accuracy?: 'second' | 'millisecond', timezoneOffset?: string): import("sequelize/types/utils").Fn;
|
|
14
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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_formatter_exports = {};
|
|
28
|
+
__export(postgres_formatter_exports, {
|
|
29
|
+
PostgresFormatter: () => PostgresFormatter
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(postgres_formatter_exports);
|
|
32
|
+
var import_formatter = require("./formatter");
|
|
33
|
+
class PostgresFormatter extends import_formatter.Formatter {
|
|
34
|
+
convertFormat(format) {
|
|
35
|
+
return format.replace(/hh/g, "HH24").replace(/mm/g, "MI").replace(/ss/g, "SS");
|
|
36
|
+
}
|
|
37
|
+
formatDate(field, format, timezoneOffset) {
|
|
38
|
+
format = this.convertFormat(format);
|
|
39
|
+
const timezone = this.getTimezoneByOffset(timezoneOffset);
|
|
40
|
+
if (timezone) {
|
|
41
|
+
const col = this.sequelize.getQueryInterface().quoteIdentifiers(field.col);
|
|
42
|
+
const fieldWithTZ = this.sequelize.literal(`(${col} AT TIME ZONE '${timezone}')`);
|
|
43
|
+
return this.sequelize.fn("to_char", fieldWithTZ, format);
|
|
44
|
+
}
|
|
45
|
+
return this.sequelize.fn("to_char", field, format);
|
|
46
|
+
}
|
|
47
|
+
formatUnixTimeStamp(field, format, accuracy = "second", timezoneOffset) {
|
|
48
|
+
format = this.convertFormat(format);
|
|
49
|
+
const col = this.sequelize.getQueryInterface().quoteIdentifiers(field);
|
|
50
|
+
const timezone = this.getTimezoneByOffset(timezoneOffset);
|
|
51
|
+
if (timezone) {
|
|
52
|
+
if (accuracy === "millisecond") {
|
|
53
|
+
return this.sequelize.fn(
|
|
54
|
+
"to_char",
|
|
55
|
+
this.sequelize.literal(`to_timestamp(ROUND(${col} / 1000)) AT TIME ZONE '${timezone}'`),
|
|
56
|
+
format
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return this.sequelize.fn(
|
|
60
|
+
"to_char",
|
|
61
|
+
this.sequelize.literal(`to_timestamp(${col}) AT TIME ZONE '${timezone}'`),
|
|
62
|
+
format
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (accuracy === "millisecond") {
|
|
66
|
+
return this.sequelize.fn("to_char", this.sequelize.literal(`to_timestamp(ROUND(${col} / 1000)`), format);
|
|
67
|
+
}
|
|
68
|
+
return this.sequelize.fn("to_char", this.sequelize.literal(`to_timestamp(${col})`), format);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
PostgresFormatter
|
|
74
|
+
});
|
|
@@ -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 { Col, Formatter } from './formatter';
|
|
10
|
+
export declare class SQLiteFormatter extends Formatter {
|
|
11
|
+
convertFormat(format: string): string;
|
|
12
|
+
getOffsetMinutesFromTimezone(timezone: string): string;
|
|
13
|
+
formatDate(field: Col, format: string, timezone?: string): import("sequelize/types/utils").Fn;
|
|
14
|
+
formatUnixTimeStamp(field: string, format: string, accuracy?: 'second' | 'millisecond', timezone?: string): import("sequelize/types/utils").Fn;
|
|
15
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
on: string;
|
|
12
|
+
appVersion: string;
|
|
13
|
+
up(): Promise<void>;
|
|
14
|
+
}
|