@nocobase/plugin-data-visualization 1.2.13-alpha → 1.3.0-alpha.20240710084543
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/package.json +2 -2
- package/dist/client/block/ChartBlock.d.ts +0 -10
- package/dist/client/block/ChartBlockDesigner.d.ts +0 -10
- package/dist/client/block/ChartBlockInitializer.d.ts +0 -17
- package/dist/client/block/ChartDataProvider.d.ts +0 -24
- package/dist/client/block/index.d.ts +0 -11
- package/dist/client/chart/antd/antd.d.ts +0 -15
- package/dist/client/chart/antd/index.d.ts +0 -12
- package/dist/client/chart/antd/statistic.d.ts +0 -15
- package/dist/client/chart/antd/table.d.ts +0 -14
- package/dist/client/chart/chart.d.ts +0 -84
- package/dist/client/chart/configs.d.ts +0 -97
- package/dist/client/chart/g2plot/AntChart.d.ts +0 -10
- package/dist/client/chart/g2plot/bar.d.ts +0 -14
- package/dist/client/chart/g2plot/configs.d.ts +0 -48
- package/dist/client/chart/g2plot/dualAxes.d.ts +0 -17
- package/dist/client/chart/g2plot/g2plot.d.ts +0 -18
- package/dist/client/chart/g2plot/index.d.ts +0 -11
- package/dist/client/chart/g2plot/pie.d.ts +0 -15
- package/dist/client/chart/group.d.ts +0 -64
- package/dist/client/configure/ChartConfigProvider.d.ts +0 -26
- package/dist/client/configure/ChartConfigure.d.ts +0 -26
- package/dist/client/configure/FilterDynamicComponent.d.ts +0 -10
- package/dist/client/configure/TransformerDynamicComponent.d.ts +0 -12
- package/dist/client/configure/formatters.d.ts +0 -23
- package/dist/client/configure/index.d.ts +0 -10
- package/dist/client/configure/schemas/configure.d.ts +0 -12
- package/dist/client/filter/CollectionFieldInitializer.d.ts +0 -10
- package/dist/client/filter/FilterActionInitializers.d.ts +0 -28
- package/dist/client/filter/FilterBlockDesigner.d.ts +0 -10
- package/dist/client/filter/FilterBlockInitializer.d.ts +0 -11
- package/dist/client/filter/FilterBlockProvider.d.ts +0 -10
- package/dist/client/filter/FilterCheckbox.d.ts +0 -10
- package/dist/client/filter/FilterForm.d.ts +0 -10
- package/dist/client/filter/FilterItemDesigner.d.ts +0 -10
- package/dist/client/filter/FilterItemInitializers.d.ts +0 -20
- package/dist/client/filter/FilterProvider.d.ts +0 -38
- package/dist/client/filter/FilterVariableInput.d.ts +0 -10
- package/dist/client/filter/index.d.ts +0 -14
- package/dist/client/filter/utils.d.ts +0 -67
- package/dist/client/hooks/filter.d.ts +0 -69
- package/dist/client/hooks/index.d.ts +0 -12
- package/dist/client/hooks/query.d.ts +0 -61
- package/dist/client/hooks/transformer.d.ts +0 -26
- package/dist/client/hooks/useDateVariable.d.ts +0 -22
- package/dist/client/hooks/useUserVariable.d.ts +0 -16
- package/dist/client/hooks/useVariableOptions.d.ts +0 -33
- package/dist/client/index.d.ts +0 -20
- package/dist/client/index.js +0 -170
- package/dist/client/locale/index.d.ts +0 -11
- package/dist/client/renderer/ChartRenderer.d.ts +0 -12
- package/dist/client/renderer/ChartRendererProvider.d.ts +0 -56
- package/dist/client/renderer/index.d.ts +0 -10
- package/dist/client/transformers.d.ts +0 -20
- package/dist/client/utils.d.ts +0 -110
- package/dist/externalVersion.js +0 -30
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -48
- package/dist/locale/en-US.json +0 -91
- package/dist/locale/ko_KR.json +0 -85
- package/dist/locale/zh-CN.json +0 -92
- package/dist/node_modules/koa-compose/index.js +0 -1
- package/dist/node_modules/koa-compose/package.json +0 -1
- package/dist/server/actions/formatter.d.ts +0 -12
- package/dist/server/actions/formatter.js +0 -101
- package/dist/server/actions/query.d.ts +0 -17
- package/dist/server/actions/query.js +0 -293
- package/dist/server/index.d.ts +0 -9
- package/dist/server/index.js +0 -42
- package/dist/server/migrations/20230926211750-rename-charttype.d.ts +0 -13
- package/dist/server/migrations/20230926211750-rename-charttype.js +0 -60
- package/dist/server/plugin.d.ts +0 -21
- package/dist/server/plugin.js +0 -70
- package/dist/swagger/index.d.ts +0 -16
- package/dist/swagger/index.js +0 -38
|
@@ -1,101 +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 formatter_exports = {};
|
|
28
|
-
__export(formatter_exports, {
|
|
29
|
-
dateFormatFn: () => dateFormatFn,
|
|
30
|
-
formatFn: () => formatFn,
|
|
31
|
-
formatter: () => formatter
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(formatter_exports);
|
|
34
|
-
const getOffsetMinutesFromTimezone = (timezone) => {
|
|
35
|
-
const sign = timezone.charAt(0);
|
|
36
|
-
timezone = timezone.slice(1);
|
|
37
|
-
const [hours, minutes] = timezone.split(":");
|
|
38
|
-
const hoursNum = Number(hours);
|
|
39
|
-
const minutesNum = Number(minutes);
|
|
40
|
-
const offset = hoursNum * 60 + minutesNum;
|
|
41
|
-
return `${sign}${offset} minutes`;
|
|
42
|
-
};
|
|
43
|
-
const dateFormatFn = (sequelize, dialect, field, format, timezone) => {
|
|
44
|
-
switch (dialect) {
|
|
45
|
-
case "sqlite":
|
|
46
|
-
format = 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");
|
|
47
|
-
if (timezone) {
|
|
48
|
-
return sequelize.fn("strftime", format, sequelize.col(field), getOffsetMinutesFromTimezone(timezone));
|
|
49
|
-
}
|
|
50
|
-
return sequelize.fn("strftime", format, sequelize.col(field));
|
|
51
|
-
case "mysql":
|
|
52
|
-
case "mariadb":
|
|
53
|
-
format = 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");
|
|
54
|
-
if (timezone) {
|
|
55
|
-
return sequelize.fn(
|
|
56
|
-
"date_format",
|
|
57
|
-
sequelize.fn("convert_tz", sequelize.col(field), process.env.DB_TIMEZONE || "+00:00", timezone),
|
|
58
|
-
format
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return sequelize.fn("date_format", sequelize.col(field), format);
|
|
62
|
-
case "postgres":
|
|
63
|
-
format = format.replace(/hh/g, "HH24").replace(/mm/g, "MI").replace(/ss/g, "SS");
|
|
64
|
-
if (timezone) {
|
|
65
|
-
const fieldWithTZ = sequelize.literal(
|
|
66
|
-
`(${sequelize.getQueryInterface().quoteIdentifiers(field)} AT TIME ZONE CURRENT_SETTING('TIMEZONE') AT TIME ZONE '${timezone}')`
|
|
67
|
-
);
|
|
68
|
-
return sequelize.fn("to_char", fieldWithTZ, format);
|
|
69
|
-
}
|
|
70
|
-
return sequelize.fn("to_char", sequelize.col(field), format);
|
|
71
|
-
default:
|
|
72
|
-
return sequelize.col(field);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
/* istanbul ignore next -- @preserve */
|
|
76
|
-
const formatFn = (sequelize, dialect, field, format) => {
|
|
77
|
-
switch (dialect) {
|
|
78
|
-
case "sqlite":
|
|
79
|
-
case "postgres":
|
|
80
|
-
return sequelize.fn("format", format, sequelize.col(field));
|
|
81
|
-
default:
|
|
82
|
-
return field;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const formatter = (sequelize, type, field, format, timezone) => {
|
|
86
|
-
const dialect = sequelize.getDialect();
|
|
87
|
-
switch (type) {
|
|
88
|
-
case "date":
|
|
89
|
-
case "datetime":
|
|
90
|
-
case "time":
|
|
91
|
-
return dateFormatFn(sequelize, dialect, field, format, timezone);
|
|
92
|
-
default:
|
|
93
|
-
return formatFn(sequelize, dialect, field, format);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
-
0 && (module.exports = {
|
|
98
|
-
dateFormatFn,
|
|
99
|
-
formatFn,
|
|
100
|
-
formatter
|
|
101
|
-
});
|
|
@@ -1,17 +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
|
-
export declare const postProcess: (ctx: Context, next: Next) => Promise<void>;
|
|
11
|
-
export declare const queryData: (ctx: Context, next: Next) => Promise<void>;
|
|
12
|
-
export declare const parseBuilder: (ctx: Context, next: Next) => Promise<void>;
|
|
13
|
-
export declare const parseFieldAndAssociations: (ctx: Context, next: Next) => Promise<void>;
|
|
14
|
-
export declare const parseVariables: (ctx: Context, next: Next) => Promise<void>;
|
|
15
|
-
export declare const cacheMiddleware: (ctx: Context, next: Next) => Promise<void>;
|
|
16
|
-
export declare const checkPermission: (ctx: Context, next: Next) => Promise<any>;
|
|
17
|
-
export declare const query: (ctx: Context, next: Next) => Promise<void>;
|
|
@@ -1,293 +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 __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 query_exports = {};
|
|
38
|
-
__export(query_exports, {
|
|
39
|
-
cacheMiddleware: () => cacheMiddleware,
|
|
40
|
-
checkPermission: () => checkPermission,
|
|
41
|
-
parseBuilder: () => parseBuilder,
|
|
42
|
-
parseFieldAndAssociations: () => parseFieldAndAssociations,
|
|
43
|
-
parseVariables: () => parseVariables,
|
|
44
|
-
postProcess: () => postProcess,
|
|
45
|
-
query: () => query,
|
|
46
|
-
queryData: () => queryData
|
|
47
|
-
});
|
|
48
|
-
module.exports = __toCommonJS(query_exports);
|
|
49
|
-
var import_database = require("@nocobase/database");
|
|
50
|
-
var import_formatter = require("./formatter");
|
|
51
|
-
var import_koa_compose = __toESM(require("koa-compose"));
|
|
52
|
-
var import_server = require("@nocobase/server");
|
|
53
|
-
const AllowedAggFuncs = ["sum", "count", "avg", "min", "max"];
|
|
54
|
-
const getDB = (ctx, dataSource) => {
|
|
55
|
-
const ds = ctx.app.dataSourceManager.dataSources.get(dataSource);
|
|
56
|
-
return ds == null ? void 0 : ds.collectionManager.db;
|
|
57
|
-
};
|
|
58
|
-
const postProcess = async (ctx, next) => {
|
|
59
|
-
const { data, fieldMap } = ctx.action.params.values;
|
|
60
|
-
ctx.body = data.map((record) => {
|
|
61
|
-
Object.entries(record).forEach(([key, value]) => {
|
|
62
|
-
if (!value) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const { type } = fieldMap[key] || {};
|
|
66
|
-
switch (type) {
|
|
67
|
-
case "bigInt":
|
|
68
|
-
case "integer":
|
|
69
|
-
case "float":
|
|
70
|
-
case "double":
|
|
71
|
-
record[key] = Number(value);
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return record;
|
|
76
|
-
});
|
|
77
|
-
await next();
|
|
78
|
-
};
|
|
79
|
-
const queryData = async (ctx, next) => {
|
|
80
|
-
const { dataSource, collection, queryParams, fieldMap } = ctx.action.params.values;
|
|
81
|
-
const db = getDB(ctx, dataSource) || ctx.db;
|
|
82
|
-
const model = db.getModel(collection);
|
|
83
|
-
const data = await model.findAll(queryParams);
|
|
84
|
-
ctx.action.params.values = {
|
|
85
|
-
data,
|
|
86
|
-
fieldMap
|
|
87
|
-
};
|
|
88
|
-
await next();
|
|
89
|
-
};
|
|
90
|
-
const parseBuilder = async (ctx, next) => {
|
|
91
|
-
const { dataSource, measures, dimensions, orders, include, where, limit } = ctx.action.params.values;
|
|
92
|
-
const db = getDB(ctx, dataSource) || ctx.db;
|
|
93
|
-
const { sequelize } = db;
|
|
94
|
-
const attributes = [];
|
|
95
|
-
const group = [];
|
|
96
|
-
const order = [];
|
|
97
|
-
const fieldMap = {};
|
|
98
|
-
let hasAgg = false;
|
|
99
|
-
measures.forEach((measure) => {
|
|
100
|
-
const { field, aggregation, alias } = measure;
|
|
101
|
-
const attribute = [];
|
|
102
|
-
const col = sequelize.col(field);
|
|
103
|
-
if (aggregation) {
|
|
104
|
-
if (!AllowedAggFuncs.includes(aggregation)) {
|
|
105
|
-
throw new Error(`Invalid aggregation function: ${aggregation}`);
|
|
106
|
-
}
|
|
107
|
-
hasAgg = true;
|
|
108
|
-
attribute.push(sequelize.fn(aggregation, col));
|
|
109
|
-
} else {
|
|
110
|
-
attribute.push(col);
|
|
111
|
-
}
|
|
112
|
-
if (alias) {
|
|
113
|
-
attribute.push(alias);
|
|
114
|
-
}
|
|
115
|
-
attributes.push(attribute.length > 1 ? attribute : attribute[0]);
|
|
116
|
-
fieldMap[alias || field] = measure;
|
|
117
|
-
});
|
|
118
|
-
dimensions.forEach((dimension) => {
|
|
119
|
-
const { field, format, alias, type } = dimension;
|
|
120
|
-
const attribute = [];
|
|
121
|
-
const col = sequelize.col(field);
|
|
122
|
-
if (format) {
|
|
123
|
-
attribute.push((0, import_formatter.formatter)(sequelize, type, field, format, ctx.timezone));
|
|
124
|
-
} else {
|
|
125
|
-
attribute.push(col);
|
|
126
|
-
}
|
|
127
|
-
if (alias) {
|
|
128
|
-
attribute.push(alias);
|
|
129
|
-
}
|
|
130
|
-
attributes.push(attribute.length > 1 ? attribute : attribute[0]);
|
|
131
|
-
if (hasAgg) {
|
|
132
|
-
group.push(attribute[0]);
|
|
133
|
-
}
|
|
134
|
-
fieldMap[alias || field] = dimension;
|
|
135
|
-
});
|
|
136
|
-
orders.forEach((item) => {
|
|
137
|
-
const alias = sequelize.getQueryInterface().quoteIdentifier(item.alias);
|
|
138
|
-
const name = hasAgg ? sequelize.literal(alias) : sequelize.col(item.field);
|
|
139
|
-
order.push([name, item.order || "ASC"]);
|
|
140
|
-
});
|
|
141
|
-
ctx.action.params.values = {
|
|
142
|
-
...ctx.action.params.values,
|
|
143
|
-
queryParams: {
|
|
144
|
-
where,
|
|
145
|
-
attributes,
|
|
146
|
-
include,
|
|
147
|
-
group,
|
|
148
|
-
order,
|
|
149
|
-
limit: limit || 2e3,
|
|
150
|
-
subQuery: false,
|
|
151
|
-
raw: true
|
|
152
|
-
},
|
|
153
|
-
fieldMap
|
|
154
|
-
};
|
|
155
|
-
await next();
|
|
156
|
-
};
|
|
157
|
-
const parseFieldAndAssociations = async (ctx, next) => {
|
|
158
|
-
const {
|
|
159
|
-
dataSource,
|
|
160
|
-
collection: collectionName,
|
|
161
|
-
measures,
|
|
162
|
-
dimensions,
|
|
163
|
-
orders,
|
|
164
|
-
filter
|
|
165
|
-
} = ctx.action.params.values;
|
|
166
|
-
const db = getDB(ctx, dataSource) || ctx.db;
|
|
167
|
-
const collection = db.getCollection(collectionName);
|
|
168
|
-
const fields = collection.fields;
|
|
169
|
-
const models = {};
|
|
170
|
-
const parseField = (selected) => {
|
|
171
|
-
var _a, _b, _c, _d;
|
|
172
|
-
let target;
|
|
173
|
-
let name;
|
|
174
|
-
if (!Array.isArray(selected.field)) {
|
|
175
|
-
name = selected.field;
|
|
176
|
-
} else if (selected.field.length === 1) {
|
|
177
|
-
name = selected.field[0];
|
|
178
|
-
} else if (selected.field.length > 1) {
|
|
179
|
-
[target, name] = selected.field;
|
|
180
|
-
}
|
|
181
|
-
const rawAttributes = collection.model.getAttributes();
|
|
182
|
-
let field = ((_a = rawAttributes[name]) == null ? void 0 : _a.field) || name;
|
|
183
|
-
let fieldType = (_b = fields.get(name)) == null ? void 0 : _b.type;
|
|
184
|
-
if (target) {
|
|
185
|
-
const targetField = fields.get(target);
|
|
186
|
-
const targetCollection = db.getCollection(targetField.target);
|
|
187
|
-
const targetFields = targetCollection.fields;
|
|
188
|
-
fieldType = (_c = targetFields.get(name)) == null ? void 0 : _c.type;
|
|
189
|
-
field = `${target}.${field}`;
|
|
190
|
-
name = `${target}.${name}`;
|
|
191
|
-
const targetType = (_d = fields.get(target)) == null ? void 0 : _d.type;
|
|
192
|
-
if (!models[target]) {
|
|
193
|
-
models[target] = { type: targetType };
|
|
194
|
-
}
|
|
195
|
-
} else {
|
|
196
|
-
field = `${collectionName}.${field}`;
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
...selected,
|
|
200
|
-
field,
|
|
201
|
-
name,
|
|
202
|
-
type: fieldType,
|
|
203
|
-
alias: selected.alias || name
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
const parsedMeasures = (measures == null ? void 0 : measures.map(parseField)) || [];
|
|
207
|
-
const parsedDimensions = (dimensions == null ? void 0 : dimensions.map(parseField)) || [];
|
|
208
|
-
const parsedOrders = (orders == null ? void 0 : orders.map(parseField)) || [];
|
|
209
|
-
const include = Object.entries(models).map(([target, { type }]) => ({
|
|
210
|
-
association: target,
|
|
211
|
-
attributes: [],
|
|
212
|
-
...type === "belongsToMany" ? { through: { attributes: [] } } : {}
|
|
213
|
-
}));
|
|
214
|
-
const filterParser = new import_database.FilterParser(filter, {
|
|
215
|
-
collection
|
|
216
|
-
});
|
|
217
|
-
const { where, include: filterInclude } = filterParser.toSequelizeParams();
|
|
218
|
-
const parsedFilterInclude = filterInclude == null ? void 0 : filterInclude.map((item) => {
|
|
219
|
-
var _a;
|
|
220
|
-
if (((_a = fields.get(item.association)) == null ? void 0 : _a.type) === "belongsToMany") {
|
|
221
|
-
item.through = { attributes: [] };
|
|
222
|
-
}
|
|
223
|
-
return item;
|
|
224
|
-
});
|
|
225
|
-
ctx.action.params.values = {
|
|
226
|
-
...ctx.action.params.values,
|
|
227
|
-
where,
|
|
228
|
-
measures: parsedMeasures,
|
|
229
|
-
dimensions: parsedDimensions,
|
|
230
|
-
orders: parsedOrders,
|
|
231
|
-
include: [...include, ...parsedFilterInclude || []]
|
|
232
|
-
};
|
|
233
|
-
await next();
|
|
234
|
-
};
|
|
235
|
-
const parseVariables = async (ctx, next) => {
|
|
236
|
-
const { filter } = ctx.action.params.values;
|
|
237
|
-
ctx.action.params.filter = filter;
|
|
238
|
-
await import_server.middlewares.parseVariables(ctx, async () => {
|
|
239
|
-
ctx.action.params.values.filter = ctx.action.params.filter;
|
|
240
|
-
await next();
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
const cacheMiddleware = async (ctx, next) => {
|
|
244
|
-
const { uid, cache: cacheConfig, refresh } = ctx.action.params.values;
|
|
245
|
-
const cache = ctx.app.cacheManager.getCache("data-visualization");
|
|
246
|
-
const useCache = (cacheConfig == null ? void 0 : cacheConfig.enabled) && uid;
|
|
247
|
-
if (useCache && !refresh) {
|
|
248
|
-
const data = await cache.get(uid);
|
|
249
|
-
if (data) {
|
|
250
|
-
ctx.body = data;
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
await next();
|
|
255
|
-
if (useCache) {
|
|
256
|
-
await cache.set(uid, ctx.body, (cacheConfig == null ? void 0 : cacheConfig.ttl) * 1e3);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
const checkPermission = (ctx, next) => {
|
|
260
|
-
const { collection } = ctx.action.params.values;
|
|
261
|
-
const roleName = ctx.state.currentRole || "anonymous";
|
|
262
|
-
const can = ctx.app.acl.can({ role: roleName, resource: collection, action: "list" });
|
|
263
|
-
if (!can && roleName !== "root") {
|
|
264
|
-
ctx.throw(403, "No permissions");
|
|
265
|
-
}
|
|
266
|
-
return next();
|
|
267
|
-
};
|
|
268
|
-
const query = async (ctx, next) => {
|
|
269
|
-
try {
|
|
270
|
-
await (0, import_koa_compose.default)([
|
|
271
|
-
checkPermission,
|
|
272
|
-
cacheMiddleware,
|
|
273
|
-
parseVariables,
|
|
274
|
-
parseFieldAndAssociations,
|
|
275
|
-
parseBuilder,
|
|
276
|
-
queryData,
|
|
277
|
-
postProcess
|
|
278
|
-
])(ctx, next);
|
|
279
|
-
} catch (err) {
|
|
280
|
-
ctx.throw(500, err);
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
284
|
-
0 && (module.exports = {
|
|
285
|
-
cacheMiddleware,
|
|
286
|
-
checkPermission,
|
|
287
|
-
parseBuilder,
|
|
288
|
-
parseFieldAndAssociations,
|
|
289
|
-
parseVariables,
|
|
290
|
-
postProcess,
|
|
291
|
-
query,
|
|
292
|
-
queryData
|
|
293
|
-
});
|
package/dist/server/index.d.ts
DELETED
|
@@ -1,9 +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
|
-
export { default } from './plugin';
|
package/dist/server/index.js
DELETED
|
@@ -1,42 +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 __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 server_exports = {};
|
|
38
|
-
__export(server_exports, {
|
|
39
|
-
default: () => import_plugin.default
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(server_exports);
|
|
42
|
-
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -1,13 +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 { Migration } from '@nocobase/server';
|
|
10
|
-
export default class RenameChartTypeMigration extends Migration {
|
|
11
|
-
appVersion: string;
|
|
12
|
-
up(): Promise<void>;
|
|
13
|
-
}
|
|
@@ -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 rename_charttype_exports = {};
|
|
28
|
-
__export(rename_charttype_exports, {
|
|
29
|
-
default: () => RenameChartTypeMigration
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(rename_charttype_exports);
|
|
32
|
-
var import_server = require("@nocobase/server");
|
|
33
|
-
class RenameChartTypeMigration extends import_server.Migration {
|
|
34
|
-
appVersion = "<0.14.0-alpha.7";
|
|
35
|
-
async up() {
|
|
36
|
-
const result = await this.app.version.satisfies("<=0.14.0-alpha.7");
|
|
37
|
-
if (!result) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const r = this.db.getRepository("uiSchemas");
|
|
41
|
-
const items = await r.find({
|
|
42
|
-
filter: {
|
|
43
|
-
"schema.x-decorator": "ChartRendererProvider"
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
await this.db.sequelize.transaction(async (transaction) => {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
for (const item of items) {
|
|
49
|
-
const schema = item.schema;
|
|
50
|
-
const chartType = (_b = (_a = schema["x-decorator-props"]) == null ? void 0 : _a.config) == null ? void 0 : _b.chartType;
|
|
51
|
-
if (!chartType || chartType.startsWith("Built-in.")) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
schema["x-decorator-props"].config.chartType = `Built-in.${chartType}`;
|
|
55
|
-
item.set("schema", schema);
|
|
56
|
-
await item.save({ transaction });
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
package/dist/server/plugin.d.ts
DELETED
|
@@ -1,21 +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 { Cache } from '@nocobase/cache';
|
|
10
|
-
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
11
|
-
export declare class PluginDataVisualizationServer extends Plugin {
|
|
12
|
-
cache: Cache;
|
|
13
|
-
afterAdd(): void;
|
|
14
|
-
beforeLoad(): void;
|
|
15
|
-
load(): Promise<void>;
|
|
16
|
-
install(options?: InstallOptions): Promise<void>;
|
|
17
|
-
afterEnable(): Promise<void>;
|
|
18
|
-
afterDisable(): Promise<void>;
|
|
19
|
-
remove(): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
export default PluginDataVisualizationServer;
|
package/dist/server/plugin.js
DELETED
|
@@ -1,70 +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 plugin_exports = {};
|
|
28
|
-
__export(plugin_exports, {
|
|
29
|
-
PluginDataVisualizationServer: () => PluginDataVisualizationServer,
|
|
30
|
-
default: () => plugin_default
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(plugin_exports);
|
|
33
|
-
var import_server = require("@nocobase/server");
|
|
34
|
-
var import_query = require("./actions/query");
|
|
35
|
-
class PluginDataVisualizationServer extends import_server.Plugin {
|
|
36
|
-
cache;
|
|
37
|
-
afterAdd() {
|
|
38
|
-
}
|
|
39
|
-
beforeLoad() {
|
|
40
|
-
this.app.resource({
|
|
41
|
-
name: "charts",
|
|
42
|
-
actions: {
|
|
43
|
-
query: import_query.query
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
this.app.acl.allow("charts", "query", "loggedIn");
|
|
47
|
-
}
|
|
48
|
-
async load() {
|
|
49
|
-
this.cache = await this.app.cacheManager.createCache({
|
|
50
|
-
name: "data-visualization",
|
|
51
|
-
store: "memory",
|
|
52
|
-
ttl: 30 * 1e3,
|
|
53
|
-
// millseconds
|
|
54
|
-
max: 1e3
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
async install(options) {
|
|
58
|
-
}
|
|
59
|
-
async afterEnable() {
|
|
60
|
-
}
|
|
61
|
-
async afterDisable() {
|
|
62
|
-
}
|
|
63
|
-
async remove() {
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
var plugin_default = PluginDataVisualizationServer;
|
|
67
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
-
0 && (module.exports = {
|
|
69
|
-
PluginDataVisualizationServer
|
|
70
|
-
});
|
package/dist/swagger/index.d.ts
DELETED
|
@@ -1,16 +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
|
-
declare const _default: {
|
|
10
|
-
info: {
|
|
11
|
-
title: string;
|
|
12
|
-
};
|
|
13
|
-
tags: any[];
|
|
14
|
-
paths: {};
|
|
15
|
-
};
|
|
16
|
-
export default _default;
|
package/dist/swagger/index.js
DELETED
|
@@ -1,38 +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 swagger_exports = {};
|
|
28
|
-
__export(swagger_exports, {
|
|
29
|
-
default: () => swagger_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(swagger_exports);
|
|
32
|
-
var swagger_default = {
|
|
33
|
-
info: {
|
|
34
|
-
title: "NocoBase API - Data visualization plugin"
|
|
35
|
-
},
|
|
36
|
-
tags: [],
|
|
37
|
-
paths: {}
|
|
38
|
-
};
|