@nocobase/plugin-data-visualization 2.1.0-beta.8 → 2.2.0-alpha.1

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 (96) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/102.ae672a174b9de2c5.js +47 -0
  4. package/dist/client/176.0b68fc9582cfe5a3.js +10 -0
  5. package/dist/client/214.6dda3ffed1dca904.js +10 -0
  6. package/dist/client/680.c3725300a5f4414b.js +10 -0
  7. package/dist/client/index.js +1 -1
  8. package/dist/client-v2/176.8068b95175599050.js +10 -0
  9. package/dist/client-v2/214.a999212f348c0092.js +10 -0
  10. package/dist/client-v2/468.95cb9025bce70a9c.js +10 -0
  11. package/dist/client-v2/496.51bfbe09593275b9.js +10 -0
  12. package/dist/client-v2/680.a2c2838809485d36.js +10 -0
  13. package/dist/client-v2/chart/ChartGroup.d.ts +44 -0
  14. package/dist/client-v2/chart/configs.d.ts +290 -0
  15. package/dist/client-v2/chart/index.d.ts +11 -0
  16. package/dist/client-v2/chart/types.d.ts +102 -0
  17. package/dist/{client → client-v2}/flow/models/Chart.d.ts +2 -0
  18. package/dist/{client → client-v2}/flow/models/ChartBlockModel.d.ts +16 -1
  19. package/dist/{client → client-v2}/flow/models/ChartOptionsBuilder.d.ts +9 -0
  20. package/dist/{client → client-v2}/flow/models/ECharts.d.ts +2 -0
  21. package/dist/client-v2/flow/models/EventsEditor.d.ts +14 -0
  22. package/dist/{client → client-v2}/flow/models/QueryBuilder.d.ts +15 -2
  23. package/dist/{client → client-v2}/flow/models/QueryBuilder.service.d.ts +1 -0
  24. package/dist/{client → client-v2}/flow/models/SQLEditor.d.ts +6 -1
  25. package/dist/{client → client-v2}/flow/models/config-store.d.ts +6 -2
  26. package/dist/{client → client-v2}/flow/resources/ChartResource.d.ts +1 -0
  27. package/dist/{client → client-v2}/flow/utils.d.ts +8 -0
  28. package/dist/client-v2/hooks/index.d.ts +9 -0
  29. package/dist/{client/flow/models/EventsEditor.d.ts → client-v2/hooks/useSetChartSize.d.ts} +11 -2
  30. package/dist/client-v2/index.d.ts +12 -0
  31. package/dist/client-v2/index.js +10 -0
  32. package/dist/client-v2/locale.d.ts +15 -0
  33. package/dist/client-v2/plugin.d.ts +23 -0
  34. package/dist/externalVersion.js +14 -13
  35. package/dist/node_modules/koa-compose/index.js +1 -1
  36. package/dist/node_modules/koa-compose/package.json +1 -1
  37. package/dist/server/actions/query.d.ts +2 -4
  38. package/dist/server/actions/query.js +57 -186
  39. package/dist/server/plugin.js +2 -2
  40. package/dist/server/types.d.ts +3 -0
  41. package/package.json +5 -2
  42. package/dist/client/322e2bf42e03b4a8.js +0 -47
  43. package/dist/client/3f66fc107a17e7ea.js +0 -10
  44. package/dist/client/8795975cb8946be4.js +0 -10
  45. package/dist/client/924c5f5607998e1c.js +0 -10
  46. package/dist/client/flow/components/AntdFilterSelector.d.ts +0 -35
  47. package/dist/node_modules/moment-timezone/LICENSE +0 -20
  48. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.js +0 -1548
  49. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.min.js +0 -1
  50. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.js +0 -1548
  51. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-1970-2030.min.js +0 -1
  52. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.js +0 -1560
  53. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data-2012-2022.min.js +0 -1
  54. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.js +0 -1548
  55. package/dist/node_modules/moment-timezone/builds/moment-timezone-with-data.min.js +0 -1
  56. package/dist/node_modules/moment-timezone/builds/moment-timezone.min.js +0 -1
  57. package/dist/node_modules/moment-timezone/composer.json +0 -43
  58. package/dist/node_modules/moment-timezone/data/meta/latest.json +0 -5889
  59. package/dist/node_modules/moment-timezone/data/packed/latest.json +0 -852
  60. package/dist/node_modules/moment-timezone/index.d.ts +0 -78
  61. package/dist/node_modules/moment-timezone/index.js +0 -15
  62. package/dist/node_modules/moment-timezone/moment-timezone-utils.d.ts +0 -70
  63. package/dist/node_modules/moment-timezone/moment-timezone-utils.js +0 -339
  64. package/dist/node_modules/moment-timezone/moment-timezone.js +0 -696
  65. package/dist/node_modules/moment-timezone/package.json +0 -1
  66. package/dist/server/formatter/formatter.d.ts +0 -27
  67. package/dist/server/formatter/formatter.js +0 -85
  68. package/dist/server/formatter/mysql-formatter.d.ts +0 -14
  69. package/dist/server/formatter/mysql-formatter.js +0 -93
  70. package/dist/server/formatter/oracle-formatter.d.ts +0 -14
  71. package/dist/server/formatter/oracle-formatter.js +0 -74
  72. package/dist/server/formatter/postgres-formatter.d.ts +0 -14
  73. package/dist/server/formatter/postgres-formatter.js +0 -74
  74. package/dist/server/formatter/sqlite-formatter.d.ts +0 -15
  75. package/dist/server/formatter/sqlite-formatter.js +0 -83
  76. package/dist/server/query-parser/index.d.ts +0 -11
  77. package/dist/server/query-parser/index.js +0 -56
  78. package/dist/server/query-parser/mysql-query-parser.d.ts +0 -15
  79. package/dist/server/query-parser/mysql-query-parser.js +0 -43
  80. package/dist/server/query-parser/oracle-query-parser.d.ts +0 -18
  81. package/dist/server/query-parser/oracle-query-parser.js +0 -60
  82. package/dist/server/query-parser/postgres-query-parser.d.ts +0 -15
  83. package/dist/server/query-parser/postgres-query-parser.js +0 -43
  84. package/dist/server/query-parser/query-parser.d.ts +0 -31
  85. package/dist/server/query-parser/query-parser.js +0 -146
  86. package/dist/server/query-parser/sqlite-query-parser.d.ts +0 -15
  87. package/dist/server/query-parser/sqlite-query-parser.js +0 -43
  88. /package/dist/{client → client-v2}/flow/components/CodeEditor.d.ts +0 -0
  89. /package/dist/{client → client-v2}/flow/components/DaraButton.d.ts +0 -0
  90. /package/dist/{client → client-v2}/flow/models/ChartOptionsBuilder.service.d.ts +0 -0
  91. /package/dist/{client → client-v2}/flow/models/ChartOptionsEditor.d.ts +0 -0
  92. /package/dist/{client → client-v2}/flow/models/ChartOptionsPanel.d.ts +0 -0
  93. /package/dist/{client → client-v2}/flow/models/ConfigPanel.d.ts +0 -0
  94. /package/dist/{client → client-v2}/flow/models/EventsPanel.d.ts +0 -0
  95. /package/dist/{client → client-v2}/flow/models/QueryPanel.d.ts +0 -0
  96. /package/dist/{client → client-v2}/flow/models/ResultPanel.d.ts +0 -0
