@tachybase/plugin-field-formula 1.3.20 → 1.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +2 -2
- package/dist/client/interfaces/formula.d.ts +88 -88
- package/dist/externalVersion.js +4 -6
- package/dist/server/field-formula.d.ts +1 -1
- package/dist/server/field-formula.js +11 -12
- package/dist/server/migrations/20230213161904-alter-field.d.ts +1 -1
- package/dist/server/migrations/20230213161904-alter-field.js +1 -1
- package/dist/server/plugin.d.ts +1 -1
- package/dist/server/plugin.js +3 -3
- package/package.json +9 -16
package/dist/client/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(n,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("@tachybase/client"),require("@tachybase/schema"),require("react/jsx-runtime"),require("react"),require("@
|
|
1
|
+
(function(n,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("@tachybase/client"),require("@tachybase/schema"),require("react/jsx-runtime"),require("react"),require("@tego/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/schema","react/jsx-runtime","react","@tego/client","react-i18next"],r):(n=typeof globalThis!="undefined"?globalThis:n||self,r(n["@tachybase/plugin-field-formula"]={},n["@tachybase/client"],n["@tachybase/schema"],n.jsxRuntime,n.react,n["@tego/client"]))})(this,function(n,r,o,s,N,c){"use strict";var ne=Object.defineProperty,oe=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var V=(n,r,o)=>r in n?ne(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,b=(n,r)=>{for(var o in r||(r={}))_.call(r,o)&&V(n,o,r[o]);if(C)for(var o of C(r))B.call(r,o)&&V(n,o,r[o]);return n},y=(n,r)=>oe(n,ae(r));var G=(n,r)=>{var o={};for(var s in n)_.call(n,s)&&r.indexOf(s)<0&&(o[s]=n[s]);if(n!=null&&C)for(var s of C(n))r.indexOf(s)<0&&B.call(n,s)&&(o[s]=n[s]);return o};var $=(n,r,o)=>new Promise((s,N)=>{var c=p=>{try{F(o.next(p))}catch(S){N(S)}},T=p=>{try{F(o.throw(p))}catch(S){N(S)}},F=p=>p.done?s(p.value):Promise.resolve(p.value).then(c,T);F((o=o.apply(n,r)).next())});const T=e=>{var P;const{value:t="",supports:i=[],useCurrentFields:a,onChange:u}=e,d=r.useCompile(),{interfaces:m}=r.useCollectionManager_deprecated(),v=((P=a==null?void 0:a())!=null?P:[]).filter(l=>i.includes(l.interface)).map(l=>{var E,x;return{label:d(l.uiSchema.title),value:l.name,children:(x=(E=m[l.interface]).usePathOptions)==null?void 0:x.call(E,l)}});return s.jsx(r.Variable.TextArea,{value:t,onChange:u,scope:v})},F={boolean:Boolean,integer:{boolean(e){return Number(e)},number(e){return e>=0?Math.floor(e):Math.ceil(e)},bigint(e){return Number(e)},string(e){const t=Number.parseInt(e,10);return Number.isNaN(t)||!Number.isFinite(t)?null:t},date(e){const t=e.valueOf();return Number.isNaN(t)?null:t}},bigInt:{boolean(e){return Number(e)},number(e){return Math.floor(e>=0?Math.floor(e):Math.ceil(e))},bigint(e){return Number(e)},string(e){const t=Number.parseInt(e,10);return Number.isNaN(t)||!Number.isFinite(t)?null:t},date(e){const t=e.valueOf();return Number.isNaN(t)?null:t}},double:{boolean(e){return Number(e)},number(e){return e},bigint(e){return Number(e)},string(e){const t=Number.parseFloat(e);return Number.isNaN(t)||!Number.isFinite(t)?null:t},date(e){const t=e.valueOf();return Number.isNaN(t)?null:t}},decimal:{boolean(e){return Number(e)},number(e){return e},bigint(e){return e},date(e){const t=e.valueOf();return Number.isNaN(t)?null:t}},string:{boolean(e){return e.toString()},number(e){return e.toString()},bigint(e){return e.toString()},string(e){return e},date(e){return e.toISOString()}},date:{boolean(e){return null},number(e){const t=new Date(e);return Number.isNaN(t.valueOf())?null:t},bigint(e){const t=new Date(Number(e));return Number.isNaN(t.valueOf())?null:t},string(e){const t=Date.parse(e);return Number.isNaN(t)?null:new Date(t)},date(e){return new Date(e)}}};function p(e,t){if(e==null)return null;let i=typeof e;i=="object"&&e instanceof Date&&(i="date");const a=F[t];if(!a)return null;if(typeof a=="function")return a(e);const u=a[i];return u?u(e):null}const S={boolean:r.Checkbox.ReadPretty,integer:r.InputNumber.ReadPretty,bigInt:r.InputNumber.ReadPretty,double:r.InputNumber.ReadPretty,decimal:r.InputNumber.ReadPretty,date:r.DatePicker.ReadPretty,string:r.Input.ReadPretty};function J(){const e=o.useFieldSchema(),t=r.useCollection_deprecated(),{getCollection:i,getCollectionField:a}=r.useCollectionManager_deprecated(),u=e.name.split(".");let d=t;for(let m=0;m<u.length-1;m++){const g=d.getField(u[m]);d=i(g.target)}return a(`${d.name}.${u[u.length-1]}`)}function U(e,t,i){const a=e[t];return Array.isArray(a)?a[i]:a&&typeof a=="object"?a:e}function z(e){var A,R,w;const O=e,{value:t}=O,i=G(O,["value"]),a=o.useFieldSchema(),{dataType:u,expression:d,engine:m="math.js"}=(A=J())!=null?A:{},[g,v]=N.useState(t),{evaluate:P}=c.evaluators.get(m),l=r.useFormBlockContext(),x=o.useField().path.entire,q=x==null?void 0:x.replace(`.${a.name}`,""),Y=q.split(".")[0],Z=parseInt((R=q.split("."))==null?void 0:R[1]);N.useEffect(()=>{v(t)},[t]),o.useFormEffects(()=>{o.onFormValuesChange(te=>{var k;if(a.name.indexOf(".")>=0||!(l!=null&&l.form)||(k=l.form)!=null&&k.readPretty)return;const re=o.toJS(U(te.values,Y,Z));let f;try{f=P(d,re),f=p(f,u)}catch(se){f=null}f==null&&g==null&&v(f),v(f),f!==t&&e.onChange(f)})});const ee=(w=S[u])!=null?w:r.Input;return s.jsx(ee,y(b({},i),{value:u==="double"?c.toFixedByStep(g,e.step):g}))}const D=()=>null;D.Expression=T,D.Result=o.connect(z);const h="field-formula",H=[{dependencies:["dataType"],fulfill:{state:{display:'{{["double", "decimal"].includes($deps[0]) ? "visible" : "none"}}'}}}],M=[{dependencies:["dataType"],fulfill:{state:{display:'{{$deps[0] === "date" ? "visible" : "none"}}'}}}],{defaultProps:K,dateTimeProps:I,operators:L}=r.interfacesProperties,Q={"uiSchema.x-component-props.dateFormat":y(b({},c.lodash.cloneDeep(I["uiSchema.x-component-props.dateFormat"])),{"x-reactions":M}),"uiSchema.x-component-props.showTime":y(b({},c.lodash.cloneDeep(I["uiSchema.x-component-props.showTime"])),{"x-reactions":[...I["uiSchema.x-component-props.showTime"]["x-reactions"],...M]}),"uiSchema.x-component-props.timeFormat":b({},c.lodash.cloneDeep(I["uiSchema.x-component-props.timeFormat"]))};class W extends r.CollectionFieldInterface{constructor(){super(...arguments),this.name="formula",this.type="object",this.group="advanced",this.order=1,this.title=`{{t("Formula", { ns: "${h}" })}}`,this.description=`{{t("Configure and store the results of calculations between multiple field values in the same record, supporting both Math.js and Excel formula functions.", { ns: "${h}" })}}`,this.sortable=!0,this.default={type:"formula",uiSchema:{type:"string","x-component":"Formula.Result","x-component-props":{stringMode:!0,step:"1"},"x-read-pretty":!0}},this.properties=y(b(y(b({},K),{dataType:{type:"string",title:'{{t("Storage type")}}',"x-decorator":"FormItem","x-component":"Select","x-disabled":"{{ !createOnly }}",enum:[{value:"boolean",label:"Boolean"},{value:"integer",label:"Integer"},{value:"bigInt",label:"Big integer"},{value:"double",label:"Double"},{value:"string",label:"String"},{value:"date",label:"Datetime"}],required:!0,default:"double"},"uiSchema.x-component-props.addonAfter":{type:"string",title:'{{t("Suffix")}}',"x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.step":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"0.1",label:"1.0"},{value:"0.01",label:"1.00"},{value:"0.001",label:"1.000"},{value:"0.0001",label:"1.0000"},{value:"0.00001",label:"1.00000"}],"x-reactions":H}}),Q),{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${h}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:Array.from(c.evaluators.getEntities()).reduce((t,[i,a])=>t.concat(b({value:i},a)),[]),required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Expression", { ns: "${h}" })}}`,required:!0,"x-component":"Formula.Expression","x-decorator":"FormItem","x-component-props":{supports:["checkbox","number","percent","integer","number","percent","sequence","input","textarea","email","phone","datetime","createdAt","updatedAt","radioGroup","checkboxGroup","select","multipleSelect"],useCurrentFields:"{{ useCurrentFields }}"},"x-reactions":{dependencies:["engine"],fulfill:{schema:{description:"{{renderExpressionDescription($deps[0])}}"}}},"x-validator"(t,i,{form:a}){const{values:u}=a,{evaluate:d}=c.evaluators.get(u.engine),m=t.trim().replace(/{{\s*([^{}]+)\s*}}/g,"1");try{return d(m),""}catch(g){return r.i18n.t("Expression syntax error",{ns:h})}}}}),this.filterable={operators:L.string},this.titleUsable=!0}}function X(e){const t=c.evaluators.get(e);return t!=null&&t.link?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:r.css`
|
|
2
2
|
&:after {
|
|
3
3
|
content: ':';
|
|
4
4
|
}
|
|
5
5
|
& + a {
|
|
6
6
|
margin-left: 0.25em;
|
|
7
7
|
}
|
|
8
|
-
`,children:r.i18n.t("Syntax references",{ns:
|
|
8
|
+
`,children:r.i18n.t("Syntax references",{ns:h})}),s.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null}class j extends r.Plugin{load(){return $(this,null,function*(){this.app.addComponents({Formula:D}),this.app.addScopes({renderExpressionDescription:X}),this.app.dataSourceManager.addFieldInterfaces([W])})}}n.FormulaFieldPlugin=j,n.default=j,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -61,14 +61,14 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
61
61
|
};
|
|
62
62
|
}[];
|
|
63
63
|
version?: string | (string & {});
|
|
64
|
-
name?: import("
|
|
64
|
+
name?: import("@tachybase/schema").SchemaKey | (string & {});
|
|
65
65
|
title?: any;
|
|
66
66
|
description?: any;
|
|
67
67
|
default?: any;
|
|
68
68
|
readOnly?: boolean | (string & {});
|
|
69
69
|
writeOnly?: boolean | (string & {});
|
|
70
|
-
type?: import("
|
|
71
|
-
enum?: (string & {}) | import("
|
|
70
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
71
|
+
enum?: (string & {}) | import("@tachybase/schema").SchemaEnum<any>;
|
|
72
72
|
const?: any;
|
|
73
73
|
multipleOf?: number | (string & {});
|
|
74
74
|
maximum?: number | (string & {});
|
|
@@ -87,22 +87,22 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
87
87
|
format?: string | (string & {});
|
|
88
88
|
$ref?: string | (string & {});
|
|
89
89
|
$namespace?: string | (string & {});
|
|
90
|
-
definitions?: (string & {}) | import("
|
|
91
|
-
properties?: (string & {}) | import("
|
|
92
|
-
items?: (string & {}) | import("
|
|
93
|
-
additionalItems?: (string & {}) | import("
|
|
90
|
+
definitions?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
91
|
+
properties?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
92
|
+
items?: (string & {}) | import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
93
|
+
additionalItems?: (string & {}) | import("@tachybase/schema").Stringify<{
|
|
94
94
|
[key: symbol]: any;
|
|
95
95
|
[key: `x-${string}`]: any;
|
|
96
96
|
[key: `x-${number}`]: any;
|
|
97
97
|
version?: string;
|
|
98
|
-
name?: import("
|
|
98
|
+
name?: import("@tachybase/schema").SchemaKey;
|
|
99
99
|
title?: any;
|
|
100
100
|
description?: any;
|
|
101
101
|
default?: any;
|
|
102
102
|
readOnly?: boolean;
|
|
103
103
|
writeOnly?: boolean;
|
|
104
|
-
type?: import("
|
|
105
|
-
enum?: import("
|
|
104
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
105
|
+
enum?: import("@tachybase/schema").SchemaEnum<any>;
|
|
106
106
|
const?: any;
|
|
107
107
|
multipleOf?: number;
|
|
108
108
|
maximum?: number;
|
|
@@ -121,12 +121,12 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
121
121
|
format?: string;
|
|
122
122
|
$ref?: string;
|
|
123
123
|
$namespace?: string;
|
|
124
|
-
definitions?: import("
|
|
125
|
-
properties?: import("
|
|
126
|
-
items?: import("
|
|
127
|
-
additionalItems?: import("
|
|
128
|
-
patternProperties?: import("
|
|
129
|
-
additionalProperties?: import("
|
|
124
|
+
definitions?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
125
|
+
properties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
126
|
+
items?: import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
127
|
+
additionalItems?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
128
|
+
patternProperties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
129
|
+
additionalProperties?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
130
130
|
"x-value"?: any;
|
|
131
131
|
"x-index"?: number;
|
|
132
132
|
"x-pattern"?: any;
|
|
@@ -136,7 +136,7 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
136
136
|
"x-decorator-props"?: any;
|
|
137
137
|
"x-component"?: any;
|
|
138
138
|
"x-component-props"?: any;
|
|
139
|
-
"x-reactions"?: import("
|
|
139
|
+
"x-reactions"?: import("@tachybase/schema").SchemaReactions<any>;
|
|
140
140
|
"x-content"?: any;
|
|
141
141
|
"x-data"?: any;
|
|
142
142
|
"x-visible"?: boolean;
|
|
@@ -147,20 +147,20 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
147
147
|
"x-read-pretty"?: boolean;
|
|
148
148
|
"x-compile-omitted"?: string[];
|
|
149
149
|
}>;
|
|
150
|
-
patternProperties?: (string & {}) | import("
|
|
151
|
-
additionalProperties?: (string & {}) | import("
|
|
150
|
+
patternProperties?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
151
|
+
additionalProperties?: (string & {}) | import("@tachybase/schema").Stringify<{
|
|
152
152
|
[key: symbol]: any;
|
|
153
153
|
[key: `x-${string}`]: any;
|
|
154
154
|
[key: `x-${number}`]: any;
|
|
155
155
|
version?: string;
|
|
156
|
-
name?: import("
|
|
156
|
+
name?: import("@tachybase/schema").SchemaKey;
|
|
157
157
|
title?: any;
|
|
158
158
|
description?: any;
|
|
159
159
|
default?: any;
|
|
160
160
|
readOnly?: boolean;
|
|
161
161
|
writeOnly?: boolean;
|
|
162
|
-
type?: import("
|
|
163
|
-
enum?: import("
|
|
162
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
163
|
+
enum?: import("@tachybase/schema").SchemaEnum<any>;
|
|
164
164
|
const?: any;
|
|
165
165
|
multipleOf?: number;
|
|
166
166
|
maximum?: number;
|
|
@@ -179,12 +179,12 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
179
179
|
format?: string;
|
|
180
180
|
$ref?: string;
|
|
181
181
|
$namespace?: string;
|
|
182
|
-
definitions?: import("
|
|
183
|
-
properties?: import("
|
|
184
|
-
items?: import("
|
|
185
|
-
additionalItems?: import("
|
|
186
|
-
patternProperties?: import("
|
|
187
|
-
additionalProperties?: import("
|
|
182
|
+
definitions?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
183
|
+
properties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
184
|
+
items?: import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
185
|
+
additionalItems?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
186
|
+
patternProperties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
187
|
+
additionalProperties?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
188
188
|
"x-value"?: any;
|
|
189
189
|
"x-index"?: number;
|
|
190
190
|
"x-pattern"?: any;
|
|
@@ -194,7 +194,7 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
194
194
|
"x-decorator-props"?: any;
|
|
195
195
|
"x-component"?: any;
|
|
196
196
|
"x-component-props"?: any;
|
|
197
|
-
"x-reactions"?: import("
|
|
197
|
+
"x-reactions"?: import("@tachybase/schema").SchemaReactions<any>;
|
|
198
198
|
"x-content"?: any;
|
|
199
199
|
"x-data"?: any;
|
|
200
200
|
"x-visible"?: boolean;
|
|
@@ -234,14 +234,14 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
234
234
|
};
|
|
235
235
|
})[];
|
|
236
236
|
version?: string | (string & {});
|
|
237
|
-
name?: import("
|
|
237
|
+
name?: import("@tachybase/schema").SchemaKey | (string & {});
|
|
238
238
|
title?: any;
|
|
239
239
|
description?: any;
|
|
240
240
|
default?: any;
|
|
241
241
|
readOnly?: boolean | (string & {});
|
|
242
242
|
writeOnly?: boolean | (string & {});
|
|
243
|
-
type?: import("
|
|
244
|
-
enum?: (string & {}) | import("
|
|
243
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
244
|
+
enum?: (string & {}) | import("@tachybase/schema").SchemaEnum<any>;
|
|
245
245
|
const?: any;
|
|
246
246
|
multipleOf?: number | (string & {});
|
|
247
247
|
maximum?: number | (string & {});
|
|
@@ -260,22 +260,22 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
260
260
|
format?: string | (string & {});
|
|
261
261
|
$ref?: string | (string & {});
|
|
262
262
|
$namespace?: string | (string & {});
|
|
263
|
-
definitions?: (string & {}) | import("
|
|
264
|
-
properties?: (string & {}) | import("
|
|
265
|
-
items?: (string & {}) | import("
|
|
266
|
-
additionalItems?: (string & {}) | import("
|
|
263
|
+
definitions?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
264
|
+
properties?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
265
|
+
items?: (string & {}) | import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
266
|
+
additionalItems?: (string & {}) | import("@tachybase/schema").Stringify<{
|
|
267
267
|
[key: symbol]: any;
|
|
268
268
|
[key: `x-${string}`]: any;
|
|
269
269
|
[key: `x-${number}`]: any;
|
|
270
270
|
version?: string;
|
|
271
|
-
name?: import("
|
|
271
|
+
name?: import("@tachybase/schema").SchemaKey;
|
|
272
272
|
title?: any;
|
|
273
273
|
description?: any;
|
|
274
274
|
default?: any;
|
|
275
275
|
readOnly?: boolean;
|
|
276
276
|
writeOnly?: boolean;
|
|
277
|
-
type?: import("
|
|
278
|
-
enum?: import("
|
|
277
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
278
|
+
enum?: import("@tachybase/schema").SchemaEnum<any>;
|
|
279
279
|
const?: any;
|
|
280
280
|
multipleOf?: number;
|
|
281
281
|
maximum?: number;
|
|
@@ -294,12 +294,12 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
294
294
|
format?: string;
|
|
295
295
|
$ref?: string;
|
|
296
296
|
$namespace?: string;
|
|
297
|
-
definitions?: import("
|
|
298
|
-
properties?: import("
|
|
299
|
-
items?: import("
|
|
300
|
-
additionalItems?: import("
|
|
301
|
-
patternProperties?: import("
|
|
302
|
-
additionalProperties?: import("
|
|
297
|
+
definitions?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
298
|
+
properties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
299
|
+
items?: import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
300
|
+
additionalItems?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
301
|
+
patternProperties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
302
|
+
additionalProperties?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
303
303
|
"x-value"?: any;
|
|
304
304
|
"x-index"?: number;
|
|
305
305
|
"x-pattern"?: any;
|
|
@@ -309,7 +309,7 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
309
309
|
"x-decorator-props"?: any;
|
|
310
310
|
"x-component"?: any;
|
|
311
311
|
"x-component-props"?: any;
|
|
312
|
-
"x-reactions"?: import("
|
|
312
|
+
"x-reactions"?: import("@tachybase/schema").SchemaReactions<any>;
|
|
313
313
|
"x-content"?: any;
|
|
314
314
|
"x-data"?: any;
|
|
315
315
|
"x-visible"?: boolean;
|
|
@@ -320,20 +320,20 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
320
320
|
"x-read-pretty"?: boolean;
|
|
321
321
|
"x-compile-omitted"?: string[];
|
|
322
322
|
}>;
|
|
323
|
-
patternProperties?: (string & {}) | import("
|
|
324
|
-
additionalProperties?: (string & {}) | import("
|
|
323
|
+
patternProperties?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
324
|
+
additionalProperties?: (string & {}) | import("@tachybase/schema").Stringify<{
|
|
325
325
|
[key: symbol]: any;
|
|
326
326
|
[key: `x-${string}`]: any;
|
|
327
327
|
[key: `x-${number}`]: any;
|
|
328
328
|
version?: string;
|
|
329
|
-
name?: import("
|
|
329
|
+
name?: import("@tachybase/schema").SchemaKey;
|
|
330
330
|
title?: any;
|
|
331
331
|
description?: any;
|
|
332
332
|
default?: any;
|
|
333
333
|
readOnly?: boolean;
|
|
334
334
|
writeOnly?: boolean;
|
|
335
|
-
type?: import("
|
|
336
|
-
enum?: import("
|
|
335
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
336
|
+
enum?: import("@tachybase/schema").SchemaEnum<any>;
|
|
337
337
|
const?: any;
|
|
338
338
|
multipleOf?: number;
|
|
339
339
|
maximum?: number;
|
|
@@ -352,12 +352,12 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
352
352
|
format?: string;
|
|
353
353
|
$ref?: string;
|
|
354
354
|
$namespace?: string;
|
|
355
|
-
definitions?: import("
|
|
356
|
-
properties?: import("
|
|
357
|
-
items?: import("
|
|
358
|
-
additionalItems?: import("
|
|
359
|
-
patternProperties?: import("
|
|
360
|
-
additionalProperties?: import("
|
|
355
|
+
definitions?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
356
|
+
properties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
357
|
+
items?: import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
358
|
+
additionalItems?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
359
|
+
patternProperties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
360
|
+
additionalProperties?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
361
361
|
"x-value"?: any;
|
|
362
362
|
"x-index"?: number;
|
|
363
363
|
"x-pattern"?: any;
|
|
@@ -367,7 +367,7 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
367
367
|
"x-decorator-props"?: any;
|
|
368
368
|
"x-component"?: any;
|
|
369
369
|
"x-component-props"?: any;
|
|
370
|
-
"x-reactions"?: import("
|
|
370
|
+
"x-reactions"?: import("@tachybase/schema").SchemaReactions<any>;
|
|
371
371
|
"x-content"?: any;
|
|
372
372
|
"x-data"?: any;
|
|
373
373
|
"x-visible"?: boolean;
|
|
@@ -402,14 +402,14 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
402
402
|
[x: `x-${string}`]: any;
|
|
403
403
|
[x: `x-${number}`]: any;
|
|
404
404
|
version?: string | (string & {});
|
|
405
|
-
name?: import("
|
|
405
|
+
name?: import("@tachybase/schema").SchemaKey | (string & {});
|
|
406
406
|
title?: any;
|
|
407
407
|
description?: any;
|
|
408
408
|
default?: any;
|
|
409
409
|
readOnly?: boolean | (string & {});
|
|
410
410
|
writeOnly?: boolean | (string & {});
|
|
411
|
-
type?: import("
|
|
412
|
-
enum?: (string & {}) | import("
|
|
411
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
412
|
+
enum?: (string & {}) | import("@tachybase/schema").SchemaEnum<any>;
|
|
413
413
|
const?: any;
|
|
414
414
|
multipleOf?: number | (string & {});
|
|
415
415
|
maximum?: number | (string & {});
|
|
@@ -428,22 +428,22 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
428
428
|
format?: string | (string & {});
|
|
429
429
|
$ref?: string | (string & {});
|
|
430
430
|
$namespace?: string | (string & {});
|
|
431
|
-
definitions?: (string & {}) | import("
|
|
432
|
-
properties?: (string & {}) | import("
|
|
433
|
-
items?: (string & {}) | import("
|
|
434
|
-
additionalItems?: (string & {}) | import("
|
|
431
|
+
definitions?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
432
|
+
properties?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
433
|
+
items?: (string & {}) | import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
434
|
+
additionalItems?: (string & {}) | import("@tachybase/schema").Stringify<{
|
|
435
435
|
[key: symbol]: any;
|
|
436
436
|
[key: `x-${string}`]: any;
|
|
437
437
|
[key: `x-${number}`]: any;
|
|
438
438
|
version?: string;
|
|
439
|
-
name?: import("
|
|
439
|
+
name?: import("@tachybase/schema").SchemaKey;
|
|
440
440
|
title?: any;
|
|
441
441
|
description?: any;
|
|
442
442
|
default?: any;
|
|
443
443
|
readOnly?: boolean;
|
|
444
444
|
writeOnly?: boolean;
|
|
445
|
-
type?: import("
|
|
446
|
-
enum?: import("
|
|
445
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
446
|
+
enum?: import("@tachybase/schema").SchemaEnum<any>;
|
|
447
447
|
const?: any;
|
|
448
448
|
multipleOf?: number;
|
|
449
449
|
maximum?: number;
|
|
@@ -462,12 +462,12 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
462
462
|
format?: string;
|
|
463
463
|
$ref?: string;
|
|
464
464
|
$namespace?: string;
|
|
465
|
-
definitions?: import("
|
|
466
|
-
properties?: import("
|
|
467
|
-
items?: import("
|
|
468
|
-
additionalItems?: import("
|
|
469
|
-
patternProperties?: import("
|
|
470
|
-
additionalProperties?: import("
|
|
465
|
+
definitions?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
466
|
+
properties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
467
|
+
items?: import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
468
|
+
additionalItems?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
469
|
+
patternProperties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
470
|
+
additionalProperties?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
471
471
|
"x-value"?: any;
|
|
472
472
|
"x-index"?: number;
|
|
473
473
|
"x-pattern"?: any;
|
|
@@ -477,7 +477,7 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
477
477
|
"x-decorator-props"?: any;
|
|
478
478
|
"x-component"?: any;
|
|
479
479
|
"x-component-props"?: any;
|
|
480
|
-
"x-reactions"?: import("
|
|
480
|
+
"x-reactions"?: import("@tachybase/schema").SchemaReactions<any>;
|
|
481
481
|
"x-content"?: any;
|
|
482
482
|
"x-data"?: any;
|
|
483
483
|
"x-visible"?: boolean;
|
|
@@ -488,20 +488,20 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
488
488
|
"x-read-pretty"?: boolean;
|
|
489
489
|
"x-compile-omitted"?: string[];
|
|
490
490
|
}>;
|
|
491
|
-
patternProperties?: (string & {}) | import("
|
|
492
|
-
additionalProperties?: (string & {}) | import("
|
|
491
|
+
patternProperties?: (string & {}) | import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
492
|
+
additionalProperties?: (string & {}) | import("@tachybase/schema").Stringify<{
|
|
493
493
|
[key: symbol]: any;
|
|
494
494
|
[key: `x-${string}`]: any;
|
|
495
495
|
[key: `x-${number}`]: any;
|
|
496
496
|
version?: string;
|
|
497
|
-
name?: import("
|
|
497
|
+
name?: import("@tachybase/schema").SchemaKey;
|
|
498
498
|
title?: any;
|
|
499
499
|
description?: any;
|
|
500
500
|
default?: any;
|
|
501
501
|
readOnly?: boolean;
|
|
502
502
|
writeOnly?: boolean;
|
|
503
|
-
type?: import("
|
|
504
|
-
enum?: import("
|
|
503
|
+
type?: import("@tachybase/schema").SchemaTypes;
|
|
504
|
+
enum?: import("@tachybase/schema").SchemaEnum<any>;
|
|
505
505
|
const?: any;
|
|
506
506
|
multipleOf?: number;
|
|
507
507
|
maximum?: number;
|
|
@@ -520,12 +520,12 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
520
520
|
format?: string;
|
|
521
521
|
$ref?: string;
|
|
522
522
|
$namespace?: string;
|
|
523
|
-
definitions?: import("
|
|
524
|
-
properties?: import("
|
|
525
|
-
items?: import("
|
|
526
|
-
additionalItems?: import("
|
|
527
|
-
patternProperties?: import("
|
|
528
|
-
additionalProperties?: import("
|
|
523
|
+
definitions?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
524
|
+
properties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
525
|
+
items?: import("@tachybase/schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
526
|
+
additionalItems?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
527
|
+
patternProperties?: import("@tachybase/schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
528
|
+
additionalProperties?: import("@tachybase/schema").Stringify</*elided*/ any>;
|
|
529
529
|
"x-value"?: any;
|
|
530
530
|
"x-index"?: number;
|
|
531
531
|
"x-pattern"?: any;
|
|
@@ -535,7 +535,7 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
535
535
|
"x-decorator-props"?: any;
|
|
536
536
|
"x-component"?: any;
|
|
537
537
|
"x-component-props"?: any;
|
|
538
|
-
"x-reactions"?: import("
|
|
538
|
+
"x-reactions"?: import("@tachybase/schema").SchemaReactions<any>;
|
|
539
539
|
"x-content"?: any;
|
|
540
540
|
"x-data"?: any;
|
|
541
541
|
"x-visible"?: boolean;
|
|
@@ -555,7 +555,7 @@ export declare class FormulaFieldInterface extends CollectionFieldInterface {
|
|
|
555
555
|
"x-decorator-props"?: any;
|
|
556
556
|
"x-component"?: any;
|
|
557
557
|
"x-component-props"?: any;
|
|
558
|
-
"x-reactions"?: (string & {}) | import("
|
|
558
|
+
"x-reactions"?: (string & {}) | import("@tachybase/schema").SchemaReactions<any>;
|
|
559
559
|
"x-content"?: any;
|
|
560
560
|
"x-data"?: any;
|
|
561
561
|
"x-visible"?: boolean | (string & {});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "1.3.
|
|
2
|
+
"@tachybase/client": "1.3.22",
|
|
3
3
|
"react": "18.3.1",
|
|
4
|
-
"@
|
|
5
|
-
"@
|
|
6
|
-
"@tachybase/database": "1.3.20",
|
|
7
|
-
"@tachybase/server": "1.3.20",
|
|
4
|
+
"@tego/client": "1.3.39",
|
|
5
|
+
"@tego/server": "1.3.39",
|
|
8
6
|
"react-i18next": "15.2.0",
|
|
9
|
-
"@tachybase/schema": "1.3.
|
|
7
|
+
"@tachybase/schema": "1.3.39"
|
|
10
8
|
};
|
|
@@ -20,19 +20,18 @@ __export(field_formula_exports, {
|
|
|
20
20
|
FormulaField: () => FormulaField
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(field_formula_exports);
|
|
23
|
-
var
|
|
24
|
-
var import_evaluators = require("@tachybase/evaluators");
|
|
23
|
+
var import_server = require("@tego/server");
|
|
25
24
|
var import_utils = require("../utils");
|
|
26
25
|
const DataTypeMap = {
|
|
27
|
-
boolean:
|
|
28
|
-
integer:
|
|
29
|
-
bigInt:
|
|
30
|
-
double:
|
|
31
|
-
decimal:
|
|
32
|
-
string:
|
|
33
|
-
date:
|
|
26
|
+
boolean: import_server.DataTypes.BOOLEAN,
|
|
27
|
+
integer: import_server.DataTypes.INTEGER,
|
|
28
|
+
bigInt: import_server.DataTypes.BIGINT,
|
|
29
|
+
double: import_server.DataTypes.DOUBLE,
|
|
30
|
+
decimal: import_server.DataTypes.DECIMAL,
|
|
31
|
+
string: import_server.DataTypes.STRING,
|
|
32
|
+
date: import_server.DataTypes.DATE(3)
|
|
34
33
|
};
|
|
35
|
-
class FormulaField extends
|
|
34
|
+
class FormulaField extends import_server.Field {
|
|
36
35
|
constructor() {
|
|
37
36
|
super(...arguments);
|
|
38
37
|
this.initFieldData = async ({ transaction }) => {
|
|
@@ -91,11 +90,11 @@ class FormulaField extends import_database.Field {
|
|
|
91
90
|
}
|
|
92
91
|
get dataType() {
|
|
93
92
|
const { dataType } = this.options;
|
|
94
|
-
return DataTypeMap[dataType] ??
|
|
93
|
+
return DataTypeMap[dataType] ?? import_server.DataTypes.DOUBLE;
|
|
95
94
|
}
|
|
96
95
|
calculate(scope) {
|
|
97
96
|
const { expression, engine = "math.js", dataType = "double" } = this.options;
|
|
98
|
-
const evaluate =
|
|
97
|
+
const evaluate = import_server.evaluators.get(engine);
|
|
99
98
|
try {
|
|
100
99
|
const result = evaluate(expression, scope);
|
|
101
100
|
return (0, import_utils.toDbType)(result, dataType);
|
|
@@ -20,7 +20,7 @@ __export(alter_field_exports, {
|
|
|
20
20
|
default: () => alter_field_default
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(alter_field_exports);
|
|
23
|
-
var import_server = require("@
|
|
23
|
+
var import_server = require("@tego/server");
|
|
24
24
|
class alter_field_default extends import_server.Migration {
|
|
25
25
|
constructor() {
|
|
26
26
|
super(...arguments);
|
package/dist/server/plugin.d.ts
CHANGED
package/dist/server/plugin.js
CHANGED
|
@@ -21,8 +21,8 @@ __export(plugin_exports, {
|
|
|
21
21
|
default: () => plugin_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(plugin_exports);
|
|
24
|
-
var
|
|
25
|
-
var import_server = require("@
|
|
24
|
+
var import_node_path = require("node:path");
|
|
25
|
+
var import_server = require("@tego/server");
|
|
26
26
|
var import_field_formula = require("./field-formula");
|
|
27
27
|
class FormulaFieldPlugin extends import_server.Plugin {
|
|
28
28
|
afterAdd() {
|
|
@@ -33,7 +33,7 @@ class FormulaFieldPlugin extends import_server.Plugin {
|
|
|
33
33
|
});
|
|
34
34
|
this.db.addMigrations({
|
|
35
35
|
namespace: this.name,
|
|
36
|
-
directory: (0,
|
|
36
|
+
directory: (0, import_node_path.resolve)(__dirname, "./migrations"),
|
|
37
37
|
context: {
|
|
38
38
|
plugin: this
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-field-formula",
|
|
3
3
|
"displayName": "Field: Formula",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.22",
|
|
5
5
|
"description": "Configure and store the results of calculations between multiple field values in the same record, supporting both Math.js and Excel formula functions.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Collection fields"
|
|
@@ -10,22 +10,15 @@
|
|
|
10
10
|
"main": "./dist/server/index.js",
|
|
11
11
|
"dependencies": {},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"@
|
|
16
|
-
"@
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"@tachybase/
|
|
20
|
-
"@tachybase/test": "1.3.20",
|
|
21
|
-
"@tachybase/database": "1.3.20",
|
|
22
|
-
"@tachybase/client": "1.3.20",
|
|
23
|
-
"@tachybase/utils": "1.3.20",
|
|
24
|
-
"@tachybase/server": "1.3.20"
|
|
13
|
+
"@tachybase/schema": "^1.3.39",
|
|
14
|
+
"@tachybase/test": "^1.3.39",
|
|
15
|
+
"@tego/client": "^1.3.39",
|
|
16
|
+
"@tego/server": "^1.3.39",
|
|
17
|
+
"react": "18.3.1",
|
|
18
|
+
"react-i18next": "15.2.0",
|
|
19
|
+
"@tachybase/client": "1.3.22"
|
|
25
20
|
},
|
|
26
21
|
"description.zh-CN": "可以配置并存储同一条记录的多字段值之间的计算结果,支持 Math.js 和 Excel formula functions 两种引擎",
|
|
27
22
|
"displayName.zh-CN": "数据表字段:公式",
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "tachybase-build --no-dts @tachybase/plugin-field-formula"
|
|
30
|
-
}
|
|
23
|
+
"scripts": {}
|
|
31
24
|
}
|