@nocobase/plugin-data-visualization 0.20.0-alpha.9 → 0.21.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/client/block/ChartBlockInitializer.d.ts +7 -2
  2. package/dist/client/block/ChartDataProvider.d.ts +1 -0
  3. package/dist/client/chart/chart.d.ts +7 -7
  4. package/dist/client/chart/configs.d.ts +11 -0
  5. package/dist/client/chart/g2plot/AntChart.d.ts +2 -0
  6. package/dist/client/chart/g2plot/dualAxes.d.ts +3 -2
  7. package/dist/client/chart/g2plot/g2plot.d.ts +1 -1
  8. package/dist/client/chart/g2plot/pie.d.ts +2 -1
  9. package/dist/client/chart/group.d.ts +24 -0
  10. package/dist/client/configure/TransformerDynamicComponent.d.ts +4 -0
  11. package/dist/client/filter/CollectionFieldInitializer.d.ts +2 -0
  12. package/dist/client/filter/FilterActionInitializers.d.ts +7 -2
  13. package/dist/client/filter/FilterItemInitializers.d.ts +7 -2
  14. package/dist/client/filter/FilterProvider.d.ts +10 -11
  15. package/dist/client/filter/utils.d.ts +8 -0
  16. package/dist/client/hooks/filter.d.ts +24 -6
  17. package/dist/client/hooks/query.d.ts +13 -118
  18. package/dist/client/hooks/transformer.d.ts +14 -7
  19. package/dist/client/index.d.ts +3 -3
  20. package/dist/client/index.js +128 -110
  21. package/dist/client/renderer/ChartRendererProvider.d.ts +1 -0
  22. package/dist/client/transformers.d.ts +12 -0
  23. package/dist/client/utils.d.ts +2 -0
  24. package/dist/externalVersion.js +7 -7
  25. package/dist/locale/en-US.json +8 -1
  26. package/dist/locale/zh-CN.json +8 -1
  27. package/dist/node_modules/koa-compose/package.json +1 -1
  28. package/dist/server/actions/formatter.js +1 -0
  29. package/dist/server/actions/query.d.ts +1 -0
  30. package/dist/server/actions/query.js +23 -7
  31. package/dist/server/plugin.d.ts +2 -2
  32. package/dist/server/plugin.js +4 -4
  33. package/package.json +3 -3
  34. package/dist/client/block/transformers.d.ts +0 -7
  35. /package/dist/client/{block → configure}/formatters.d.ts +0 -0
@@ -13,6 +13,7 @@ export type TransformProps = {
13
13
  field: string;
14
14
  type: string;
15
15
  format: string;
16
+ argument?: string | number;
16
17
  };
