@revisium/formula 0.3.0 → 0.5.0
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/README.md +32 -0
- package/dist/chunk-INF4CK6N.js +1419 -0
- package/dist/chunk-INF4CK6N.js.map +1 -0
- package/dist/chunk-KYBZYJ7E.cjs +1453 -0
- package/dist/chunk-KYBZYJ7E.cjs.map +1 -0
- package/dist/editor/index.cjs +6 -7
- package/dist/editor/index.d.cts +1 -1
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +1 -2
- package/dist/formula-spec.cjs +91 -3
- package/dist/formula-spec.cjs.map +1 -1
- package/dist/formula-spec.js +91 -3
- package/dist/formula-spec.js.map +1 -1
- package/dist/{index-DO2EZ7U6.d.cts → index-BEXpS2D6.d.cts} +79 -2
- package/dist/{index-DO2EZ7U6.d.ts → index-BEXpS2D6.d.ts} +79 -2
- package/dist/index.cjs +17 -14
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/package.json +2 -2
- package/dist/chunk-4JNGUHMF.js +0 -1022
- package/dist/chunk-4JNGUHMF.js.map +0 -1
- package/dist/chunk-JJ72EVIZ.cjs +0 -1035
- package/dist/chunk-JJ72EVIZ.cjs.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-Q7SFCCGT.cjs +0 -11
- package/dist/chunk-Q7SFCCGT.cjs.map +0 -1
package/dist/formula-spec.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import './chunk-PZ5AY32C.js';
|
|
2
|
-
|
|
3
1
|
// src/formula-spec.ts
|
|
4
2
|
var formulaSpec = {
|
|
5
3
|
version: "1.1",
|
|
@@ -366,12 +364,50 @@ var formulaSpec = {
|
|
|
366
364
|
"items[-2].price // second to last"
|
|
367
365
|
],
|
|
368
366
|
dependenciesExtracted: ['["items[0].price"]', '["items[-1].name"]']
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: "root_path",
|
|
370
|
+
description: "Absolute path reference starting with /. Always resolves from root data, even inside array item formulas",
|
|
371
|
+
minVersion: "1.1",
|
|
372
|
+
examples: [
|
|
373
|
+
"/taxRate",
|
|
374
|
+
"/config.tax",
|
|
375
|
+
"price * (1 + /taxRate)",
|
|
376
|
+
"price * /config.multiplier"
|
|
377
|
+
],
|
|
378
|
+
dependenciesExtracted: ['["/taxRate"]', '["/config.tax"]']
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "relative_path",
|
|
382
|
+
description: "Relative path reference starting with ../. Resolves from parent context (root data) when inside array item formulas",
|
|
383
|
+
minVersion: "1.1",
|
|
384
|
+
examples: [
|
|
385
|
+
"../discount",
|
|
386
|
+
"../settings.multiplier",
|
|
387
|
+
"price * (1 - ../discount)",
|
|
388
|
+
"price * ../settings.multiplier"
|
|
389
|
+
],
|
|
390
|
+
dependenciesExtracted: ['["../discount"]', '["../settings.multiplier"]']
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: "function_named_fields",
|
|
394
|
+
description: "Fields can have the same name as built-in functions (max, min, sum, etc.). Built-in functions are always checked first when a function call is made",
|
|
395
|
+
minVersion: "1.0",
|
|
396
|
+
examples: [
|
|
397
|
+
"max(max, 0)",
|
|
398
|
+
"min(min, 100)",
|
|
399
|
+
"max(max - field.min, 0)",
|
|
400
|
+
"round(round * 2)"
|
|
401
|
+
]
|
|
369
402
|
}
|
|
370
403
|
],
|
|
371
404
|
versionDetection: [
|
|
372
405
|
{ feature: "Simple refs, arithmetic, comparisons", minVersion: "1.0" },
|
|
406
|
+
{ feature: "Function-named fields (max(max, 0))", minVersion: "1.0" },
|
|
373
407
|
{ feature: "Nested paths (a.b)", minVersion: "1.1" },
|
|
374
|
-
{ feature: "Array index ([0], [-1])", minVersion: "1.1" }
|
|
408
|
+
{ feature: "Array index ([0], [-1])", minVersion: "1.1" },
|
|
409
|
+
{ feature: "Absolute paths (/field)", minVersion: "1.1" },
|
|
410
|
+
{ feature: "Relative paths (../field)", minVersion: "1.1" }
|
|
375
411
|
],
|
|
376
412
|
parseResult: {
|
|
377
413
|
description: "The parser automatically detects the minimum required version",
|
|
@@ -462,6 +498,58 @@ evaluate('price > 100', { price: 150 })
|
|
|
462
498
|
|
|
463
499
|
evaluate('a + b * c', { a: 1, b: 2, c: 3 })
|
|
464
500
|
// 7`
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
name: "Function-named fields",
|
|
504
|
+
description: "Fields can have the same name as built-in functions",
|
|
505
|
+
code: `// Built-in functions take precedence in function calls
|
|
506
|
+
evaluate('max(max, 0)', { max: 10 })
|
|
507
|
+
// 10 (max() function, then max field)
|
|
508
|
+
|
|
509
|
+
evaluate('max(max - field.min, 0)', { max: 100, field: { min: 20 } })
|
|
510
|
+
// 80
|
|
511
|
+
|
|
512
|
+
evaluate('round(round * 2)', { round: 3.7 })
|
|
513
|
+
// 7
|
|
514
|
+
|
|
515
|
+
// Field named "sum" doesn't conflict with sum() function
|
|
516
|
+
evaluate('sum(values) + sum', { values: [1, 2, 3], sum: 10 })
|
|
517
|
+
// 16`
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
name: "Evaluate with context (array items)",
|
|
521
|
+
description: "Use evaluateWithContext() for array item formulas with path resolution",
|
|
522
|
+
code: `// Absolute path: /field always resolves from root
|
|
523
|
+
evaluateWithContext('price * (1 + /taxRate)', {
|
|
524
|
+
rootData: { taxRate: 0.1, items: [{ price: 100 }] },
|
|
525
|
+
itemData: { price: 100 },
|
|
526
|
+
currentPath: 'items[0]'
|
|
527
|
+
})
|
|
528
|
+
// 110
|
|
529
|
+
|
|
530
|
+
// Nested absolute path
|
|
531
|
+
evaluateWithContext('price * /config.multiplier', {
|
|
532
|
+
rootData: { config: { multiplier: 1.5 }, items: [] },
|
|
533
|
+
itemData: { price: 100 },
|
|
534
|
+
currentPath: 'items[0]'
|
|
535
|
+
})
|
|
536
|
+
// 150
|
|
537
|
+
|
|
538
|
+
// Relative path: ../field resolves from parent (root)
|
|
539
|
+
evaluateWithContext('price * (1 - ../discount)', {
|
|
540
|
+
rootData: { discount: 0.2, items: [] },
|
|
541
|
+
itemData: { price: 100 },
|
|
542
|
+
currentPath: 'items[0]'
|
|
543
|
+
})
|
|
544
|
+
// 80
|
|
545
|
+
|
|
546
|
+
// itemData takes precedence over rootData for same field
|
|
547
|
+
evaluateWithContext('value + 10', {
|
|
548
|
+
rootData: { value: 100 },
|
|
549
|
+
itemData: { value: 50 },
|
|
550
|
+
currentPath: 'items[0]'
|
|
551
|
+
})
|
|
552
|
+
// 60`
|
|
465
553
|
}
|
|
466
554
|
],
|
|
467
555
|
schemaUsage: {
|
package/dist/formula-spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/formula-spec.ts"],"names":[],"mappings":";;;AAuDO,IAAM,WAAA,GAA2B;AAAA,EACtC,OAAA,EAAS,KAAA;AAAA,EACT,WAAA,EACE,8GAAA;AAAA,EAEF,MAAA,EAAQ;AAAA,IACN,eAAA,EAAiB;AAAA,MACf,iDAAA;AAAA,MACA,mDAAA;AAAA,MACA,qDAAA;AAAA,MACA;AAAA,KACF;AAAA,IACA,mBAAA,EAAqB;AAAA,MACnB,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,kCAAA,EAAmC;AAAA,MACjE,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,aAAA,EAAc;AAAA,MAC5C,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,gBAAA,EAAiB;AAAA,MAC/C,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,UAAA,EAAW;AAAA,MACzC,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,oBAAA;AAAqB,KACrD;AAAA,IACA,mBAAA,EAAqB;AAAA,MACnB,EAAE,QAAA,EAAU,IAAA,EAAM,WAAA,EAAa,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MAAA,EAAQ;AAAA,KACV;AAAA,IACA;AAAA,MACE,UAAA,EAAY,uBAAA;AAAA,MACZ,WAAA,EAAa,gBAAA;AAAA,MACb,MAAA,EAAQ;AAAA,KACV;AAAA,IACA;AAAA,MACE,UAAA,EAAY,iCAAA;AAAA,MACZ,WAAA,EAAa,kCAAA;AAAA,MACb,MAAA,EAAQ;AAAA;AACV,GACF;AAAA,EAEA,WAAA,EAAa;AAAA,IACX;AAAA,MACE,IAAA,EAAM,0BAAA;AAAA,MACN,WAAA,EAAa,qCAAA;AAAA,MACb,IAAA,EAAM,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,KAMR;AAAA,IACA;AAAA,MACE,IAAA,EAAM,oBAAA;AAAA,MACN,WAAA,EAAa,4CAAA;AAAA,MACb,IAAA,EAAM,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,KAMR;AAAA,IACA;AAAA,MACE,IAAA,EAAM,qBAAA;AAAA,MACN,WAAA,EAAa,0CAAA;AAAA,MACb,IAAA,EAAM,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,KAMR;AAAA,IACA;AAAA,MACE,IAAA,EAAM,sBAAA;AAAA,MACN,WAAA,EAAa,oCAAA;AAAA,MACb,IAAA,EAAM,CAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA,IAAA;AAAA;AAcR,GACF;AAAA,EAEA,WAAA,EAAa;AAAA,IACX,SAAA,EACE,0EAAA;AAAA,IACF,UAAA,EAAY,CAAC,QAAA,EAAU,QAAA,EAAU,SAAS,CAAA;AAAA,IAC1C,KAAA,EAAO;AAAA,MACL,0DAAA;AAAA,MACA,sDAAA;AAAA,MACA,6DAAA;AAAA,MACA;AAAA;AACF;AAEJ","file":"formula-spec.js","sourcesContent":["export interface FunctionSpec {\n name: string;\n description: string;\n signature: string;\n returnType: 'string' | 'number' | 'boolean' | 'any';\n examples: string[];\n}\n\nexport interface FormulaSpec {\n version: string;\n description: string;\n syntax: {\n fieldReferences: string[];\n arithmeticOperators: { operator: string; description: string }[];\n comparisonOperators: { operator: string; description: string }[];\n logicalOperators: { operator: string; description: string }[];\n other: string[];\n };\n functions: {\n string: FunctionSpec[];\n numeric: FunctionSpec[];\n boolean: FunctionSpec[];\n array: FunctionSpec[];\n conversion: FunctionSpec[];\n conditional: FunctionSpec[];\n };\n features: {\n name: string;\n description: string;\n minVersion: string;\n examples: string[];\n dependenciesExtracted?: string[];\n }[];\n versionDetection: { feature: string; minVersion: string }[];\n parseResult: {\n description: string;\n interface: string;\n };\n examples: {\n expression: string;\n description: string;\n result?: string;\n }[];\n apiExamples: {\n name: string;\n description: string;\n code: string;\n }[];\n schemaUsage: {\n structure: string;\n fieldTypes: string[];\n rules: string[];\n };\n}\n\nexport const formulaSpec: FormulaSpec = {\n version: '1.1',\n description:\n 'Formula expressions for computed fields. Formulas reference other fields and calculate values automatically.',\n\n syntax: {\n fieldReferences: [\n 'Simple field: fieldName (e.g., price, quantity)',\n 'Nested path: object.property (e.g., stats.damage)',\n 'Array index: array[0] or array[-1] for last element',\n 'Combined: items[0].price, user.addresses[-1].city',\n ],\n arithmeticOperators: [\n { operator: '+', description: 'Addition or string concatenation' },\n { operator: '-', description: 'Subtraction' },\n { operator: '*', description: 'Multiplication' },\n { operator: '/', description: 'Division' },\n { operator: '%', description: 'Modulo (remainder)' },\n ],\n comparisonOperators: [\n { operator: '==', description: 'Equal' },\n { operator: '!=', description: 'Not equal' },\n { operator: '>', description: 'Greater than' },\n { operator: '<', description: 'Less than' },\n { operator: '>=', description: 'Greater or equal' },\n { operator: '<=', description: 'Less or equal' },\n ],\n logicalOperators: [\n { operator: '&&', description: 'Logical AND' },\n { operator: '||', description: 'Logical OR' },\n { operator: '!', description: 'Logical NOT' },\n ],\n other: ['Parentheses: (a + b) * c', 'Unary minus: -value, a + -b'],\n },\n\n functions: {\n string: [\n {\n name: 'concat',\n description: 'Concatenate multiple values into a single string',\n signature: 'concat(value1, value2, ...)',\n returnType: 'string',\n examples: [\n 'concat(firstName, \" \", lastName) // \"John Doe\"',\n 'concat(\"Price: \", price, \" USD\") // \"Price: 100 USD\"',\n ],\n },\n {\n name: 'upper',\n description: 'Convert string to uppercase',\n signature: 'upper(text)',\n returnType: 'string',\n examples: ['upper(name) // \"HELLO\"'],\n },\n {\n name: 'lower',\n description: 'Convert string to lowercase',\n signature: 'lower(text)',\n returnType: 'string',\n examples: ['lower(name) // \"hello\"'],\n },\n {\n name: 'trim',\n description: 'Remove whitespace from both ends of a string',\n signature: 'trim(text)',\n returnType: 'string',\n examples: ['trim(name) // \"hello\" from \" hello \"'],\n },\n {\n name: 'left',\n description: 'Extract characters from the beginning of a string',\n signature: 'left(text, count)',\n returnType: 'string',\n examples: ['left(name, 3) // \"hel\" from \"hello\"'],\n },\n {\n name: 'right',\n description: 'Extract characters from the end of a string',\n signature: 'right(text, count)',\n returnType: 'string',\n examples: ['right(name, 3) // \"llo\" from \"hello\"'],\n },\n {\n name: 'replace',\n description: 'Replace first occurrence of a substring',\n signature: 'replace(text, search, replacement)',\n returnType: 'string',\n examples: ['replace(name, \"o\", \"0\") // \"hell0\" from \"hello\"'],\n },\n {\n name: 'join',\n description: 'Join array elements into a string',\n signature: 'join(array, separator?)',\n returnType: 'string',\n examples: ['join(tags) // \"a,b,c\"', 'join(tags, \" | \") // \"a | b | c\"'],\n },\n ],\n numeric: [\n {\n name: 'round',\n description: 'Round a number to specified decimal places',\n signature: 'round(number, decimals?)',\n returnType: 'number',\n examples: ['round(3.14159, 2) // 3.14', 'round(3.5) // 4'],\n },\n {\n name: 'floor',\n description: 'Round down to the nearest integer',\n signature: 'floor(number)',\n returnType: 'number',\n examples: ['floor(3.7) // 3'],\n },\n {\n name: 'ceil',\n description: 'Round up to the nearest integer',\n signature: 'ceil(number)',\n returnType: 'number',\n examples: ['ceil(3.2) // 4'],\n },\n {\n name: 'abs',\n description: 'Get the absolute value',\n signature: 'abs(number)',\n returnType: 'number',\n examples: ['abs(-5) // 5'],\n },\n {\n name: 'sqrt',\n description: 'Calculate the square root',\n signature: 'sqrt(number)',\n returnType: 'number',\n examples: ['sqrt(16) // 4'],\n },\n {\n name: 'pow',\n description: 'Raise a number to a power',\n signature: 'pow(base, exponent)',\n returnType: 'number',\n examples: ['pow(2, 3) // 8'],\n },\n {\n name: 'min',\n description: 'Get the minimum of multiple values',\n signature: 'min(value1, value2, ...)',\n returnType: 'number',\n examples: ['min(a, b, c) // smallest value'],\n },\n {\n name: 'max',\n description: 'Get the maximum of multiple values',\n signature: 'max(value1, value2, ...)',\n returnType: 'number',\n examples: ['max(a, b, c) // largest value'],\n },\n {\n name: 'log',\n description: 'Calculate the natural logarithm',\n signature: 'log(number)',\n returnType: 'number',\n examples: ['log(10) // 2.302...'],\n },\n {\n name: 'log10',\n description: 'Calculate the base-10 logarithm',\n signature: 'log10(number)',\n returnType: 'number',\n examples: ['log10(100) // 2'],\n },\n {\n name: 'exp',\n description: 'Calculate e raised to a power',\n signature: 'exp(number)',\n returnType: 'number',\n examples: ['exp(1) // 2.718...'],\n },\n {\n name: 'sign',\n description: 'Get the sign of a number (-1, 0, or 1)',\n signature: 'sign(number)',\n returnType: 'number',\n examples: ['sign(-5) // -1', 'sign(0) // 0', 'sign(5) // 1'],\n },\n {\n name: 'length',\n description: 'Get the length of a string or array',\n signature: 'length(value)',\n returnType: 'number',\n examples: ['length(name) // 5 from \"hello\"', 'length(items) // 3'],\n },\n ],\n boolean: [\n {\n name: 'and',\n description: 'Logical AND of two values',\n signature: 'and(a, b)',\n returnType: 'boolean',\n examples: ['and(isActive, hasPermission) // true if both true'],\n },\n {\n name: 'or',\n description: 'Logical OR of two values',\n signature: 'or(a, b)',\n returnType: 'boolean',\n examples: ['or(isAdmin, isOwner) // true if either true'],\n },\n {\n name: 'not',\n description: 'Logical NOT of a value',\n signature: 'not(value)',\n returnType: 'boolean',\n examples: ['not(isDeleted) // true if false'],\n },\n {\n name: 'contains',\n description: 'Check if a string contains a substring',\n signature: 'contains(text, search)',\n returnType: 'boolean',\n examples: ['contains(name, \"ell\") // true for \"hello\"'],\n },\n {\n name: 'startswith',\n description: 'Check if a string starts with a prefix',\n signature: 'startswith(text, prefix)',\n returnType: 'boolean',\n examples: ['startswith(name, \"hel\") // true for \"hello\"'],\n },\n {\n name: 'endswith',\n description: 'Check if a string ends with a suffix',\n signature: 'endswith(text, suffix)',\n returnType: 'boolean',\n examples: ['endswith(name, \"llo\") // true for \"hello\"'],\n },\n {\n name: 'isnull',\n description: 'Check if a value is null or undefined',\n signature: 'isnull(value)',\n returnType: 'boolean',\n examples: ['isnull(optionalField) // true if null/undefined'],\n },\n {\n name: 'includes',\n description: 'Check if an array contains a value',\n signature: 'includes(array, value)',\n returnType: 'boolean',\n examples: [\n 'includes(tags, \"featured\") // true if array contains value',\n ],\n },\n ],\n array: [\n {\n name: 'sum',\n description: 'Calculate the sum of array elements',\n signature: 'sum(array)',\n returnType: 'number',\n examples: ['sum(prices) // total of all prices'],\n },\n {\n name: 'avg',\n description: 'Calculate the average of array elements',\n signature: 'avg(array)',\n returnType: 'number',\n examples: ['avg(scores) // average score'],\n },\n {\n name: 'count',\n description: 'Get the number of elements in an array',\n signature: 'count(array)',\n returnType: 'number',\n examples: ['count(items) // number of items'],\n },\n {\n name: 'first',\n description: 'Get the first element of an array',\n signature: 'first(array)',\n returnType: 'any',\n examples: ['first(items) // first item'],\n },\n {\n name: 'last',\n description: 'Get the last element of an array',\n signature: 'last(array)',\n returnType: 'any',\n examples: ['last(items) // last item'],\n },\n ],\n conversion: [\n {\n name: 'tostring',\n description: 'Convert a value to string',\n signature: 'tostring(value)',\n returnType: 'string',\n examples: ['tostring(42) // \"42\"'],\n },\n {\n name: 'tonumber',\n description: 'Convert a value to number',\n signature: 'tonumber(value)',\n returnType: 'number',\n examples: ['tonumber(\"42\") // 42'],\n },\n {\n name: 'toboolean',\n description: 'Convert a value to boolean',\n signature: 'toboolean(value)',\n returnType: 'boolean',\n examples: ['toboolean(1) // true', 'toboolean(0) // false'],\n },\n ],\n conditional: [\n {\n name: 'if',\n description: 'Return one of two values based on a condition',\n signature: 'if(condition, valueIfTrue, valueIfFalse)',\n returnType: 'any',\n examples: [\n 'if(stock > 0, \"Available\", \"Out of Stock\")',\n 'if(price > 100, price * 0.9, price)',\n ],\n },\n {\n name: 'coalesce',\n description: 'Return the first non-null value',\n signature: 'coalesce(value1, value2, ...)',\n returnType: 'any',\n examples: ['coalesce(nickname, name, \"Anonymous\")'],\n },\n ],\n },\n\n features: [\n {\n name: 'simple_refs',\n description: 'Reference top-level fields by name',\n minVersion: '1.0',\n examples: ['price', 'quantity', 'baseDamage'],\n dependenciesExtracted: ['[\"price\"]', '[\"quantity\"]', '[\"baseDamage\"]'],\n },\n {\n name: 'arithmetic',\n description: 'Basic math operations (+, -, *, /)',\n minVersion: '1.0',\n examples: ['price * 1.1', 'a + b - c', 'quantity * price'],\n },\n {\n name: 'comparison',\n description: 'Compare values (>, <, >=, <=, ==, !=)',\n minVersion: '1.0',\n examples: ['price > 100', 'x == 10', 'quantity >= 5'],\n },\n {\n name: 'nested_path',\n description: 'Access nested object properties using dot notation',\n minVersion: '1.1',\n examples: ['stats.damage', 'user.profile.name', 'item.metadata.category'],\n dependenciesExtracted: ['[\"stats.damage\"]'],\n },\n {\n name: 'array_index',\n description:\n 'Access array elements by numeric index. Negative indices access from the end',\n minVersion: '1.1',\n examples: [\n 'items[0].price',\n 'inventory[1].quantity',\n 'items[-1].name // last element',\n 'items[-2].price // second to last',\n ],\n dependenciesExtracted: ['[\"items[0].price\"]', '[\"items[-1].name\"]'],\n },\n ],\n\n versionDetection: [\n { feature: 'Simple refs, arithmetic, comparisons', minVersion: '1.0' },\n { feature: 'Nested paths (a.b)', minVersion: '1.1' },\n { feature: 'Array index ([0], [-1])', minVersion: '1.1' },\n ],\n\n parseResult: {\n description:\n 'The parser automatically detects the minimum required version',\n interface: `interface ParseResult {\n ast: ASTNode; // Abstract syntax tree\n dependencies: string[]; // List of field dependencies\n features: string[]; // List of detected features\n minVersion: string; // Minimum required version (\"1.0\" or \"1.1\")\n}`,\n },\n\n examples: [\n {\n expression: 'price * quantity',\n description: 'Calculate total from price and quantity',\n result: 'number',\n },\n {\n expression: 'firstName + \" \" + lastName',\n description: 'Concatenate strings with space',\n result: 'string',\n },\n {\n expression: 'quantity > 0',\n description: 'Check if in stock',\n result: 'boolean',\n },\n {\n expression: 'if(stock > 0, \"Available\", \"Out of Stock\")',\n description: 'Conditional text based on stock',\n result: 'string',\n },\n {\n expression: 'price * (1 + taxRate)',\n description: 'Price with tax',\n result: 'number',\n },\n {\n expression: 'items[0].price + items[1].price',\n description: 'Sum first two item prices (v1.1)',\n result: 'number',\n },\n ],\n\n apiExamples: [\n {\n name: 'Simple Expression (v1.0)',\n description: 'Parse a basic arithmetic expression',\n code: `parseExpression('price * 1.1')\n// {\n// minVersion: \"1.0\",\n// features: [],\n// dependencies: [\"price\"]\n// }`,\n },\n {\n name: 'Nested Path (v1.1)',\n description: 'Parse expression with nested object access',\n code: `parseExpression('stats.damage * multiplier')\n// {\n// minVersion: \"1.1\",\n// features: [\"nested_path\"],\n// dependencies: [\"stats.damage\", \"multiplier\"]\n// }`,\n },\n {\n name: 'Array Access (v1.1)',\n description: 'Parse expression with array index access',\n code: `parseExpression('items[0].price + items[1].price')\n// {\n// minVersion: \"1.1\",\n// features: [\"array_index\", \"nested_path\"],\n// dependencies: [\"items[0].price\", \"items[1].price\"]\n// }`,\n },\n {\n name: 'Evaluate expressions',\n description: 'Execute formulas with context data',\n code: `evaluate('price * 1.1', { price: 100 })\n// 110\n\nevaluate('stats.damage', { stats: { damage: 50 } })\n// 50\n\nevaluate('items[0].price', { items: [{ price: 10 }] })\n// 10\n\nevaluate('price > 100', { price: 150 })\n// true\n\nevaluate('a + b * c', { a: 1, b: 2, c: 3 })\n// 7`,\n },\n ],\n\n schemaUsage: {\n structure:\n '{ \"x-formula\": { \"version\": 1, \"expression\": \"...\" }, \"readOnly\": true }',\n fieldTypes: ['string', 'number', 'boolean'],\n rules: [\n 'Add x-formula to string, number, or boolean field schema',\n 'readOnly: true is REQUIRED for fields with x-formula',\n 'Expression must reference existing fields in the same table',\n 'Circular dependencies are not allowed (a references b, b references a)',\n ],\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/formula-spec.ts"],"names":[],"mappings":";AAuDO,IAAM,WAAA,GAA2B;AAAA,EACtC,OAAA,EAAS,KAAA;AAAA,EACT,WAAA,EACE,8GAAA;AAAA,EAEF,MAAA,EAAQ;AAAA,IACN,eAAA,EAAiB;AAAA,MACf,iDAAA;AAAA,MACA,mDAAA;AAAA,MACA,qDAAA;AAAA,MACA;AAAA,KACF;AAAA,IACA,mBAAA,EAAqB;AAAA,MACnB,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,kCAAA,EAAmC;AAAA,MACjE,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,aAAA,EAAc;AAAA,MAC5C,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,gBAAA,EAAiB;AAAA,MAC/C,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,UAAA,EAAW;AAAA,MACzC,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,oBAAA;AAAqB,KACrD;AAAA,IACA,mBAAA,EAAqB;AAAA,MACnB,EAAE,QAAA,EAAU,IAAA,EAAM,WAAA,EAAa,OAAA,EAAQ;AAAA,MACvC,EAAE,QAAA,EAAU,IAAA,EAAM,WAAA,EAAa,WAAA,EAAY;AAAA,MAC3C,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,cAAA,EAAe;AAAA,MAC7C,EAAE,QAAA,EAAU,GAAA,EAAK,WAAA,EAAa,WAAA,EAAY;AAAA,MAC1C,EAAE,QAAA,EAAU,IAAA,EAAM,WAAA,EAAa,kBAAA,EAAmB;AAAA,MAClD,EAAE,QAAA,EAAU,IAAA,EAAM,WAAA,EAAa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,MACb,IAAA,EAAM,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,KAMR;AAAA,IACA;AAAA,MACE,IAAA,EAAM,sBAAA;AAAA,MACN,WAAA,EAAa,oCAAA;AAAA,MACb,IAAA,EAAM,CAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA,IAAA;AAAA,KAcR;AAAA,IACA;AAAA,MACE,IAAA,EAAM,uBAAA;AAAA,MACN,WAAA,EAAa,qDAAA;AAAA,MACb,IAAA,EAAM,CAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA,KAAA;AAAA,KAaR;AAAA,IACA;AAAA,MACE,IAAA,EAAM,qCAAA;AAAA,MACN,WAAA,EACE,wEAAA;AAAA,MACF,IAAA,EAAM,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAA;AAAA;AA+BR,GACF;AAAA,EAEA,WAAA,EAAa;AAAA,IACX,SAAA,EACE,0EAAA;AAAA,IACF,UAAA,EAAY,CAAC,QAAA,EAAU,QAAA,EAAU,SAAS,CAAA;AAAA,IAC1C,KAAA,EAAO;AAAA,MACL,0DAAA;AAAA,MACA,sDAAA;AAAA,MACA,6DAAA;AAAA,MACA;AAAA;AACF;AAEJ","file":"formula-spec.js","sourcesContent":["export interface FunctionSpec {\n name: string;\n description: string;\n signature: string;\n returnType: 'string' | 'number' | 'boolean' | 'any';\n examples: string[];\n}\n\nexport interface FormulaSpec {\n version: string;\n description: string;\n syntax: {\n fieldReferences: string[];\n arithmeticOperators: { operator: string; description: string }[];\n comparisonOperators: { operator: string; description: string }[];\n logicalOperators: { operator: string; description: string }[];\n other: string[];\n };\n functions: {\n string: FunctionSpec[];\n numeric: FunctionSpec[];\n boolean: FunctionSpec[];\n array: FunctionSpec[];\n conversion: FunctionSpec[];\n conditional: FunctionSpec[];\n };\n features: {\n name: string;\n description: string;\n minVersion: string;\n examples: string[];\n dependenciesExtracted?: string[];\n }[];\n versionDetection: { feature: string; minVersion: string }[];\n parseResult: {\n description: string;\n interface: string;\n };\n examples: {\n expression: string;\n description: string;\n result?: string;\n }[];\n apiExamples: {\n name: string;\n description: string;\n code: string;\n }[];\n schemaUsage: {\n structure: string;\n fieldTypes: string[];\n rules: string[];\n };\n}\n\nexport const formulaSpec: FormulaSpec = {\n version: '1.1',\n description:\n 'Formula expressions for computed fields. Formulas reference other fields and calculate values automatically.',\n\n syntax: {\n fieldReferences: [\n 'Simple field: fieldName (e.g., price, quantity)',\n 'Nested path: object.property (e.g., stats.damage)',\n 'Array index: array[0] or array[-1] for last element',\n 'Combined: items[0].price, user.addresses[-1].city',\n ],\n arithmeticOperators: [\n { operator: '+', description: 'Addition or string concatenation' },\n { operator: '-', description: 'Subtraction' },\n { operator: '*', description: 'Multiplication' },\n { operator: '/', description: 'Division' },\n { operator: '%', description: 'Modulo (remainder)' },\n ],\n comparisonOperators: [\n { operator: '==', description: 'Equal' },\n { operator: '!=', description: 'Not equal' },\n { operator: '>', description: 'Greater than' },\n { operator: '<', description: 'Less than' },\n { operator: '>=', description: 'Greater or equal' },\n { operator: '<=', description: 'Less or equal' },\n ],\n logicalOperators: [\n { operator: '&&', description: 'Logical AND' },\n { operator: '||', description: 'Logical OR' },\n { operator: '!', description: 'Logical NOT' },\n ],\n other: ['Parentheses: (a + b) * c', 'Unary minus: -value, a + -b'],\n },\n\n functions: {\n string: [\n {\n name: 'concat',\n description: 'Concatenate multiple values into a single string',\n signature: 'concat(value1, value2, ...)',\n returnType: 'string',\n examples: [\n 'concat(firstName, \" \", lastName) // \"John Doe\"',\n 'concat(\"Price: \", price, \" USD\") // \"Price: 100 USD\"',\n ],\n },\n {\n name: 'upper',\n description: 'Convert string to uppercase',\n signature: 'upper(text)',\n returnType: 'string',\n examples: ['upper(name) // \"HELLO\"'],\n },\n {\n name: 'lower',\n description: 'Convert string to lowercase',\n signature: 'lower(text)',\n returnType: 'string',\n examples: ['lower(name) // \"hello\"'],\n },\n {\n name: 'trim',\n description: 'Remove whitespace from both ends of a string',\n signature: 'trim(text)',\n returnType: 'string',\n examples: ['trim(name) // \"hello\" from \" hello \"'],\n },\n {\n name: 'left',\n description: 'Extract characters from the beginning of a string',\n signature: 'left(text, count)',\n returnType: 'string',\n examples: ['left(name, 3) // \"hel\" from \"hello\"'],\n },\n {\n name: 'right',\n description: 'Extract characters from the end of a string',\n signature: 'right(text, count)',\n returnType: 'string',\n examples: ['right(name, 3) // \"llo\" from \"hello\"'],\n },\n {\n name: 'replace',\n description: 'Replace first occurrence of a substring',\n signature: 'replace(text, search, replacement)',\n returnType: 'string',\n examples: ['replace(name, \"o\", \"0\") // \"hell0\" from \"hello\"'],\n },\n {\n name: 'join',\n description: 'Join array elements into a string',\n signature: 'join(array, separator?)',\n returnType: 'string',\n examples: ['join(tags) // \"a,b,c\"', 'join(tags, \" | \") // \"a | b | c\"'],\n },\n ],\n numeric: [\n {\n name: 'round',\n description: 'Round a number to specified decimal places',\n signature: 'round(number, decimals?)',\n returnType: 'number',\n examples: ['round(3.14159, 2) // 3.14', 'round(3.5) // 4'],\n },\n {\n name: 'floor',\n description: 'Round down to the nearest integer',\n signature: 'floor(number)',\n returnType: 'number',\n examples: ['floor(3.7) // 3'],\n },\n {\n name: 'ceil',\n description: 'Round up to the nearest integer',\n signature: 'ceil(number)',\n returnType: 'number',\n examples: ['ceil(3.2) // 4'],\n },\n {\n name: 'abs',\n description: 'Get the absolute value',\n signature: 'abs(number)',\n returnType: 'number',\n examples: ['abs(-5) // 5'],\n },\n {\n name: 'sqrt',\n description: 'Calculate the square root',\n signature: 'sqrt(number)',\n returnType: 'number',\n examples: ['sqrt(16) // 4'],\n },\n {\n name: 'pow',\n description: 'Raise a number to a power',\n signature: 'pow(base, exponent)',\n returnType: 'number',\n examples: ['pow(2, 3) // 8'],\n },\n {\n name: 'min',\n description: 'Get the minimum of multiple values',\n signature: 'min(value1, value2, ...)',\n returnType: 'number',\n examples: ['min(a, b, c) // smallest value'],\n },\n {\n name: 'max',\n description: 'Get the maximum of multiple values',\n signature: 'max(value1, value2, ...)',\n returnType: 'number',\n examples: ['max(a, b, c) // largest value'],\n },\n {\n name: 'log',\n description: 'Calculate the natural logarithm',\n signature: 'log(number)',\n returnType: 'number',\n examples: ['log(10) // 2.302...'],\n },\n {\n name: 'log10',\n description: 'Calculate the base-10 logarithm',\n signature: 'log10(number)',\n returnType: 'number',\n examples: ['log10(100) // 2'],\n },\n {\n name: 'exp',\n description: 'Calculate e raised to a power',\n signature: 'exp(number)',\n returnType: 'number',\n examples: ['exp(1) // 2.718...'],\n },\n {\n name: 'sign',\n description: 'Get the sign of a number (-1, 0, or 1)',\n signature: 'sign(number)',\n returnType: 'number',\n examples: ['sign(-5) // -1', 'sign(0) // 0', 'sign(5) // 1'],\n },\n {\n name: 'length',\n description: 'Get the length of a string or array',\n signature: 'length(value)',\n returnType: 'number',\n examples: ['length(name) // 5 from \"hello\"', 'length(items) // 3'],\n },\n ],\n boolean: [\n {\n name: 'and',\n description: 'Logical AND of two values',\n signature: 'and(a, b)',\n returnType: 'boolean',\n examples: ['and(isActive, hasPermission) // true if both true'],\n },\n {\n name: 'or',\n description: 'Logical OR of two values',\n signature: 'or(a, b)',\n returnType: 'boolean',\n examples: ['or(isAdmin, isOwner) // true if either true'],\n },\n {\n name: 'not',\n description: 'Logical NOT of a value',\n signature: 'not(value)',\n returnType: 'boolean',\n examples: ['not(isDeleted) // true if false'],\n },\n {\n name: 'contains',\n description: 'Check if a string contains a substring',\n signature: 'contains(text, search)',\n returnType: 'boolean',\n examples: ['contains(name, \"ell\") // true for \"hello\"'],\n },\n {\n name: 'startswith',\n description: 'Check if a string starts with a prefix',\n signature: 'startswith(text, prefix)',\n returnType: 'boolean',\n examples: ['startswith(name, \"hel\") // true for \"hello\"'],\n },\n {\n name: 'endswith',\n description: 'Check if a string ends with a suffix',\n signature: 'endswith(text, suffix)',\n returnType: 'boolean',\n examples: ['endswith(name, \"llo\") // true for \"hello\"'],\n },\n {\n name: 'isnull',\n description: 'Check if a value is null or undefined',\n signature: 'isnull(value)',\n returnType: 'boolean',\n examples: ['isnull(optionalField) // true if null/undefined'],\n },\n {\n name: 'includes',\n description: 'Check if an array contains a value',\n signature: 'includes(array, value)',\n returnType: 'boolean',\n examples: [\n 'includes(tags, \"featured\") // true if array contains value',\n ],\n },\n ],\n array: [\n {\n name: 'sum',\n description: 'Calculate the sum of array elements',\n signature: 'sum(array)',\n returnType: 'number',\n examples: ['sum(prices) // total of all prices'],\n },\n {\n name: 'avg',\n description: 'Calculate the average of array elements',\n signature: 'avg(array)',\n returnType: 'number',\n examples: ['avg(scores) // average score'],\n },\n {\n name: 'count',\n description: 'Get the number of elements in an array',\n signature: 'count(array)',\n returnType: 'number',\n examples: ['count(items) // number of items'],\n },\n {\n name: 'first',\n description: 'Get the first element of an array',\n signature: 'first(array)',\n returnType: 'any',\n examples: ['first(items) // first item'],\n },\n {\n name: 'last',\n description: 'Get the last element of an array',\n signature: 'last(array)',\n returnType: 'any',\n examples: ['last(items) // last item'],\n },\n ],\n conversion: [\n {\n name: 'tostring',\n description: 'Convert a value to string',\n signature: 'tostring(value)',\n returnType: 'string',\n examples: ['tostring(42) // \"42\"'],\n },\n {\n name: 'tonumber',\n description: 'Convert a value to number',\n signature: 'tonumber(value)',\n returnType: 'number',\n examples: ['tonumber(\"42\") // 42'],\n },\n {\n name: 'toboolean',\n description: 'Convert a value to boolean',\n signature: 'toboolean(value)',\n returnType: 'boolean',\n examples: ['toboolean(1) // true', 'toboolean(0) // false'],\n },\n ],\n conditional: [\n {\n name: 'if',\n description: 'Return one of two values based on a condition',\n signature: 'if(condition, valueIfTrue, valueIfFalse)',\n returnType: 'any',\n examples: [\n 'if(stock > 0, \"Available\", \"Out of Stock\")',\n 'if(price > 100, price * 0.9, price)',\n ],\n },\n {\n name: 'coalesce',\n description: 'Return the first non-null value',\n signature: 'coalesce(value1, value2, ...)',\n returnType: 'any',\n examples: ['coalesce(nickname, name, \"Anonymous\")'],\n },\n ],\n },\n\n features: [\n {\n name: 'simple_refs',\n description: 'Reference top-level fields by name',\n minVersion: '1.0',\n examples: ['price', 'quantity', 'baseDamage'],\n dependenciesExtracted: ['[\"price\"]', '[\"quantity\"]', '[\"baseDamage\"]'],\n },\n {\n name: 'arithmetic',\n description: 'Basic math operations (+, -, *, /)',\n minVersion: '1.0',\n examples: ['price * 1.1', 'a + b - c', 'quantity * price'],\n },\n {\n name: 'comparison',\n description: 'Compare values (>, <, >=, <=, ==, !=)',\n minVersion: '1.0',\n examples: ['price > 100', 'x == 10', 'quantity >= 5'],\n },\n {\n name: 'nested_path',\n description: 'Access nested object properties using dot notation',\n minVersion: '1.1',\n examples: ['stats.damage', 'user.profile.name', 'item.metadata.category'],\n dependenciesExtracted: ['[\"stats.damage\"]'],\n },\n {\n name: 'array_index',\n description:\n 'Access array elements by numeric index. Negative indices access from the end',\n minVersion: '1.1',\n examples: [\n 'items[0].price',\n 'inventory[1].quantity',\n 'items[-1].name // last element',\n 'items[-2].price // second to last',\n ],\n dependenciesExtracted: ['[\"items[0].price\"]', '[\"items[-1].name\"]'],\n },\n {\n name: 'root_path',\n description:\n 'Absolute path reference starting with /. Always resolves from root data, even inside array item formulas',\n minVersion: '1.1',\n examples: [\n '/taxRate',\n '/config.tax',\n 'price * (1 + /taxRate)',\n 'price * /config.multiplier',\n ],\n dependenciesExtracted: ['[\"/taxRate\"]', '[\"/config.tax\"]'],\n },\n {\n name: 'relative_path',\n description:\n 'Relative path reference starting with ../. Resolves from parent context (root data) when inside array item formulas',\n minVersion: '1.1',\n examples: [\n '../discount',\n '../settings.multiplier',\n 'price * (1 - ../discount)',\n 'price * ../settings.multiplier',\n ],\n dependenciesExtracted: ['[\"../discount\"]', '[\"../settings.multiplier\"]'],\n },\n {\n name: 'function_named_fields',\n description:\n 'Fields can have the same name as built-in functions (max, min, sum, etc.). Built-in functions are always checked first when a function call is made',\n minVersion: '1.0',\n examples: [\n 'max(max, 0)',\n 'min(min, 100)',\n 'max(max - field.min, 0)',\n 'round(round * 2)',\n ],\n },\n ],\n\n versionDetection: [\n { feature: 'Simple refs, arithmetic, comparisons', minVersion: '1.0' },\n { feature: 'Function-named fields (max(max, 0))', minVersion: '1.0' },\n { feature: 'Nested paths (a.b)', minVersion: '1.1' },\n { feature: 'Array index ([0], [-1])', minVersion: '1.1' },\n { feature: 'Absolute paths (/field)', minVersion: '1.1' },\n { feature: 'Relative paths (../field)', minVersion: '1.1' },\n ],\n\n parseResult: {\n description:\n 'The parser automatically detects the minimum required version',\n interface: `interface ParseResult {\n ast: ASTNode; // Abstract syntax tree\n dependencies: string[]; // List of field dependencies\n features: string[]; // List of detected features\n minVersion: string; // Minimum required version (\"1.0\" or \"1.1\")\n}`,\n },\n\n examples: [\n {\n expression: 'price * quantity',\n description: 'Calculate total from price and quantity',\n result: 'number',\n },\n {\n expression: 'firstName + \" \" + lastName',\n description: 'Concatenate strings with space',\n result: 'string',\n },\n {\n expression: 'quantity > 0',\n description: 'Check if in stock',\n result: 'boolean',\n },\n {\n expression: 'if(stock > 0, \"Available\", \"Out of Stock\")',\n description: 'Conditional text based on stock',\n result: 'string',\n },\n {\n expression: 'price * (1 + taxRate)',\n description: 'Price with tax',\n result: 'number',\n },\n {\n expression: 'items[0].price + items[1].price',\n description: 'Sum first two item prices (v1.1)',\n result: 'number',\n },\n ],\n\n apiExamples: [\n {\n name: 'Simple Expression (v1.0)',\n description: 'Parse a basic arithmetic expression',\n code: `parseExpression('price * 1.1')\n// {\n// minVersion: \"1.0\",\n// features: [],\n// dependencies: [\"price\"]\n// }`,\n },\n {\n name: 'Nested Path (v1.1)',\n description: 'Parse expression with nested object access',\n code: `parseExpression('stats.damage * multiplier')\n// {\n// minVersion: \"1.1\",\n// features: [\"nested_path\"],\n// dependencies: [\"stats.damage\", \"multiplier\"]\n// }`,\n },\n {\n name: 'Array Access (v1.1)',\n description: 'Parse expression with array index access',\n code: `parseExpression('items[0].price + items[1].price')\n// {\n// minVersion: \"1.1\",\n// features: [\"array_index\", \"nested_path\"],\n// dependencies: [\"items[0].price\", \"items[1].price\"]\n// }`,\n },\n {\n name: 'Evaluate expressions',\n description: 'Execute formulas with context data',\n code: `evaluate('price * 1.1', { price: 100 })\n// 110\n\nevaluate('stats.damage', { stats: { damage: 50 } })\n// 50\n\nevaluate('items[0].price', { items: [{ price: 10 }] })\n// 10\n\nevaluate('price > 100', { price: 150 })\n// true\n\nevaluate('a + b * c', { a: 1, b: 2, c: 3 })\n// 7`,\n },\n {\n name: 'Function-named fields',\n description: 'Fields can have the same name as built-in functions',\n code: `// Built-in functions take precedence in function calls\nevaluate('max(max, 0)', { max: 10 })\n// 10 (max() function, then max field)\n\nevaluate('max(max - field.min, 0)', { max: 100, field: { min: 20 } })\n// 80\n\nevaluate('round(round * 2)', { round: 3.7 })\n// 7\n\n// Field named \"sum\" doesn't conflict with sum() function\nevaluate('sum(values) + sum', { values: [1, 2, 3], sum: 10 })\n// 16`,\n },\n {\n name: 'Evaluate with context (array items)',\n description:\n 'Use evaluateWithContext() for array item formulas with path resolution',\n code: `// Absolute path: /field always resolves from root\nevaluateWithContext('price * (1 + /taxRate)', {\n rootData: { taxRate: 0.1, items: [{ price: 100 }] },\n itemData: { price: 100 },\n currentPath: 'items[0]'\n})\n// 110\n\n// Nested absolute path\nevaluateWithContext('price * /config.multiplier', {\n rootData: { config: { multiplier: 1.5 }, items: [] },\n itemData: { price: 100 },\n currentPath: 'items[0]'\n})\n// 150\n\n// Relative path: ../field resolves from parent (root)\nevaluateWithContext('price * (1 - ../discount)', {\n rootData: { discount: 0.2, items: [] },\n itemData: { price: 100 },\n currentPath: 'items[0]'\n})\n// 80\n\n// itemData takes precedence over rootData for same field\nevaluateWithContext('value + 10', {\n rootData: { value: 100 },\n itemData: { value: 50 },\n currentPath: 'items[0]'\n})\n// 60`,\n },\n ],\n\n schemaUsage: {\n structure:\n '{ \"x-formula\": { \"version\": 1, \"expression\": \"...\" }, \"readOnly\": true }',\n fieldTypes: ['string', 'number', 'boolean'],\n rules: [\n 'Add x-formula to string, number, or boolean field schema',\n 'readOnly: true is REQUIRED for fields with x-formula',\n 'Expression must reference existing fields in the same table',\n 'Circular dependencies are not allowed (a references b, b references a)',\n ],\n },\n};\n"]}
|
|
@@ -41,7 +41,75 @@ interface FormulaContext {
|
|
|
41
41
|
}
|
|
42
42
|
type FormulaResult = number | string | boolean | null;
|
|
43
43
|
|
|
44
|
-
type ASTNode =
|
|
44
|
+
type ASTNode = NumberLiteral | StringLiteral | BooleanLiteral | NullLiteral | Identifier | RootPath | RelativePath | ContextToken | BinaryOp | UnaryOp | TernaryOp | CallExpression | MemberExpression | IndexExpression | WildcardExpression;
|
|
45
|
+
interface NumberLiteral {
|
|
46
|
+
type: 'NumberLiteral';
|
|
47
|
+
value: number;
|
|
48
|
+
}
|
|
49
|
+
interface StringLiteral {
|
|
50
|
+
type: 'StringLiteral';
|
|
51
|
+
value: string;
|
|
52
|
+
}
|
|
53
|
+
interface BooleanLiteral {
|
|
54
|
+
type: 'BooleanLiteral';
|
|
55
|
+
value: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface NullLiteral {
|
|
58
|
+
type: 'NullLiteral';
|
|
59
|
+
}
|
|
60
|
+
interface Identifier {
|
|
61
|
+
type: 'Identifier';
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
interface RootPath {
|
|
65
|
+
type: 'RootPath';
|
|
66
|
+
path: string;
|
|
67
|
+
}
|
|
68
|
+
interface RelativePath {
|
|
69
|
+
type: 'RelativePath';
|
|
70
|
+
path: string;
|
|
71
|
+
}
|
|
72
|
+
interface ContextToken {
|
|
73
|
+
type: 'ContextToken';
|
|
74
|
+
name: string;
|
|
75
|
+
}
|
|
76
|
+
interface BinaryOp {
|
|
77
|
+
type: 'BinaryOp';
|
|
78
|
+
op: string;
|
|
79
|
+
left: ASTNode;
|
|
80
|
+
right: ASTNode;
|
|
81
|
+
}
|
|
82
|
+
interface UnaryOp {
|
|
83
|
+
type: 'UnaryOp';
|
|
84
|
+
op: string;
|
|
85
|
+
argument: ASTNode;
|
|
86
|
+
}
|
|
87
|
+
interface TernaryOp {
|
|
88
|
+
type: 'TernaryOp';
|
|
89
|
+
condition: ASTNode;
|
|
90
|
+
consequent: ASTNode;
|
|
91
|
+
alternate: ASTNode;
|
|
92
|
+
}
|
|
93
|
+
interface CallExpression {
|
|
94
|
+
type: 'CallExpression';
|
|
95
|
+
callee: ASTNode;
|
|
96
|
+
arguments: ASTNode[];
|
|
97
|
+
}
|
|
98
|
+
interface MemberExpression {
|
|
99
|
+
type: 'MemberExpression';
|
|
100
|
+
object: ASTNode;
|
|
101
|
+
property: string;
|
|
102
|
+
}
|
|
103
|
+
interface IndexExpression {
|
|
104
|
+
type: 'IndexExpression';
|
|
105
|
+
object: ASTNode;
|
|
106
|
+
index: ASTNode;
|
|
107
|
+
}
|
|
108
|
+
interface WildcardExpression {
|
|
109
|
+
type: 'WildcardExpression';
|
|
110
|
+
object: ASTNode;
|
|
111
|
+
}
|
|
112
|
+
|
|
45
113
|
interface ParseResult {
|
|
46
114
|
ast: ASTNode;
|
|
47
115
|
dependencies: string[];
|
|
@@ -57,6 +125,12 @@ declare function validateSyntax(expression: string): {
|
|
|
57
125
|
position?: number;
|
|
58
126
|
};
|
|
59
127
|
declare function evaluate(expression: string, context: Record<string, unknown>): unknown;
|
|
128
|
+
interface EvaluateContextOptions {
|
|
129
|
+
rootData: Record<string, unknown>;
|
|
130
|
+
itemData?: Record<string, unknown>;
|
|
131
|
+
currentPath?: string;
|
|
132
|
+
}
|
|
133
|
+
declare function evaluateWithContext(expression: string, options: EvaluateContextOptions): unknown;
|
|
60
134
|
type InferredType = 'number' | 'boolean' | 'string' | 'unknown';
|
|
61
135
|
interface FieldTypes {
|
|
62
136
|
[fieldName: string]: 'number' | 'string' | 'boolean' | 'object' | 'array';
|
|
@@ -87,11 +161,14 @@ interface XFormulaInput {
|
|
|
87
161
|
interface SchemaProperty {
|
|
88
162
|
type?: string;
|
|
89
163
|
'x-formula'?: XFormulaInput;
|
|
164
|
+
properties?: Record<string, SchemaProperty>;
|
|
165
|
+
items?: SchemaProperty;
|
|
90
166
|
[key: string]: unknown;
|
|
91
167
|
}
|
|
92
168
|
interface JsonSchema {
|
|
93
169
|
type?: string;
|
|
94
170
|
properties?: Record<string, SchemaProperty>;
|
|
171
|
+
items?: SchemaProperty;
|
|
95
172
|
[key: string]: unknown;
|
|
96
173
|
}
|
|
97
174
|
interface ExtractedFormula {
|
|
@@ -113,4 +190,4 @@ interface SchemaValidationResult {
|
|
|
113
190
|
declare function validateFormulaAgainstSchema(expression: string, fieldName: string, schema: JsonSchema): FormulaValidationError | null;
|
|
114
191
|
declare function validateSchemaFormulas(schema: JsonSchema): SchemaValidationResult;
|
|
115
192
|
|
|
116
|
-
export { type ASTNode as A, type
|
|
193
|
+
export { type ASTNode as A, type EvaluateContextOptions as E, type FieldTypes as F, type InferredType as I, type JsonSchema as J, type ParseResult as P, type SyntaxValidationResult as S, type XFormula as X, evaluateWithContext as a, parseExpression as b, type ParsedExpression as c, validateFormulaSyntax as d, evaluate as e, extractSchemaFormulas as f, type ExtractedFormula as g, validateFormulaAgainstSchema as h, inferFormulaType as i, validateSchemaFormulas as j, type FormulaValidationError as k, type SchemaValidationResult as l, type FormulaMinorVersion as m, type FormulaFeature as n, type FormulaAnalysis as o, parseFormula as p, type PathSegment as q, type ParsedPath as r, type PathValidationResult as s, type FormulaContext as t, type FormulaResult as u, validateSyntax as v };
|
|
@@ -41,7 +41,75 @@ interface FormulaContext {
|
|
|
41
41
|
}
|
|
42
42
|
type FormulaResult = number | string | boolean | null;
|
|
43
43
|
|
|
44
|
-
type ASTNode =
|
|
44
|
+
type ASTNode = NumberLiteral | StringLiteral | BooleanLiteral | NullLiteral | Identifier | RootPath | RelativePath | ContextToken | BinaryOp | UnaryOp | TernaryOp | CallExpression | MemberExpression | IndexExpression | WildcardExpression;
|
|
45
|
+
interface NumberLiteral {
|
|
46
|
+
type: 'NumberLiteral';
|
|
47
|
+
value: number;
|
|
48
|
+
}
|
|
49
|
+
interface StringLiteral {
|
|
50
|
+
type: 'StringLiteral';
|
|
51
|
+
value: string;
|
|
52
|
+
}
|
|
53
|
+
interface BooleanLiteral {
|
|
54
|
+
type: 'BooleanLiteral';
|
|
55
|
+
value: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface NullLiteral {
|
|
58
|
+
type: 'NullLiteral';
|
|
59
|
+
}
|
|
60
|
+
interface Identifier {
|
|
61
|
+
type: 'Identifier';
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
interface RootPath {
|
|
65
|
+
type: 'RootPath';
|
|
66
|
+
path: string;
|
|
67
|
+
}
|
|
68
|
+
interface RelativePath {
|
|
69
|
+
type: 'RelativePath';
|
|
70
|
+
path: string;
|
|
71
|
+
}
|
|
72
|
+
interface ContextToken {
|
|
73
|
+
type: 'ContextToken';
|
|
74
|
+
name: string;
|
|
75
|
+
}
|
|
76
|
+
interface BinaryOp {
|
|
77
|
+
type: 'BinaryOp';
|
|
78
|
+
op: string;
|
|
79
|
+
left: ASTNode;
|
|
80
|
+
right: ASTNode;
|
|
81
|
+
}
|
|
82
|
+
interface UnaryOp {
|
|
83
|
+
type: 'UnaryOp';
|
|
84
|
+
op: string;
|
|
85
|
+
argument: ASTNode;
|
|
86
|
+
}
|
|
87
|
+
interface TernaryOp {
|
|
88
|
+
type: 'TernaryOp';
|
|
89
|
+
condition: ASTNode;
|
|
90
|
+
consequent: ASTNode;
|
|
91
|
+
alternate: ASTNode;
|
|
92
|
+
}
|
|
93
|
+
interface CallExpression {
|
|
94
|
+
type: 'CallExpression';
|
|
95
|
+
callee: ASTNode;
|
|
96
|
+
arguments: ASTNode[];
|
|
97
|
+
}
|
|
98
|
+
interface MemberExpression {
|
|
99
|
+
type: 'MemberExpression';
|
|
100
|
+
object: ASTNode;
|
|
101
|
+
property: string;
|
|
102
|
+
}
|
|
103
|
+
interface IndexExpression {
|
|
104
|
+
type: 'IndexExpression';
|
|
105
|
+
object: ASTNode;
|
|
106
|
+
index: ASTNode;
|
|
107
|
+
}
|
|
108
|
+
interface WildcardExpression {
|
|
109
|
+
type: 'WildcardExpression';
|
|
110
|
+
object: ASTNode;
|
|
111
|
+
}
|
|
112
|
+
|
|
45
113
|
interface ParseResult {
|
|
46
114
|
ast: ASTNode;
|
|
47
115
|
dependencies: string[];
|
|
@@ -57,6 +125,12 @@ declare function validateSyntax(expression: string): {
|
|
|
57
125
|
position?: number;
|
|
58
126
|
};
|
|
59
127
|
declare function evaluate(expression: string, context: Record<string, unknown>): unknown;
|
|
128
|
+
interface EvaluateContextOptions {
|
|
129
|
+
rootData: Record<string, unknown>;
|
|
130
|
+
itemData?: Record<string, unknown>;
|
|
131
|
+
currentPath?: string;
|
|
132
|
+
}
|
|
133
|
+
declare function evaluateWithContext(expression: string, options: EvaluateContextOptions): unknown;
|
|
60
134
|
type InferredType = 'number' | 'boolean' | 'string' | 'unknown';
|
|
61
135
|
interface FieldTypes {
|
|
62
136
|
[fieldName: string]: 'number' | 'string' | 'boolean' | 'object' | 'array';
|
|
@@ -87,11 +161,14 @@ interface XFormulaInput {
|
|
|
87
161
|
interface SchemaProperty {
|
|
88
162
|
type?: string;
|
|
89
163
|
'x-formula'?: XFormulaInput;
|
|
164
|
+
properties?: Record<string, SchemaProperty>;
|
|
165
|
+
items?: SchemaProperty;
|
|
90
166
|
[key: string]: unknown;
|
|
91
167
|
}
|
|
92
168
|
interface JsonSchema {
|
|
93
169
|
type?: string;
|
|
94
170
|
properties?: Record<string, SchemaProperty>;
|
|
171
|
+
items?: SchemaProperty;
|
|
95
172
|
[key: string]: unknown;
|
|
96
173
|
}
|
|
97
174
|
interface ExtractedFormula {
|
|
@@ -113,4 +190,4 @@ interface SchemaValidationResult {
|
|
|
113
190
|
declare function validateFormulaAgainstSchema(expression: string, fieldName: string, schema: JsonSchema): FormulaValidationError | null;
|
|
114
191
|
declare function validateSchemaFormulas(schema: JsonSchema): SchemaValidationResult;
|
|
115
192
|
|
|
116
|
-
export { type ASTNode as A, type
|
|
193
|
+
export { type ASTNode as A, type EvaluateContextOptions as E, type FieldTypes as F, type InferredType as I, type JsonSchema as J, type ParseResult as P, type SyntaxValidationResult as S, type XFormula as X, evaluateWithContext as a, parseExpression as b, type ParsedExpression as c, validateFormulaSyntax as d, evaluate as e, extractSchemaFormulas as f, type ExtractedFormula as g, validateFormulaAgainstSchema as h, inferFormulaType as i, validateSchemaFormulas as j, type FormulaValidationError as k, type SchemaValidationResult as l, type FormulaMinorVersion as m, type FormulaFeature as n, type FormulaAnalysis as o, parseFormula as p, type PathSegment as q, type ParsedPath as r, type PathValidationResult as s, type FormulaContext as t, type FormulaResult as u, validateSyntax as v };
|
package/dist/index.cjs
CHANGED
|
@@ -1,57 +1,60 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-Q7SFCCGT.cjs');
|
|
3
|
+
var chunkKYBZYJ7E_cjs = require('./chunk-KYBZYJ7E.cjs');
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
Object.defineProperty(exports, "buildDependencyGraph", {
|
|
9
8
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkKYBZYJ7E_cjs.buildDependencyGraph; }
|
|
11
10
|
});
|
|
12
11
|
Object.defineProperty(exports, "detectCircularDependencies", {
|
|
13
12
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkKYBZYJ7E_cjs.detectCircularDependencies; }
|
|
15
14
|
});
|
|
16
15
|
Object.defineProperty(exports, "evaluate", {
|
|
17
16
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkKYBZYJ7E_cjs.evaluate; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "evaluateWithContext", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkKYBZYJ7E_cjs.evaluateWithContext; }
|
|
19
22
|
});
|
|
20
23
|
Object.defineProperty(exports, "extractSchemaFormulas", {
|
|
21
24
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkKYBZYJ7E_cjs.extractSchemaFormulas; }
|
|
23
26
|
});
|
|
24
27
|
Object.defineProperty(exports, "getTopologicalOrder", {
|
|
25
28
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkKYBZYJ7E_cjs.getTopologicalOrder; }
|
|
27
30
|
});
|
|
28
31
|
Object.defineProperty(exports, "inferFormulaType", {
|
|
29
32
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkKYBZYJ7E_cjs.inferFormulaType; }
|
|
31
34
|
});
|
|
32
35
|
Object.defineProperty(exports, "parseExpression", {
|
|
33
36
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkKYBZYJ7E_cjs.parseExpression; }
|
|
35
38
|
});
|
|
36
39
|
Object.defineProperty(exports, "parseFormula", {
|
|
37
40
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkKYBZYJ7E_cjs.parseFormula; }
|
|
39
42
|
});
|
|
40
43
|
Object.defineProperty(exports, "validateFormulaAgainstSchema", {
|
|
41
44
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkKYBZYJ7E_cjs.validateFormulaAgainstSchema; }
|
|
43
46
|
});
|
|
44
47
|
Object.defineProperty(exports, "validateFormulaSyntax", {
|
|
45
48
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkKYBZYJ7E_cjs.validateFormulaSyntax; }
|
|
47
50
|
});
|
|
48
51
|
Object.defineProperty(exports, "validateSchemaFormulas", {
|
|
49
52
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkKYBZYJ7E_cjs.validateSchemaFormulas; }
|
|
51
54
|
});
|
|
52
55
|
Object.defineProperty(exports, "validateSyntax", {
|
|
53
56
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkKYBZYJ7E_cjs.validateSyntax; }
|
|
55
58
|
});
|
|
56
59
|
//# sourceMappingURL=index.cjs.map
|
|
57
60
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ASTNode, E as ExtractedFormula, F as FieldTypes,
|
|
1
|
+
export { A as ASTNode, E as EvaluateContextOptions, g as ExtractedFormula, F as FieldTypes, o as FormulaAnalysis, t as FormulaContext, n as FormulaFeature, m as FormulaMinorVersion, u as FormulaResult, k as FormulaValidationError, I as InferredType, J as JsonSchema, P as ParseResult, c as ParsedExpression, r as ParsedPath, q as PathSegment, s as PathValidationResult, l as SchemaValidationResult, S as SyntaxValidationResult, X as XFormula, e as evaluate, a as evaluateWithContext, f as extractSchemaFormulas, i as inferFormulaType, b as parseExpression, p as parseFormula, h as validateFormulaAgainstSchema, d as validateFormulaSyntax, j as validateSchemaFormulas, v as validateSyntax } from './index-BEXpS2D6.cjs';
|
|
2
2
|
|
|
3
3
|
interface DependencyGraph {
|
|
4
4
|
nodes: Set<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ASTNode, E as ExtractedFormula, F as FieldTypes,
|
|
1
|
+
export { A as ASTNode, E as EvaluateContextOptions, g as ExtractedFormula, F as FieldTypes, o as FormulaAnalysis, t as FormulaContext, n as FormulaFeature, m as FormulaMinorVersion, u as FormulaResult, k as FormulaValidationError, I as InferredType, J as JsonSchema, P as ParseResult, c as ParsedExpression, r as ParsedPath, q as PathSegment, s as PathValidationResult, l as SchemaValidationResult, S as SyntaxValidationResult, X as XFormula, e as evaluate, a as evaluateWithContext, f as extractSchemaFormulas, i as inferFormulaType, b as parseExpression, p as parseFormula, h as validateFormulaAgainstSchema, d as validateFormulaSyntax, j as validateSchemaFormulas, v as validateSyntax } from './index-BEXpS2D6.js';
|
|
2
2
|
|
|
3
3
|
interface DependencyGraph {
|
|
4
4
|
nodes: Set<string>;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { buildDependencyGraph, detectCircularDependencies, evaluate, extractSchemaFormulas, getTopologicalOrder, inferFormulaType, parseExpression, parseFormula, validateFormulaAgainstSchema, validateFormulaSyntax, validateSchemaFormulas, validateSyntax } from './chunk-
|
|
2
|
-
import './chunk-PZ5AY32C.js';
|
|
1
|
+
export { buildDependencyGraph, detectCircularDependencies, evaluate, evaluateWithContext, extractSchemaFormulas, getTopologicalOrder, inferFormulaType, parseExpression, parseFormula, validateFormulaAgainstSchema, validateFormulaSyntax, validateSchemaFormulas, validateSyntax } from './chunk-INF4CK6N.js';
|
|
3
2
|
//# sourceMappingURL=index.js.map
|
|
4
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revisium/formula",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Formula expression parser and evaluator for Revisium",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"formula",
|
|
@@ -104,6 +104,6 @@
|
|
|
104
104
|
"access": "public"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"
|
|
107
|
+
"ohm-js": "^17.3.0"
|
|
108
108
|
}
|
|
109
109
|
}
|