@nocobase/plugin-data-visualization
Advanced tools
Comparing version 1.4.0-alpha.20241020033334 to 1.4.0-alpha.20241023053303
@@ -11,3 +11,3 @@ /** | ||
module.exports = { | ||
"@nocobase/client": "1.4.0-alpha.20241020033334", | ||
"@nocobase/client": "1.4.0-alpha.20241023053303", | ||
"dayjs": "1.11.10", | ||
@@ -18,5 +18,5 @@ "@formily/react": "2.3.0", | ||
"react": "18.2.0", | ||
"@nocobase/cache": "1.4.0-alpha.20241020033334", | ||
"@nocobase/server": "1.4.0-alpha.20241020033334", | ||
"@nocobase/test": "1.4.0-alpha.20241020033334", | ||
"@nocobase/cache": "1.4.0-alpha.20241023053303", | ||
"@nocobase/server": "1.4.0-alpha.20241023053303", | ||
"@nocobase/test": "1.4.0-alpha.20241023053303", | ||
"@emotion/css": "11.13.0", | ||
@@ -28,7 +28,7 @@ "@ant-design/icons": "5.2.6", | ||
"@formily/core": "2.3.0", | ||
"@nocobase/utils": "1.4.0-alpha.20241020033334", | ||
"@nocobase/utils": "1.4.0-alpha.20241023053303", | ||
"react-i18next": "11.18.6", | ||
"@nocobase/actions": "1.4.0-alpha.20241020033334", | ||
"@nocobase/database": "1.4.0-alpha.20241020033334", | ||
"@nocobase/actions": "1.4.0-alpha.20241023053303", | ||
"@nocobase/database": "1.4.0-alpha.20241023053303", | ||
"sequelize": "6.35.2" | ||
}; |
@@ -1,1 +0,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-10-20T03:45:07.039Z"} | ||
{"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-10-23T05:46:47.123Z"} |
@@ -1,1 +0,1 @@ | ||
{"name":"moment-timezone","version":"0.5.43","description":"Parse and display moments in any timezone.","homepage":"http://momentjs.com/timezone/","author":"Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)","keywords":["moment","date","time","timezone","olson","iana","zone","tz"],"main":"./index.js","typings":"./index.d.ts","engines":{"node":"*"},"repository":{"type":"git","url":"https://github.com/moment/moment-timezone.git"},"bugs":{"url":"https://github.com/moment/moment-timezone/issues"},"license":"MIT","dependencies":{"moment":"^2.29.4"},"devDependencies":{"grunt":"^1.5.3","grunt-contrib-clean":"^2.0.1","grunt-contrib-jshint":"^3.2.0","grunt-contrib-nodeunit":"^4.0.0","grunt-contrib-uglify":"^5.2.2","grunt-exec":"^3.0.0","typescript":"^3.5.1"},"jspm":{"main":"builds/moment-timezone-with-data","shim":{"moment-timezone":{"deps":["moment"]}}},"scripts":{"test":"grunt"},"_lastModified":"2024-10-20T03:45:07.723Z"} | ||
{"name":"moment-timezone","version":"0.5.43","description":"Parse and display moments in any timezone.","homepage":"http://momentjs.com/timezone/","author":"Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)","keywords":["moment","date","time","timezone","olson","iana","zone","tz"],"main":"./index.js","typings":"./index.d.ts","engines":{"node":"*"},"repository":{"type":"git","url":"https://github.com/moment/moment-timezone.git"},"bugs":{"url":"https://github.com/moment/moment-timezone/issues"},"license":"MIT","dependencies":{"moment":"^2.29.4"},"devDependencies":{"grunt":"^1.5.3","grunt-contrib-clean":"^2.0.1","grunt-contrib-jshint":"^3.2.0","grunt-contrib-nodeunit":"^4.0.0","grunt-contrib-uglify":"^5.2.2","grunt-exec":"^3.0.0","typescript":"^3.5.1"},"jspm":{"main":"builds/moment-timezone-with-data","shim":{"moment-timezone":{"deps":["moment"]}}},"scripts":{"test":"grunt"},"_lastModified":"2024-10-23T05:46:47.875Z"} |
@@ -12,3 +12,2 @@ /** | ||
export declare const queryData: (ctx: Context, next: Next) => Promise<void>; | ||
export declare const parseBuilder: (ctx: Context, next: Next) => Promise<void>; | ||
export declare const parseFieldAndAssociations: (ctx: Context, next: Next) => Promise<void>; | ||
@@ -15,0 +14,0 @@ export declare const parseVariables: (ctx: Context, next: Next) => Promise<void>; |
@@ -41,3 +41,2 @@ /** | ||
checkPermission: () => checkPermission, | ||
parseBuilder: () => parseBuilder, | ||
parseFieldAndAssociations: () => parseFieldAndAssociations, | ||
@@ -53,4 +52,3 @@ parseVariables: () => parseVariables, | ||
var import_server = require("@nocobase/server"); | ||
var import_formatter = require("../formatter"); | ||
const AllowedAggFuncs = ["sum", "count", "avg", "min", "max"]; | ||
var import_query_parser = require("../query-parser"); | ||
const getDB = (ctx, dataSource) => { | ||
@@ -93,70 +91,2 @@ const ds = ctx.app.dataSourceManager.dataSources.get(dataSource); | ||
}; | ||
const parseBuilder = async (ctx, next) => { | ||
const { dataSource, measures, dimensions, orders, include, where, limit } = ctx.action.params.values; | ||
const db = getDB(ctx, dataSource) || ctx.db; | ||
const { sequelize } = db; | ||
const attributes = []; | ||
const group = []; | ||
const order = []; | ||
const fieldMap = {}; | ||
let hasAgg = false; | ||
measures.forEach((measure) => { | ||
const { field, aggregation, alias, distinct } = measure; | ||
const attribute = []; | ||
const col = sequelize.col(field); | ||
if (aggregation) { | ||
if (!AllowedAggFuncs.includes(aggregation)) { | ||
throw new Error(`Invalid aggregation function: ${aggregation}`); | ||
} | ||
hasAgg = true; | ||
attribute.push(sequelize.fn(aggregation, distinct ? sequelize.fn("DISTINCT", col) : col)); | ||
} else { | ||
attribute.push(col); | ||
} | ||
if (alias) { | ||
attribute.push(alias); | ||
} | ||
attributes.push(attribute.length > 1 ? attribute : attribute[0]); | ||
fieldMap[alias || field] = measure; | ||
}); | ||
dimensions.forEach((dimension) => { | ||
const { field, format, alias, type, options } = dimension; | ||
const attribute = []; | ||
const col = sequelize.col(field); | ||
if (format) { | ||
const formatter = (0, import_formatter.createFormatter)(sequelize); | ||
attribute.push(formatter.format({ type, field, format, timezone: ctx.timezone, options })); | ||
} else { | ||
attribute.push(col); | ||
} | ||
if (alias) { | ||
attribute.push(alias); | ||
} | ||
attributes.push(attribute.length > 1 ? attribute : attribute[0]); | ||
if (hasAgg) { | ||
group.push(attribute[0]); | ||
} | ||
fieldMap[alias || field] = dimension; | ||
}); | ||
orders.forEach((item) => { | ||
const alias = sequelize.getQueryInterface().quoteIdentifier(item.alias); | ||
const name = hasAgg ? sequelize.literal(alias) : sequelize.col(item.field); | ||
order.push([name, item.order || "ASC"]); | ||
}); | ||
ctx.action.params.values = { | ||
...ctx.action.params.values, | ||
queryParams: { | ||
where, | ||
attributes, | ||
include, | ||
group, | ||
order, | ||
limit: limit || 2e3, | ||
subQuery: false, | ||
raw: true | ||
}, | ||
fieldMap | ||
}; | ||
await next(); | ||
}; | ||
const parseFieldAndAssociations = async (ctx, next) => { | ||
@@ -294,2 +224,5 @@ const { | ||
const query = async (ctx, next) => { | ||
const { dataSource } = ctx.action.params.values; | ||
const db = getDB(ctx, dataSource) || ctx.db; | ||
const queryParser = (0, import_query_parser.createQueryParser)(db); | ||
try { | ||
@@ -301,3 +234,3 @@ await (0, import_koa_compose.default)([ | ||
parseFieldAndAssociations, | ||
parseBuilder, | ||
queryParser.parse(), | ||
queryData, | ||
@@ -314,3 +247,2 @@ postProcess | ||
checkPermission, | ||
parseBuilder, | ||
parseFieldAndAssociations, | ||
@@ -317,0 +249,0 @@ parseVariables, |
@@ -40,3 +40,3 @@ /** | ||
beforeLoad() { | ||
this.app.resource({ | ||
this.app.resourceManager.define({ | ||
name: "charts", | ||
@@ -43,0 +43,0 @@ actions: { |
{ | ||
"name": "@nocobase/plugin-data-visualization", | ||
"version": "1.4.0-alpha.20241020033334", | ||
"version": "1.4.0-alpha.20241023053303", | ||
"displayName": "Data visualization", | ||
@@ -37,3 +37,3 @@ "displayName.zh-CN": "数据可视化", | ||
}, | ||
"gitHead": "e99a8cf94fd0cf26db7fe7f82745d6345d80c48b", | ||
"gitHead": "7c6272531f271094ddac219755ac898dd33ff5ab", | ||
"keywords": [ | ||
@@ -40,0 +40,0 @@ "Blocks" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5363230
137
27975