17
18
  export type QueryProps = Partial<{
18
19
  measures: MeasureProps[];
@@ -0,0 +1,12 @@
1
+ export type Transformer = (val: any, ...args: any[]) => string | number;
2
+ export type TransformerConfig = Transformer | {
3
+ label?: string;
4
+ schema?: any;
5
+ fn: Transformer;
6
+ };
7
+ declare const transformers: {
8
+ [key: string]: {
9
+ [key: string]: TransformerConfig;
10
+ };
11
+ };
12
+ export default transformers;
@@ -9,6 +9,8 @@ export declare const createRendererSchema: (decoratorProps: any, componentProps?
9
9
  'x-component': string;
10
10
  'x-component-props': {
11
11
  size: string;
12
+ title: any;
13
+ bordered: any;
12
14
  };
13
15
  'x-initializer': string;
14
16
  properties: {
@@ -1,20 +1,20 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.20.0-alpha.9",
2
+ "@nocobase/client": "0.21.0-alpha.10",
3
+ "dayjs": "1.11.10",
3
4
  "@formily/react": "2.3.0",
4
5
  "@formily/shared": "2.3.0",
5
6
  "lodash": "4.17.21",
6
- "@nocobase/cache": "0.20.0-alpha.9",
7
- "@nocobase/server": "0.20.0-alpha.9",
7
+ "@nocobase/cache": "0.21.0-alpha.10",
8
+ "@nocobase/server": "0.21.0-alpha.10",
8
9
  "react": "18.2.0",
9
10
  "@ant-design/icons": "5.2.6",
10
11
  "ahooks": "3.7.8",
11
- "dayjs": "1.11.10",
12
12
  "@emotion/css": "11.11.2",
13
13
  "antd": "5.12.8",
14
14
  "@formily/antd-v5": "1.1.9",
15
15
  "@formily/core": "2.3.0",
16
- "@nocobase/utils": "0.20.0-alpha.9",
17
- "@nocobase/database": "0.20.0-alpha.9",
16
+ "@nocobase/utils": "0.21.0-alpha.10",
18
17
  "react-i18next": "11.18.6",
19
- "@nocobase/actions": "0.20.0-alpha.9"
18
+ "@nocobase/actions": "0.21.0-alpha.10",
19
+ "@nocobase/database": "0.21.0-alpha.10"
20
20
  };
@@ -80,5 +80,12 @@
80
80
  "Time range": "Time range",
81
81
  "Edit field properties": "Edit field properties",
82
82
  "Select a source field to use metadata of the field": "Select a source field to use metadata of the field",
83
- "Original field": "Original field"
83
+ "Original field": "Original field",
84
+ "Transformation": "Transformation",
85
+ "Add transformation": "Add transformation",
86
+ "Container": "Container",
87
+ "Show border": "Show border",
88
+ "Transformation tip": "Fields allow multiple transformations, applied sequentially. Pay attention to data type changes after each transformation. Drag-and-drop functionality enables adjustment of transformation order.",
89
+ "Type conversion": "Type conversion",
90
+ "Transformer": "Transformer"
84
91
  }
@@ -81,5 +81,12 @@
81
81
  "Time range": "时间范围",
82
82
  "Edit field properties": "编辑字段属性",
83
83
  "Select a source field to use metadata of the field": "选择来源字段可以复用字段的元数据配置",
84
- "Original field": "原始字段"
84
+ "Original field": "原始字段",
85
+ "Transformation": "数据转换",
86
+ "Add transformation": "添加数据转换",
87
+ "Container": "容器",
88
+ "Show border": "显示边框",
89
+ "Transformation tip": "一个字段可以应用多次转换,会按照顺序执行,请注意每次转换后的数据类型,拖动可以调整转换顺序。",
90
+ "Type conversion": "类型转换",
91
+ "Transformer": "转换方法"
85
92
  }
@@ -1 +1 @@
1
- {"name":"koa-compose","description":"compose Koa middleware","repository":"koajs/compose","version":"4.1.0","keywords":["koa","middleware","compose"],"files":["index.js"],"dependencies":{},"devDependencies":{"codecov":"^3.0.0","jest":"^21.0.0","matcha":"^0.7.0","standard":"^10.0.3"},"scripts":{"bench":"matcha bench/bench.js","lint":"standard --fix .","test":"jest --forceExit --coverage"},"jest":{"testEnvironment":"node"},"license":"MIT","_lastModified":"2024-03-12T13:23:16.143Z"}
1
+ {"name":"koa-compose","description":"compose Koa middleware","repository":"koajs/compose","version":"4.1.0","keywords":["koa","middleware","compose"],"files":["index.js"],"dependencies":{},"devDependencies":{"codecov":"^3.0.0","jest":"^21.0.0","matcha":"^0.7.0","standard":"^10.0.3"},"scripts":{"bench":"matcha bench/bench.js","lint":"standard --fix .","test":"jest --forceExit --coverage"},"jest":{"testEnvironment":"node"},"license":"MIT","_lastModified":"2024-04-16T16:08:33.460Z"}
@@ -38,6 +38,7 @@ const dateFormatFn = (sequelize, dialect, field, format) => {
38
38
  return sequelize.col(field);
39
39
  }
40
40
  };