@@ -0,0 +1,10 @@
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
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@nocobase/client-v2"),require("dayjs"),require("@nocobase/plugin-ai/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-data-visualization/client-v2",["react-i18next","@nocobase/client-v2","dayjs","@nocobase/plugin-ai/client-v2","react","antd","@ant-design/icons","@nocobase/flow-engine","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-data-visualization/client-v2"]=t(require("react-i18next"),require("@nocobase/client-v2"),require("dayjs"),require("@nocobase/plugin-ai/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-data-visualization/client-v2"]=t(e["react-i18next"],e["@nocobase/client-v2"],e.dayjs,e["@nocobase/plugin-ai/client-v2"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,r,n,o,i,a,u,l,c){return function(){"use strict";var f,s,p,d={9667:function(e,t,r){r.d(t,{Gm:function(){return y},VS:function(){return y}});var n=r(3485),o=r(7663),i=r(9488);function a(e,t,r,n,o,i,a){try{var u=e[i](a),l=u.value}catch(e){r(e);return}u.done?t(l):Promise.resolve(l).then(n,o)}function u(e,t,r){return(u=p()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&f(o,r.prototype),o}).apply(null,arguments)}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){var t="function"==typeof Map?new Map:void 0;return(s=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}var d=function(e,t,r){var n,o,a,u=(null==e||null==(n=e.uiSchema)?void 0:n.enum)||(null==e||null==(a=e.options)||null==(o=a.uiSchema)?void 0:o.enum),l=function(e,t){if(Array.isArray(t))return t.map(function(t){return l(e,t)});var n=e.find(function(e){var r;return e.value===((null==t||null==(r=t.toString)?void 0:r.call(t))||t)});return(0,i.OJ)((null==n?void 0:n.label)||t,(null==r?void 0:r.t)||function(e){return e})};return u&&Array.isArray(u)?l(u,t):t},y=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=c(t),l(e=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,p()?Reflect.construct(t,r||[],c(this).constructor):t.apply(this,r)),"charts",new o.EK),l(e,"fieldInterfaceConfigs",{select:{valueFormatter:d},multipleSelect:{valueFormatter:d},radioGroup:{valueFormatter:d},checkboxGroup:{valueFormatter:d}}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&f(n,e),t=[{key:"registerFieldInterfaceConfig",value:function(e,t){this.fieldInterfaceConfigs[e]=t}},{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return this.flowEngine.registerModelLoaders({ChartBlockModel:{loader:function(){return Promise.all([r.e("468"),r.e("496")]).then(r.bind(r,5843))}}}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,l,"next",e)}function l(e){a(i,n,o,u,l,"throw",e)}u(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n.prototype,t),n}(s(n.Plugin));t.Ay=y},7663:function(e,t,r){r.d(t,{t1:function(){return j},uy:function(){return y},Dl:function(){return s},Tp:function(){return d},xD:function(){return p},EK:function(){return f}});var n=r(3485),o=r(9667);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw n}}return i}}(e,t)||c(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}}var f=function(){var e;function t(){if(!(this instanceof t))throw TypeError("Cannot call a class as a function");a(this,"charts",new Map)}return e=[{key:"addGroup",value:function(e,t){if(this.charts.has(e))throw Error('[data-visualization] Chart group "'.concat(e,'" already exists'));this.charts.set(e,t)}},{key:"add",value:function(e,t){var r=this.charts.get(e);if(r){var n,o,i=Array.isArray(t)?t:[t];this.charts.set(e,(n=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){a(e,t,r[t])})}return e}({},r),o=o={charts:l(r.charts).concat(l(i))},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}),n))}}},{key:"getChartTypes",value:function(){return Array.from(this.charts.entries()).sort(function(e,t){var r=u(e,2)[1],n=u(t,2)[1];return(r.sort||0)-(n.sort||0)}).map(function(e){var t=u(e,2),r=t[0],n=t[1];return{label:n.title,value:r,children:n.charts.map(function(e){return{key:"".concat(r,".").concat(e.name),label:e.title,value:e.name}})}})}},{key:"getCharts",value:function(){var e={};return this.charts.forEach(function(t,r){t.charts.forEach(function(t){e["".concat(r,".").concat(t.name)]=t})}),e}},{key:"getChart",value:function(e){if(e)return this.getCharts()[e]}},{key:"getDefaultChartType",value:function(){var e,t=this.getChartTypes()[0],r=null==t||null==(e=t.children)?void 0:e[0];return t&&r?"".concat(t.value,".").concat(r.value):void 0}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),t}(),s=function(){var e,t=v();return(null==t||null==(e=t.charts)?void 0:e.getChartTypes())||[]},p=function(){var e=v();return b(null==e?void 0:e.charts)},d=function(){var e,t=v();return(null==t||null==(e=t.charts)?void 0:e.getCharts())||{}},y=function(e){var t,r=v();return null==r||null==(t=r.charts)?void 0:t.getChart(e)},v=function(){return(0,n.useApp)().pm.get(o.Ay)},b=function(e){if(e){if("function"==typeof e.getDefaultChartType)return e.getDefaultChartType();var t,r,n,o=null==(t=e.getChartTypes)?void 0:t.call(e)[0];return null==o||null==(n=o.children)||null==(r=n[0])?void 0:r.value}},h=r(9155),m=r(8376),g=r(9488);function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Y={field:function(e){var t=e.name,r=e.title,n=e.required,o=e.defaultValue,i=e.description;return w({},t,{title:(0,g.vV)(r),type:"string","x-decorator":"FormItem","x-component":"Select","x-reactions":"{{ useChartFields }}",required:n,description:i,default:o})},input:function(e){var t=e.name,r=e.title,n=e.required,o=e.defaultValue,i=e.description;return w({},t,{title:(0,g.vV)(r),type:"string","x-decorator":"FormItem","x-component":"Input",required:n,default:o,description:i})},boolean:function(e){var t=e.name,r=e.title,n=e.defaultValue,o=e.description;return w({},t,{"x-content":(0,g.vV)(r),type:"boolean","x-decorator":"FormItem","x-component":"Checkbox",default:void 0!==n&&n,description:o})},select:function(e){var t=e.name,r=e.title,n=e.required,o=e.defaultValue,i=e.options,a=e.description;return w({},t,{title:(0,g.vV)(r),type:"string","x-decorator":"FormItem","x-component":"Select",required:n,default:o,description:a,enum:i})},radio:function(e){var t=e.name,r=e.title,n=e.defaultValue,o=e.options,i=e.description,a=e.componentProps;return w({},t,{title:(0,g.vV)(r),type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){w(e,t,r[t])})}return e}({},a),default:n,description:i,enum:o})},percent:function(e){return w({},e.name,{title:e.title,type:"number","x-decorator":"FormItem","x-component":"InputNumber",default:e.defaultValue,description:e.description,"x-component-props":{suffix:"%"}})},xField:{configType:"field",name:"xField",title:"xField",required:!0},yField:{configType:"field",name:"yField",title:"yField",required:!0},seriesField:{configType:"field",name:"seriesField",title:"seriesField"},colorField:{configType:"field",name:"colorField",title:"colorField",required:!0},isStack:{configType:"boolean",name:"isStack",title:"isStack"},smooth:{configType:"boolean",name:"smooth",title:"smooth"},isPercent:{configType:"boolean",name:"isPercent",title:"isPercent"},isGroup:{configType:"boolean",name:"isGroup",title:"isGroup"},size:function(){return{size:{title:(0,g.vV)("Size"),type:"object","x-decorator":"FormItem","x-component":"Space",properties:{type:{"x-component":"Select","x-component-props":{allowClear:!1},default:"ratio",enum:[{label:(0,g.vV)("Aspect ratio"),value:"ratio"},{label:(0,g.vV)("Fixed height"),value:"fixed"}]},fixed:{type:"number","x-component":"InputNumber","x-component-props":{min:0,addonAfter:"px"},"x-reactions":[{dependencies:[".type"],fulfill:{state:{visible:"{{$deps[0] === 'fixed'}}"}}}]},ratio:{type:"object","x-component":"Space","x-reactions":[{dependencies:[".type"],fulfill:{state:{visible:"{{$deps[0] === 'ratio'}}"}}}],properties:{width:{type:"number","x-component":"InputNumber","x-component-props":{placeholder:(0,g.vV)("Width"),min:1}},colon:{type:"void","x-component":"Text","x-component-props":{children:":"}},height:{type:"number","x-component":"InputNumber","x-component-props":{placeholder:(0,g.vV)("Height"),min:1}}}}}}}}};function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var j=function(){var e;function t(e){var r=e.name,n=e.title,o=e.enableAdvancedConfig,i=e.Component,a=e.config;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");O(this,"name",void 0),O(this,"title",void 0),O(this,"enableAdvancedConfig",!1),O(this,"Component",void 0),O(this,"config",void 0),O(this,"configTypes",new Map),this.name=r,this.title=n,this.Component=(0,h.memo)(i,function(e,t){return JSON.stringify(e)===JSON.stringify(t)}),this.config=a,this.enableAdvancedConfig=o||!1,this.addConfigTypes(Y)}return e=[{key:"schema",get:function(){var e=this;return this.config?{type:"object",properties:this.config.reduce(function(t,r){var n={};if("string"==typeof r&&(r=e.configTypes.get(r)),"function"==typeof r)n=r();else if(r.configType){var o=e.configTypes.get(r.configType);n=(null==o?void 0:o(r))||{}}else n=r;return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){O(e,t,r[t])})}return e}({},t,n)},{})}:{}}},{key:"addConfigTypes",value:function(e){var t=this;Object.entries(e).forEach(function(e){var r=function(e){if(Array.isArray(e))return e}(e)||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return x(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return x(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),n=r[0],o=r[1];t.configTypes.set(n,o)})}},{key:"infer",value:function(e,t){var r=t.measures,n=t.dimensions,o=[],i=function(e,t){if(t.alias)return e.find(function(e){return e.value===t.alias});var r=(0,m.cn)(t.field).alias;return e.find(function(e){return e.value===r})};if((null==r?void 0:r.length)&&(a=i(e,r[0]),o=r.map(function(t){return i(e,t)})),n){if(1===n.length)f=i(e,n[0]);else if(n.length>1){n.forEach(function(t,r){var n=i(e,t);["date","time","datetime"].includes(null==n?void 0:n.type)&&(f=n,c=r)}),c=c||0;var a,u,l,c,f=f||i(e,n[c]),s=n.filter(function(e,t){return t!==c}).map(function(t){return i(e,t)});1===s.length?(u=s[0],l=s[0]):s.length>1&&(l=s[0],u=s[1])}}return{xField:f,yField:a,seriesField:u,colorField:l,yFields:o}}},{key:"getProps",value:function(e){return e}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),t}()},8376:function(e,t,r){r.d(t,{A5:function(){return g},JR:function(){return s},Nj:function(){return w},OK:function(){return y},_A:function(){return f},_J:function(){return p},cY:function(){return b},cn:function(){return m},lu:function(){return h},yy:function(){return d}});var n=r(9155),o=r.n(n),i=r(9488);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw n}}return i}}(e,t)||c(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function c(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(e,t)}}function f(e){if(!Array.isArray(e)||0===e.length)return{objects:[],rows:[],columns:[]};var t=Object.keys(e[0]),r=t[0],n=t.slice(1),o=[t];e.forEach(function(e){o.push(t.map(function(t){return e[t]}))});var i=[e.map(function(e){return e[r]})];return n.forEach(function(t){i.push(e.map(function(e){return e[t]}))}),{dimensions:t,objects:e,rows:o,columns:i}}function s(e){if(!e)return e;var t,r,n,o=e.dataset,i=Array.isArray(o)?null==(t=o[0])?void 0:t.source:null==o?void 0:o.source,a=e.series,u=Array.isArray(a)?a:a?[a]:[];if(!Array.isArray(i)||0===i.length)return e;var c=i[0];if(!c||(void 0===c?"undefined":l(c))!=="object"||Array.isArray(c))return e;var f=u.filter(function(e){return(null==e?void 0:e.type)==="pie"});if(0===f.length)return e;var s=null==(n=f[0])||null==(r=n.encode)?void 0:r.value,p=Array.isArray(s)?s[0]:s;if(("string"!=typeof p||!p)&&Object.prototype.hasOwnProperty.call(c,"value")&&(p="value"),"string"!=typeof p||!p)return e;var d=function(e){return e.includes("{c}")?e.replace(/\{c\}/g,"{@"+p+"}"):e};return f.forEach(function(e){(null==e?void 0:e.label)&&"string"==typeof e.label.formatter&&(e.label.formatter=d(e.label.formatter)),(null==e?void 0:e.tooltip)&&"string"==typeof e.tooltip.formatter&&(e.tooltip.formatter=d(e.tooltip.formatter))}),e.tooltip&&"string"==typeof e.tooltip.formatter&&(e.tooltip.formatter=d(e.tooltip.formatter)),e}var p={datetime:[{label:(0,i.MZ)("YYYY"),value:"YYYY"},{label:(0,i.MZ)("MM"),value:"MM"},{label:(0,i.MZ)("DD"),value:"DD"},{label:(0,i.MZ)("HH:mm"),value:"HH:mm"},{label:(0,i.MZ)("YYYY-MM"),value:"YYYY-MM"},{label:(0,i.MZ)("YYYY-MM-DD"),value:"YYYY-MM-DD"},{label:(0,i.MZ)("YYYY-MM-DD HH:mm"),value:"YYYY-MM-DD HH:mm"},{label:(0,i.MZ)("YYYY-MM-DD HH:mm:ss"),value:"YYYY-MM-DD HH:mm:ss"},{label:(0,i.MZ)("MM/DD/YYYY"),value:"MM/DD/YYYY"},{label:(0,i.MZ)("MM/DD/YYYY HH:mm"),value:"MM/DD/YYYY HH:mm"},{label:(0,i.MZ)("MM/DD/YYYY HH:mm:ss"),value:"MM/DD/YYYY HH:mm:ss"}],date:[{label:(0,i.MZ)("YYYY"),value:"YYYY"},{label:(0,i.MZ)("MM"),value:"MM"},{label:(0,i.MZ)("DD"),value:"DD"},{label:(0,i.MZ)("YYYY-MM"),value:"YYYY-MM"},{label:(0,i.MZ)("YYYY-MM-DD"),value:"YYYY-MM-DD"},{label:(0,i.MZ)("MM/DD/YYYY"),value:"MM/DD/YYYY"}],time:[{label:(0,i.MZ)("HH"),value:"HH"},{label:(0,i.MZ)("HH:mm"),value:"HH:mm"},{label:(0,i.MZ)("HH:mm:ss"),value:"HH:mm:ss"}]};function d(e){return new Promise(function(t){setTimeout(t,e)})}function y(e,t){if("string"!=typeof e)return"";var r=e.trim();if(!r)return"";var n=r.replace(RegExp("[::]\\s*$","u"),""),o="string"==typeof t&&/^zh([-_]|$)/i.test(t);return"".concat(n).concat(o?":":":")}var v=function(){if("u"<typeof window)return!1;try{var e,t=new URLSearchParams(window.location.search||"").get("_debug");if("true"===t||"1"===t)return!0;var r=null==(e=window.localStorage)?void 0:e.getItem("nocobase.debug");if("true"===r||"1"===r)return!0}catch(e){}return!1},b=function(){for(var e,t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];v()&&(e=console).log.apply(e,function(e){if(Array.isArray(e))return a(e)}(r)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||c(r)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())},h=function(){var e=(0,i.kj)();return o().useCallback(function(t){return(0,i.OJ)(t,e)},[e])},m=function(e){var t,r,n;return Array.isArray(e)?1===e.length?r=e[0]:e.length>1&&(t=(n=u(e,2))[0],r=n[1]):r=e,{target:t,name:r,alias:t?"".concat(t,".").concat(r):r}},g=function(e){if((void 0===e?"undefined":l(e))==="object"&&null!==e){if(Array.isArray(e)){var t=e.map(function(e){return g(e)}).filter(Boolean);return t.length>0?t:null}var r={},n=!0,o=!1,i=void 0;try{for(var a,c=Object.entries(e)[Symbol.iterator]();!(n=(a=c.next()).done);n=!0){var f=u(a.value,2),s=f[0],p=f[1];if("string"!=typeof s||0!==s.trim().length){var d=g(p);null==d||(void 0===d?"undefined":l(d))==="object"&&(Array.isArray(d)&&0===d.length||0===Object.keys(d).length)||(r[s]=d)}}}catch(e){o=!0,i=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw i}}return Object.keys(r).length>0?r:null}return"string"==typeof e&&e.startsWith("{{$nFilter.")&&e.endsWith("}}")?null:e},w=function(e){return!e||(Array.isArray(e)?0===e.length:!!((void 0===e?"undefined":l(e))==="object"&&(0===Object.keys(e).length||Array.isArray(e.$and)&&0===e.$and.length||Array.isArray(e.$or)&&0===e.$or.length))||!1)}},9488:function(e,t,r){r.d(t,{MZ:function(){return a},OJ:function(){return u},kj:function(){return l},vV:function(){return c}});var n=r(7694),o=r(5953),i="@nocobase/plugin-data-visualization";function a(e){return(0,n.tExpr)(e,{ns:[i,"client"]})}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){return e};return"string"==typeof e?e.replace(/\{\{\s*t\((['"])(.*?)\1(?:\s*,\s*\{[^}]*\})?\)\s*\}\}/g,function(e,r,n){return t(n)}):e}function l(){return(0,o.useTranslation)([i,"client"],{nsMode:"fallback"})[0]}function c(e){return"{{t(".concat(JSON.stringify(e),", { ns: ['").concat(i,"', 'client'], nsMode: 'fallback' })}}")}},7375:function(e){e.exports=a},3485:function(e){e.exports=t},7694:function(e){e.exports=u},550:function(e){e.exports=n},7768:function(e){e.exports=l},2059:function(e){e.exports=i},9185:function(e){e.exports=r},6773:function(e){e.exports=c},9155:function(e){e.exports=o},5953:function(t){t.exports=e}},y={};function v(e){var t=y[e];if(void 0!==t)return t.exports;var r=y[e]={id:e,loaded:!1,exports:{}};return d[e](r,r.exports,v),r.loaded=!0,r.exports}v.m=d,v.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return v.d(t,{a:t}),t},v.d=function(e,t){for(var r in t)v.o(t,r)&&!v.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},v.f={},v.e=function(e){return Promise.all(Object.keys(v.f).reduce(function(t,r){return v.f[r](e,t),t},[]))},v.u=function(e){return""+e+"."+({176:"8068b95175599050",214:"a999212f348c0092",468:"95cb9025bce70a9c",496:"51bfbe09593275b9",680:"a2c2838809485d36"})[e]+".js"},v.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),v.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},b={},v.l=function(e,t,r,n){if(b[e])return void b[e].push(t);if(void 0!==r)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var l=a[u];if(l.getAttribute("src")==e||l.getAttribute("data-rspack")=="@nocobase/plugin-data-visualization/client-v2:"+r){o=l;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,v.nc&&o.setAttribute("nonce",v.nc),o.setAttribute("data-rspack","@nocobase/plugin-data-visualization/client-v2:"+r),o.src=e),b[e]=[t];var c=function(t,r){o.onerror=o.onload=null,clearTimeout(f);var n=b[e];if(delete b[e],o.parentNode&&o.parentNode.removeChild(o),n&&n.forEach(function(e){return e(r)}),t)return t(r)},f=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.bind(null,o.onload),i&&document.head.appendChild(o)},v.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},v.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},v.nc=void 0,v.g.importScripts&&(h=v.g.location+"");var b,h,m=v.g.document;if(!h&&m&&(m.currentScript&&"SCRIPT"===m.currentScript.tagName.toUpperCase()&&(h=m.currentScript.src),!h)){var g=m.getElementsByTagName("script");if(g.length)for(var w=g.length-1;w>-1&&(!h||!/^http(s?):/.test(h));)h=g[w--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");v.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),f={889:0},v.f.j=function(e,t){var r=v.o(f,e)?f[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var n=new Promise(function(t,n){r=f[e]=[t,n]});t.push(r[2]=n);var o=v.p+v.u(e),i=Error();v.l(o,function(t){if(v.o(f,e)&&(0!==(r=f[e])&&(f[e]=void 0),r)){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+n+": "+o+")",i.name="ChunkLoadError",i.type=n,i.request=o,r[1](i)}},"chunk-"+e,e)}},s=function(e,t){var r,n,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==f[e]})){for(r in i)v.o(i,r)&&(v.m[r]=i[r]);a&&a(v)}for(e&&e(t);u<o.length;u++)n=o[u],v.o(f,n)&&f[n]&&f[n][0](),f[n]=0},(p=self.webpackChunk_nocobase_plugin_data_visualization_client_v2=self.webpackChunk_nocobase_plugin_data_visualization_client_v2||[]).forEach(s.bind(null,0)),p.push=s.bind(null,p.push.bind(p));var Y={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-data-visualization/dist/client-v2/")}if(!e){var n=window.__nocobase_modern_client_prefix__||"v",o="/"+(n=String(n).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+n+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-data-visualization/dist/client-v2/"}v.p=e}(),!function(){v.r(Y),v.d(Y,{default:function(){return e.Ay},PluginDataVisualizationClient:function(){return e.VS},useCharts:function(){return t.Tp},useChartTypes:function(){return t.Dl},useDefaultChartType:function(){return t.xD},ChartGroup:function(){return t.EK},Chart:function(){return t.t1},useChart:function(){return t.uy},useSetChartSize:function(){return o},PluginDataVisualiztionClient:function(){return e.Gm}});var e=v(9667),t=v(7663),r=v(9155);function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var o=function(){var e,t,o,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0,u=function(e){if(Array.isArray(e))return e}(e=(0,r.useState)(a||i.fixed||0))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return n(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return n(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),l=u[0],c=u[1],f=(0,r.useRef)(null);return(0,r.useEffect)(function(){var e,t,r=f.current;if(r&&!a&&"fixed"!==i.type){var n="ratio"===i.type&&(null==(e=i.ratio)?void 0:e.width)&&(null==(t=i.ratio)?void 0:t.height)?i.ratio.height/i.ratio.width:0,o=new ResizeObserver(function(e){e.forEach(function(e){c(n?e.contentRect.width*n:Math.max(e.contentRect.height,400))})});return o.observe(r),function(){return o.disconnect()}}},[a,null==(t=i.ratio)?void 0:t.height,null==(o=i.ratio)?void 0:o.width,i.type]),{chartRef:f,chartHeight:a||l||i.fixed||400}}}(),Y}()});
@@ -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
+ export declare const NAMESPACE = "@nocobase/plugin-data-visualization";
10
+ export declare function tExpr(key: string): string;
11
+ export declare function translateExpr(source: any, t?: (key: string) => string): any;
12
+ export declare function useChartsTranslation(): import("react-i18next").UseTranslationResponse<("@nocobase/plugin-data-visualization" | "client")[], undefined>;
13
+ export declare function useT(): import("react-i18next").TFunction<("@nocobase/plugin-data-visualization" | "client")[], undefined>;
14
+ export declare function tStr(key: string): string;
15
+ export declare function lang(key: string): string;
@@ -0,0 +1,23 @@
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 { Plugin } from '@nocobase/client-v2';
10
+ import { ChartGroup } from './chart';
11
+ type FieldInterfaceConfig = {
12
+ valueFormatter: (field: any, value: any, context?: any) => any;
13
+ };
14
+ export declare class PluginDataVisualizationClient extends Plugin {
15
+ charts: ChartGroup;
16
+ fieldInterfaceConfigs: {
17
+ [fieldInterface: string]: FieldInterfaceConfig;
18
+ };
19
+ registerFieldInterfaceConfig(key: string, config: FieldInterfaceConfig): void;
20
+ load(): Promise<void>;
21
+ }
22
+ export { PluginDataVisualizationClient as PluginDataVisualiztionClient };
23
+ export default PluginDataVisualizationClient;
@@ -8,18 +8,19 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.8",
11
+ "@nocobase/client": "2.2.0-alpha.1",
12
12
  "@formily/react": "2.3.7",
13
- "@nocobase/plugin-ai": "2.1.0-beta.8",
14
- "@nocobase/flow-engine": "2.1.0-beta.8",
13
+ "@nocobase/plugin-ai": "2.2.0-alpha.1",
14
+ "@nocobase/flow-engine": "2.2.0-alpha.1",
15
15
  "react-i18next": "11.18.6",
16
16
  "dayjs": "1.11.13",
17
17
  "@formily/shared": "2.3.7",
18
- "lodash": "4.17.21",
19
- "@nocobase/cache": "2.1.0-beta.8",
20
- "@nocobase/server": "2.1.0-beta.8",
21
- "@nocobase/test": "2.1.0-beta.8",
22
- "@nocobase/utils": "2.1.0-beta.8",
18
+ "lodash": "4.18.1",
19
+ "@nocobase/client-v2": "2.2.0-alpha.1",
20
+ "@nocobase/cache": "2.2.0-alpha.1",
21
+ "@nocobase/server": "2.2.0-alpha.1",
22
+ "@nocobase/test": "2.2.0-alpha.1",
23
+ "@nocobase/utils": "2.2.0-alpha.1",
23
24
  "react": "18.2.0",
24
25
  "@emotion/css": "11.13.0",
25
26
  "@ant-design/icons": "5.6.1",
@@ -27,9 +28,9 @@ module.exports = {
27
28
  "antd": "5.24.2",
28
29
  "@formily/antd-v5": "1.2.3",
29
30
  "@formily/core": "2.3.7",
30
- "@nocobase/actions": "2.1.0-beta.8",
31
- "@nocobase/database": "2.1.0-beta.8",
32
- "@nocobase/acl": "2.1.0-beta.8",
33
- "sequelize": "6.35.2",
34
- "@formily/reactive": "2.3.7"
31
+ "@nocobase/actions": "2.2.0-alpha.1",
32
+ "@nocobase/acl": "2.2.0-alpha.1",
33
+ "@nocobase/plugin-acl": "2.2.0-alpha.1",
34
+ "@nocobase/plugin-flow-engine": "2.2.0-alpha.1",
35
+ "@nocobase/database": "2.2.0-alpha.1"
35
36
  };
@@ -1 +1 @@
1
- (function(){"use strict";var e={979:function(e){e.exports=compose;function compose(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const r of e){if(typeof r!=="function")throw new TypeError("Middleware must be composed of functions!")}return function(r,t){let i=-1;return dispatch(0);function dispatch(n){if(n<=i)return Promise.reject(new Error("next() called multiple times"));i=n;let o=e[n];if(n===e.length)o=t;if(!o)return Promise.resolve();try{return Promise.resolve(o(r,dispatch.bind(null,n+1)))}catch(e){return Promise.reject(e)}}}}}};var r={};function __nccwpck_require__(t){var i=r[t];if(i!==undefined){return i.exports}var n=r[t]={exports:{}};var o=true;try{e[t](n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete r[t]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(979);module.exports=t})();
1
+ (()=>{"use strict";var e={979:e=>{e.exports=compose;function compose(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const r of e){if(typeof r!=="function")throw new TypeError("Middleware must be composed of functions!")}return function(r,t){let i=-1;return dispatch(0);function dispatch(o){if(o<=i)return Promise.reject(new Error("next() called multiple times"));i=o;let n=e[o];if(o===e.length)n=t;if(!n)return Promise.resolve();try{return Promise.resolve(n(r,dispatch.bind(null,o+1)))}catch(e){return Promise.reject(e)}}}}}};var r={};function __nccwpck_require__(t){var i=r[t];if(i!==undefined){return i.exports}var o=r[t]={exports:{}};var n=true;try{e[t](o,o.exports,__nccwpck_require__);n=false}finally{if(n)delete r[t]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(979);module.exports=t})();
@@ -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":"2026-03-11T23:52:30.640Z"}
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":"2026-06-10T18:13:42.939Z"}
@@ -7,10 +7,8 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Context, Next } from '@nocobase/actions';
10
- export declare const postProcess: (ctx: Context, next: Next) => Promise<void>;
10
+ export declare const checkPermission: (ctx: Context, next: Next) => Promise<void>;
11
11
  export declare const queryData: (ctx: Context, next: Next) => Promise<void>;
12
- export declare const parseFieldAndAssociations: (ctx: Context, next: Next) => Promise<void>;
13
12
  export declare const parseVariables: (ctx: Context, next: Next) => Promise<void>;
14
13
  export declare const cacheMiddleware: (ctx: Context, next: Next) => Promise<void>;
15
- export declare const checkPermission: (ctx: Context, next: Next) => Promise<any>;
16
- export declare const query: (ctx: Context, next: Next) => Promise<void>;
14
+ export declare const queryDataAction: (ctx: Context, next: Next) => Promise<void>;
@@ -38,164 +38,75 @@ var query_exports = {};
38
38
  __export(query_exports, {
39
39
  cacheMiddleware: () => cacheMiddleware,
40
40
  checkPermission: () => checkPermission,
41
- parseFieldAndAssociations: () => parseFieldAndAssociations,
42
41
  parseVariables: () => parseVariables,
43
- postProcess: () => postProcess,
44
- query: () => query,
45
- queryData: () => queryData
42
+ queryData: () => queryData,
43
+ queryDataAction: () => queryDataAction
46
44
  });
47
45
  module.exports = __toCommonJS(query_exports);
48
- var import_database = require("@nocobase/database");
49
46
  var import_koa_compose = __toESM(require("koa-compose"));
50
- var import_server = require("@nocobase/server");
51
- var import_query_parser = require("../query-parser");
52
- var import_utils = require("@nocobase/utils");
53
47
  var import_acl = require("@nocobase/acl");
54
- const getDB = (ctx, dataSource) => {
48
+ var import_plugin_acl = require("@nocobase/plugin-acl");
49
+ var import_server = require("@nocobase/server");
50
+ var import_plugin_flow_engine = require("@nocobase/plugin-flow-engine");
51
+ const getQueryDatabase = (ctx, dataSource) => {
52
+ var _a;
55
53
  const ds = ctx.app.dataSourceManager.dataSources.get(dataSource);
56
- return ds == null ? void 0 : ds.collectionManager.db;
54
+ return ((_a = ds == null ? void 0 : ds.collectionManager) == null ? void 0 : _a.db) || ctx.db;
57
55
  };
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
- case "decimal":
72
- record[key] = Number(value);
73
- break;
74
- }
56
+ const getTimezone = (ctx) => {
57
+ var _a, _b, _c, _d, _e, _f;
58
+ return ((_b = (_a = ctx == null ? void 0 : ctx.request) == null ? void 0 : _a.get) == null ? void 0 : _b.call(_a, "x-timezone")) ?? ((_d = (_c = ctx == null ? void 0 : ctx.request) == null ? void 0 : _c.header) == null ? void 0 : _d["x-timezone"]) ?? ((_f = (_e = ctx == null ? void 0 : ctx.req) == null ? void 0 : _e.headers) == null ? void 0 : _f["x-timezone"]);
59
+ };
60
+ const checkPermission = async (ctx, next) => {
61
+ var _a, _b, _c, _d, _e;
62
+ const values = ctx.action.params.values || {};
63
+ const acl = ((_a = ctx.app.dataSourceManager.get(values.dataSource)) == null ? void 0 : _a.acl) || ctx.app.acl;
64
+ const currentRoles = ((_b = ctx.state) == null ? void 0 : _b.currentRoles) || (((_c = ctx.state) == null ? void 0 : _c.currentRole) ? [ctx.state.currentRole] : []);
65
+ if (currentRoles.includes("root")) {
66
+ await next();
67
+ return;
68
+ }
69
+ try {
70
+ const result = await (0, import_plugin_acl.applyQueryPermission)({
71
+ acl,
72
+ db: getQueryDatabase(ctx, values.dataSource),
73
+ resourceName: values.collection,
74
+ query: values,
75
+ currentUser: (_d = ctx.state) == null ? void 0 : _d.currentUser,
76
+ currentRole: (_e = ctx.state) == null ? void 0 : _e.currentRole,
77
+ currentRoles,
78
+ timezone: getTimezone(ctx),
79
+ state: ctx.state
75
80
  });
76
- return record;
77
- });
81
+ ctx.action.params.values = result.query;
82
+ } catch (err) {
83
+ if (!(err instanceof import_acl.NoPermissionError)) {
84
+ throw err;
85
+ }
86
+ ctx.throw(403, "No permissions");
87
+ }
78
88
  await next();
79
89
  };
80
90
  const queryData = async (ctx, next) => {
81
- const { dataSource, collection, queryParams, fieldMap } = ctx.action.params.values;
82
- const db = getDB(ctx, dataSource) || ctx.db;
83
- const model = db.getModel(collection);
84
- const data = await model.findAll(queryParams);
85
- ctx.action.params.values = {
86
- data,
87
- fieldMap
88
- };
89
- await next();
90
- };
91
- const parseFieldAndAssociations = async (ctx, next) => {
92
91
  var _a;
93
- const {
94
- dataSource,
95
- collection: collectionName,
96
- measures,
97
- dimensions,
98
- orders,
99
- filter
100
- } = ctx.action.params.values;
101
- const db = getDB(ctx, dataSource) || ctx.db;
102
- const collection = db.getCollection(collectionName);
103
- const fields = collection.fields;
104
- const associations = collection.model.associations;
105
- const models = {};
106
- const parseField = (selected) => {
107
- var _a2, _b, _c, _d, _e, _f;
108
- let target;
109
- let name;
110
- if (!Array.isArray(selected.field)) {
111
- name = selected.field;
112
- } else if (selected.field.length === 1) {
113
- name = selected.field[0];
114
- } else if (selected.field.length > 1) {
115
- [target, name] = selected.field;
116
- }
117
- const rawAttributes = collection.model.getAttributes();
118
- let field = ((_a2 = rawAttributes[name]) == null ? void 0 : _a2.field) || name;
119
- let fieldType = (_b = fields.get(name)) == null ? void 0 : _b.type;
120
- let fieldOptions = (_c = fields.get(name)) == null ? void 0 : _c.options;
121
- if (target) {
122
- const targetField = fields.get(target);
123
- const targetCollection = db.getCollection(targetField.target);
124
- const targetFields = targetCollection.fields;
125
- fieldType = (_d = targetFields.get(name)) == null ? void 0 : _d.type;
126
- fieldOptions = (_e = targetFields.get(name)) == null ? void 0 : _e.options;
127
- field = `${target}.${field}`;
128
- name = `${target}.${name}`;
129
- const targetType = (_f = fields.get(target)) == null ? void 0 : _f.type;
130
- if (!models[target]) {
131
- models[target] = { type: targetType };
132
- }
133
- } else {
134
- field = `${collectionName}.${field}`;
135
- }
136
- return {
137
- ...selected,
138
- field,
139
- name,
140
- type: fieldType,
141
- options: fieldOptions,
142
- alias: selected.alias || name
143
- };
144
- };
145
- const parsedMeasures = (measures == null ? void 0 : measures.map(parseField)) || [];
146
- const parsedDimensions = (dimensions == null ? void 0 : dimensions.map(parseField)) || [];
147
- const parsedOrders = (orders == null ? void 0 : orders.map(parseField)) || [];
148
- const include = Object.entries(models).map(([target, { type }]) => {
149
- let options = {
150
- association: target,
151
- attributes: []
152
- };
153
- if (type === "belongsToMany") {
154
- options["through"] = { attributes: [] };
155
- }
156
- if (type === "belongsToArray") {
157
- const association = associations[target];
158
- if (association) {
159
- options = {
160
- ...options,
161
- ...association.generateInclude()
162
- };
163
- }
164
- }
165
- return options;
166
- });
167
- const filterParser = new import_database.FilterParser(filter, {
168
- collection
92
+ const { dataSource, collection, ...queryOptions } = ctx.action.params.values;
93
+ const repository = getQueryDatabase(ctx, dataSource).getRepository(collection);
94
+ ctx.body = await repository.query({
95
+ context: ctx,
96
+ ...queryOptions,
97
+ timezone: (_a = ctx.get) == null ? void 0 : _a.call(ctx, "x-timezone")
169
98
  });
170
- const { where, include: filterInclude } = filterParser.toSequelizeParams();
171
- if (filterInclude) {
172
- const stack = [...filterInclude];
173
- while (stack.length) {
174
- const item = stack.pop();
175
- const parentCollection = db.getCollection(item.parentCollection || collectionName);
176
- const field = parentCollection.fields.get(item.association);
177
- if ((field == null ? void 0 : field.type) === "belongsToMany") {
178
- item.through = { attributes: [] };
179
- }
180
- if ((field == null ? void 0 : field.target) && ((_a = item.include) == null ? void 0 : _a.length)) {
181
- for (const child of item.include) {
182
- child.parentCollection = field.target;
183
- stack.push(child);
184
- }
185
- }
186
- }
187
- }
188
- ctx.action.params.values = {
189
- ...ctx.action.params.values,
190
- where,
191
- measures: parsedMeasures,
192
- dimensions: parsedDimensions,
193
- orders: parsedOrders,
194
- include: [...include, ...filterInclude || []]
195
- };
196
99
  await next();
197
100
  };
198
101
  const parseVariables = async (ctx, next) => {
102
+ const { mode, contextParams, ...values } = ctx.action.params.values;
103
+ if (mode !== "sql") {
104
+ const resolvedValues = await (0, import_plugin_flow_engine.resolveVariablesTemplate)(ctx, values, contextParams || {});
105
+ ctx.action.params.values = {
106
+ ...ctx.action.params.values,
107
+ ...resolvedValues
108
+ };
109
+ }
199
110
  const { filter } = ctx.action.params.values;
200
111
  ctx.action.params.filter = filter;
201
112
  await import_server.middlewares.parseVariables(ctx, async () => {
@@ -219,47 +130,9 @@ const cacheMiddleware = async (ctx, next) => {
219
130
  await cache.set(uid, ctx.body, (cacheConfig == null ? void 0 : cacheConfig.ttl) * 1e3);
220
131
  }
221
132
  };
222
- const checkPermission = async (ctx, next) => {
223
- var _a, _b, _c;
224
- const { collection, dataSource } = ctx.action.params.values;
225
- const roleNames = ctx.state.currentRoles || ["anonymous"];
226
- const acl = ((_a = ctx.app.dataSourceManager.get(dataSource)) == null ? void 0 : _a.acl) || ctx.app.acl;
227
- const can = acl.can({ roles: roleNames, resource: collection, action: "list" });
228
- if (!can && !roleNames.includes("root")) {
229
- ctx.throw(403, "No permissions");
230
- }
231
- if ((_b = can == null ? void 0 : can.params) == null ? void 0 : _b.filter) {
232
- try {
233
- (0, import_acl.checkFilterParams)(ctx.database.getCollection(collection), (_c = can.params) == null ? void 0 : _c.filter);
234
- } catch (e) {
235
- if (e instanceof import_acl.NoPermissionError) {
236
- ctx.throw(403, "No permissions");
237
- }
238
- }
239
- const filter = ctx.action.params.values.filter || {};
240
- ctx.action.params.values = {
241
- ...ctx.action.params.values,
242
- filter: (0, import_utils.assign)(filter, can == null ? void 0 : can.params.filter, {
243
- filter: "andMerge"
244
- })
245
- };
246
- }
247
- return next();
248
- };
249
- const query = async (ctx, next) => {
250
- const { dataSource } = ctx.action.params.values;
251
- const db = getDB(ctx, dataSource) || ctx.db;
252
- const queryParser = (0, import_query_parser.createQueryParser)(db);
133
+ const queryDataAction = async (ctx, next) => {
253
134
  try {
254
- await (0, import_koa_compose.default)([
255
- checkPermission,
256
- cacheMiddleware,
257
- parseVariables,
258
- parseFieldAndAssociations,
259
- queryParser.parse(),
260
- queryData,
261
- postProcess
262
- ])(ctx, next);
135
+ await (0, import_koa_compose.default)([checkPermission, cacheMiddleware, parseVariables, queryData])(ctx, next);
263
136
  } catch (err) {
264
137
  ctx.throw(500, err);
265
138
  }
@@ -268,9 +141,7 @@ const query = async (ctx, next) => {
268
141
  0 && (module.exports = {
269
142
  cacheMiddleware,
270
143
  checkPermission,
271
- parseFieldAndAssociations,
272
144
  parseVariables,
273
- postProcess,
274
- query,
275
- queryData
145
+ queryData,
146
+ queryDataAction
276
147
  });
@@ -40,10 +40,10 @@ class PluginDataVisualizationServer extends import_server.Plugin {
40
40
  this.app.resourceManager.define({
41
41
  name: "charts",
42
42
  actions: {
43
- query: import_query.query
43
+ queryData: import_query.queryDataAction
44
44
  }
45
45
  });
46
- this.app.acl.allow("charts", "query", "loggedIn");
46
+ this.app.acl.allow("charts", "queryData", "loggedIn");
47
47
  }
48
48
  async load() {
49
49
  this.cache = await this.app.cacheManager.createCache({
@@ -28,12 +28,15 @@ export type OrderProps = {
28
28
  };
29
29
  export type QueryParams = Partial<{
30
30
  uid: string;
31
+ mode: 'builder' | 'sql';
31
32
  dataSource: string;
32
33
  collection: string;
33
34
  measures: MeasureProps[];
34
35
  dimensions: DimensionProps[];
35
36
  orders: OrderProps[];
36
37
  filter: any;
38
+ having: any;
39
+ contextParams: Record<string, unknown>;
37
40
  limit: number;
38
41
  offset: number;
39
42
  sql: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-visualization",
3
- "version": "2.1.0-beta.8",
3
+ "version": "2.2.0-alpha.1",
4
4
  "displayName": "Data visualization",
5
5
  "displayName.ru-RU": "Визуализация данных",
6
6
  "displayName.zh-CN": "数据可视化",
@@ -39,14 +39,17 @@
39
39
  "@nocobase/actions": "2.x",
40
40
  "@nocobase/cache": "2.x",
41
41
  "@nocobase/client": "2.x",
42
+ "@nocobase/client-v2": "2.x",
42
43
  "@nocobase/database": "2.x",
44
+ "@nocobase/plugin-acl": "2.x",
43
45
  "@nocobase/plugin-ai": "2.x",
44
46
  "@nocobase/plugin-data-source-main": "2.x",
47
+ "@nocobase/plugin-flow-engine": "2.x",
45
48
  "@nocobase/server": "2.x",
46
49
  "@nocobase/test": "2.x",
47
50
  "@nocobase/utils": "2.x"
48
51
  },
49
- "gitHead": "5099d561c5467292414c1e77ad6bad3730d97344",
52
+ "gitHead": "303663aba6c6eefa27e6a6435b4c0352074ec40f",
50
53
  "keywords": [
51
54
  "Blocks"
52
55
  ],