41
+ /* istanbul ignore next -- @preserve */
41
42
  const formatFn = (sequelize, dialect, field, format) => {
42
43
  switch (dialect) {
43
44
  case "sqlite":
@@ -5,4 +5,5 @@ export declare const parseBuilder: (ctx: Context, next: Next) => Promise<void>;
5
5
  export declare const parseFieldAndAssociations: (ctx: Context, next: Next) => Promise<void>;
6
6
  export declare const parseVariables: (ctx: Context, next: Next) => Promise<any>;
7
7
  export declare const cacheMiddleware: (ctx: Context, next: Next) => Promise<void>;
8
+ export declare const checkPermission: (ctx: Context, next: Next) => Promise<any>;
8
9
  export declare const query: (ctx: Context, next: Next) => Promise<void>;
@@ -28,6 +28,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
28
28
  var query_exports = {};
29
29
  __export(query_exports, {
30
30
  cacheMiddleware: () => cacheMiddleware,
31
+ checkPermission: () => checkPermission,
31
32
  parseBuilder: () => parseBuilder,
32
33
  parseFieldAndAssociations: () => parseFieldAndAssociations,
33
34
  parseVariables: () => parseVariables,
@@ -40,6 +41,10 @@ var import_database = require("@nocobase/database");
40
41
  var import_formatter = require("./formatter");
41
42
  var import_koa_compose = __toESM(require("koa-compose"));
42
43
  var import_utils = require("@nocobase/utils");
44
+ const getDB = (ctx, dataSource) => {
45
+ const ds = ctx.app.dataSourceManager.dataSources.get(dataSource);
46
+ return ds == null ? void 0 : ds.collectionManager.db;
47
+ };
43
48
  const postProcess = async (ctx, next) => {
44
49
  const { data, fieldMap } = ctx.action.params.values;
45
50
  ctx.body = data.map((record) => {
@@ -62,8 +67,9 @@ const postProcess = async (ctx, next) => {
62
67
  await next();
63
68
  };
64
69
  const queryData = async (ctx, next) => {
65
- const { collection, queryParams, fieldMap } = ctx.action.params.values;
66
- const model = ctx.db.getModel(collection);
70
+ const { dataSource, collection, queryParams, fieldMap } = ctx.action.params.values;
71
+ const db = getDB(ctx, dataSource) || ctx.db;
72
+ const model = db.getModel(collection);
67
73
  const data = await model.findAll(queryParams);
68
74
  ctx.action.params.values = {
69
75
  data,
@@ -72,8 +78,9 @@ const queryData = async (ctx, next) => {
72
78
  await next();
73
79
  };
74
80
  const parseBuilder = async (ctx, next) => {
75
- const { sequelize } = ctx.db;
76
- const { measures, dimensions, orders, include, where, limit } = ctx.action.params.values;
81
+ const { dataSource, measures, dimensions, orders, include, where, limit } = ctx.action.params.values;
82
+ const db = getDB(ctx, dataSource) || ctx.db;
83
+ const { sequelize } = db;
77
84
  const attributes = [];
78
85
  const group = [];
79
86
  const order = [];
@@ -135,8 +142,16 @@ const parseBuilder = async (ctx, next) => {
135
142
  await next();
136
143
  };
137
144
  const parseFieldAndAssociations = async (ctx, next) => {
138
- const { collection: collectionName, measures, dimensions, orders, filter } = ctx.action.params.values;
139
- const collection = ctx.db.getCollection(collectionName);
145
+ const {
146
+ dataSource,
147
+ collection: collectionName,
148
+ measures,
149
+ dimensions,
150
+ orders,
151
+ filter
152
+ } = ctx.action.params.values;
153
+ const db = getDB(ctx, dataSource) || ctx.db;
154
+ const collection = db.getCollection(collectionName);
140
155
  const fields = collection.fields;
141
156
  const models = {};
142
157
  const parseField = (selected) => {
@@ -155,7 +170,7 @@ const parseFieldAndAssociations = async (ctx, next) => {
155
170
  let fieldType = (_b = fields.get(name)) == null ? void 0 : _b.type;
156
171
  if (target) {
157
172
  const targetField = fields.get(target);
158
- const targetCollection = ctx.db.getCollection(targetField.target);
173
+ const targetCollection = db.getCollection(targetField.target);
159
174
  const targetFields = targetCollection.fields;
160
175
  fieldType = (_c = targetFields.get(name)) == null ? void 0 : _c.type;
161
176
  field = `${target}.${field}`;
@@ -296,6 +311,7 @@ const query = async (ctx, next) => {
296
311
  // Annotate the CommonJS export names for ESM import in node:
297
312
  0 && (module.exports = {
298
313
  cacheMiddleware,
314
+ checkPermission,
299
315
  parseBuilder,
300
316
  parseFieldAndAssociations,
301
317
  parseVariables,
@@ -1,6 +1,6 @@
1
1
  import { Cache } from '@nocobase/cache';
2
2
  import { InstallOptions, Plugin } from '@nocobase/server';
3
- export declare class DataVisualizationPlugin extends Plugin {
3
+ export declare class PluginDataVisualizationServer extends Plugin {
4
4
  cache: Cache;
5
5
  afterAdd(): void;
6
6
  beforeLoad(): void;
@@ -10,4 +10,4 @@ export declare class DataVisualizationPlugin extends Plugin {
10
10
  afterDisable(): Promise<void>;
11
11
  remove(): Promise<void>;
12
12
  }
13
- export default DataVisualizationPlugin;
13
+ export default PluginDataVisualizationServer;
@@ -17,14 +17,14 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var plugin_exports = {};
19
19
  __export(plugin_exports, {
20
- DataVisualizationPlugin: () => DataVisualizationPlugin,
20
+ PluginDataVisualizationServer: () => PluginDataVisualizationServer,
21
21
  default: () => plugin_default
22
22
  });
23
23
  module.exports = __toCommonJS(plugin_exports);
24
24
  var import_server = require("@nocobase/server");
25
25
  var import_query = require("./actions/query");
26
26
  var import_path = require("path");
27
- class DataVisualizationPlugin extends import_server.Plugin {
27
+ class PluginDataVisualizationServer extends import_server.Plugin {
28
28
  cache;
29
29
  afterAdd() {
30
30
  }
@@ -62,8 +62,8 @@ class DataVisualizationPlugin extends import_server.Plugin {
62
62
  async remove() {
63
63
  }
64
64
  }
65
- var plugin_default = DataVisualizationPlugin;
65
+ var plugin_default = PluginDataVisualizationServer;
66
66
  // Annotate the CommonJS export names for ESM import in node:
67
67
  0 && (module.exports = {
68
- DataVisualizationPlugin
68
+ PluginDataVisualizationServer
69
69
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-visualization",
3
- "version": "0.20.0-alpha.9",
3
+ "version": "0.21.0-alpha.10",
4
4
  "displayName": "Data visualization",
5
5
  "displayName.zh-CN": "数据可视化",
6
6
  "description": "Provides data visualization feature, including chart block and chart filter block, support line charts, area charts, bar charts and more than a dozen kinds of charts, you can also extend more chart types.",
@@ -10,7 +10,7 @@
10
10
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/data-visualization",
11
11
  "devDependencies": {
12
12
  "@ant-design/icons": "5.x",
13
- "@ant-design/plots": "^1.2.5",
13
+ "@ant-design/plots": "^2.1.4",
14
14
  "@emotion/css": "^11.7.1",
15
15
  "@formily/antd-v5": "1.x",
16
16
  "@formily/core": "2.x",
@@ -33,7 +33,7 @@
33
33
  "@nocobase/test": "0.x",
34
34
  "@nocobase/utils": "0.x"
35
35
  },
36
- "gitHead": "5473d9039cfdb649a8c8c625edefc9a3ac464be5",
36
+ "gitHead": "98adf5ec996a4f359c6ca1c4a6ac837c43b6e268",
37
37
  "keywords": [
38
38
  "Blocks"
39
39
  ]
@@ -1,7 +0,0 @@
1
- export type Transformer = (val: any, locale?: string) => string | number;
2
- declare const transformers: {
3
- [key: string]: {
4
- [key: string]: Transformer;
5
- };
6
- };
7
- export default transformers;