@rippling/rippling-sdk 0.2.0-alpha.108 → 0.2.0-alpha.109
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/client.d.mts +3 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +3 -0
- package/client.d.ts.map +1 -1
- package/client.js +3 -0
- package/client.js.map +1 -1
- package/client.mjs +3 -0
- package/client.mjs.map +1 -1
- package/lib/charts/builders.d.mts +18 -19
- package/lib/charts/builders.d.mts.map +1 -1
- package/lib/charts/builders.d.ts +18 -19
- package/lib/charts/builders.d.ts.map +1 -1
- package/lib/charts/builders.js +35 -28
- package/lib/charts/builders.js.map +1 -1
- package/lib/charts/builders.mjs +35 -28
- package/lib/charts/builders.mjs.map +1 -1
- package/lib/charts/describe.d.mts +6 -7
- package/lib/charts/describe.d.mts.map +1 -1
- package/lib/charts/describe.d.ts +6 -7
- package/lib/charts/describe.d.ts.map +1 -1
- package/lib/charts/describe.js +26 -27
- package/lib/charts/describe.js.map +1 -1
- package/lib/charts/describe.mjs +27 -28
- package/lib/charts/describe.mjs.map +1 -1
- package/lib/charts/errors.d.mts +2 -6
- package/lib/charts/errors.d.mts.map +1 -1
- package/lib/charts/errors.d.ts +2 -6
- package/lib/charts/errors.d.ts.map +1 -1
- package/lib/charts/errors.js +2 -6
- package/lib/charts/errors.js.map +1 -1
- package/lib/charts/errors.mjs +2 -6
- package/lib/charts/errors.mjs.map +1 -1
- package/lib/charts/evaluate.d.mts +5 -7
- package/lib/charts/evaluate.d.mts.map +1 -1
- package/lib/charts/evaluate.d.ts +5 -7
- package/lib/charts/evaluate.d.ts.map +1 -1
- package/lib/charts/evaluate.js +21 -35
- package/lib/charts/evaluate.js.map +1 -1
- package/lib/charts/evaluate.mjs +22 -36
- package/lib/charts/evaluate.mjs.map +1 -1
- package/lib/charts/schema.d.mts +8 -97
- package/lib/charts/schema.d.mts.map +1 -1
- package/lib/charts/schema.d.ts +8 -97
- package/lib/charts/schema.d.ts.map +1 -1
- package/lib/charts/schema.js +186 -65
- package/lib/charts/schema.js.map +1 -1
- package/lib/charts/schema.mjs +185 -65
- package/lib/charts/schema.mjs.map +1 -1
- package/lib/charts/types.d.mts +40 -25
- package/lib/charts/types.d.mts.map +1 -1
- package/lib/charts/types.d.ts +40 -25
- package/lib/charts/types.d.ts.map +1 -1
- package/lib/charts/types.js +8 -10
- package/lib/charts/types.js.map +1 -1
- package/lib/charts/types.mjs +8 -10
- package/lib/charts/types.mjs.map +1 -1
- package/lib/charts/visualization-grammar.d.mts +66 -0
- package/lib/charts/visualization-grammar.d.mts.map +1 -0
- package/lib/charts/visualization-grammar.d.ts +66 -0
- package/lib/charts/visualization-grammar.d.ts.map +1 -0
- package/lib/charts/visualization-grammar.js +70 -0
- package/lib/charts/visualization-grammar.js.map +1 -0
- package/lib/charts/visualization-grammar.mjs +67 -0
- package/lib/charts/visualization-grammar.mjs.map +1 -0
- package/lib/charts/vocabulary.d.mts +7 -0
- package/lib/charts/vocabulary.d.mts.map +1 -0
- package/lib/charts/vocabulary.d.ts +7 -0
- package/lib/charts/vocabulary.d.ts.map +1 -0
- package/lib/charts/vocabulary.js +10 -0
- package/lib/charts/vocabulary.js.map +1 -0
- package/lib/charts/vocabulary.mjs +7 -0
- package/lib/charts/vocabulary.mjs.map +1 -0
- package/lib/charts.d.mts +3 -3
- package/lib/charts.d.mts.map +1 -1
- package/lib/charts.d.ts +3 -3
- package/lib/charts.d.ts.map +1 -1
- package/lib/charts.js +2 -1
- package/lib/charts.js.map +1 -1
- package/lib/charts.mjs +1 -1
- package/lib/charts.mjs.map +1 -1
- package/package.json +4 -2
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +4 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/reimbursements.d.mts +1 -1
- package/resources/reimbursements.d.ts +1 -1
- package/resources/reimbursements.js +1 -1
- package/resources/reimbursements.mjs +1 -1
- package/resources/spend-categories.d.mts +140 -0
- package/resources/spend-categories.d.mts.map +1 -0
- package/resources/spend-categories.d.ts +140 -0
- package/resources/spend-categories.d.ts.map +1 -0
- package/resources/spend-categories.js +83 -0
- package/resources/spend-categories.js.map +1 -0
- package/resources/spend-categories.mjs +79 -0
- package/resources/spend-categories.mjs.map +1 -0
- package/src/client.ts +17 -0
- package/src/lib/charts/README.md +35 -28
- package/src/lib/charts/agent-reference.md +73 -0
- package/src/lib/charts/builders.ts +51 -35
- package/src/lib/charts/capabilities.json +96 -0
- package/src/lib/charts/describe.ts +31 -29
- package/src/lib/charts/errors.ts +2 -6
- package/src/lib/charts/evaluate.ts +25 -38
- package/src/lib/charts/schema.ts +232 -66
- package/src/lib/charts/types.ts +42 -31
- package/src/lib/charts/visualization-grammar.ts +67 -0
- package/src/lib/charts/vocabulary.ts +7 -0
- package/src/lib/charts.ts +8 -1
- package/src/resources/index.ts +7 -0
- package/src/resources/reimbursements.ts +1 -1
- package/src/resources/spend-categories.ts +175 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/lib/charts/guards.d.mts +0 -15
- package/lib/charts/guards.d.mts.map +0 -1
- package/lib/charts/guards.d.ts +0 -15
- package/lib/charts/guards.d.ts.map +0 -1
- package/lib/charts/guards.js +0 -38
- package/lib/charts/guards.js.map +0 -1
- package/lib/charts/guards.mjs +0 -34
- package/lib/charts/guards.mjs.map +0 -1
- package/src/lib/charts/guards.ts +0 -42
package/lib/charts/builders.mjs
CHANGED
|
@@ -1,55 +1,64 @@
|
|
|
1
1
|
import { ChartRuleError } from "./errors.mjs";
|
|
2
|
-
function
|
|
3
|
-
return
|
|
2
|
+
function hasOwn(value, key) {
|
|
3
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
4
|
+
}
|
|
5
|
+
function isOperandNode(operand) {
|
|
6
|
+
return typeof operand === 'object' && operand !== null && hasOwn(operand, 'kind');
|
|
4
7
|
}
|
|
5
8
|
/** True when a value is a `{$rule}` placeholder — the marker the builders emit. */
|
|
6
9
|
export function isRulePlaceholder(value) {
|
|
7
|
-
return typeof value === 'object' && value !== null && '$rule'
|
|
10
|
+
return typeof value === 'object' && value !== null && hasOwn(value, '$rule');
|
|
8
11
|
}
|
|
9
12
|
/** Wrap a bare scalar as a literal node. */
|
|
10
13
|
export function literal(value) {
|
|
14
|
+
if (typeof value === 'number' && !Number.isFinite(value)) {
|
|
15
|
+
throw new ChartRuleError('literal(value) requires a finite number');
|
|
16
|
+
}
|
|
11
17
|
return { kind: 'literal', value };
|
|
12
18
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
19
|
+
function toOperandNode(operand) {
|
|
20
|
+
return isOperandNode(operand) ? operand : literal(operand);
|
|
21
|
+
}
|
|
22
|
+
function toNumericOperandNode(operand) {
|
|
23
|
+
return typeof operand === 'number' ? literal(operand) : operand;
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
20
26
|
* `value` — this data point's plotted numeric value: a bar's height, a point's
|
|
21
27
|
* y, a slice's amount. It is what a colour rule compares against a constant.
|
|
22
28
|
*/
|
|
23
29
|
export const value = Object.freeze({ kind: 'value' });
|
|
24
|
-
/* Comparisons — return a condition. */
|
|
25
|
-
function
|
|
26
|
-
return (left, right) => ({ kind, left:
|
|
30
|
+
/* Comparisons — return a condition with no nested expressions. */
|
|
31
|
+
function equalityComparison(kind) {
|
|
32
|
+
return (left, right) => ({ kind, left: toOperandNode(left), right: toOperandNode(right) });
|
|
33
|
+
}
|
|
34
|
+
function numericComparison(kind) {
|
|
35
|
+
return (left, right) => ({ kind, left: toNumericOperandNode(left), right: toNumericOperandNode(right) });
|
|
27
36
|
}
|
|
28
|
-
export const equals =
|
|
29
|
-
export const isNot =
|
|
30
|
-
export const lessThan =
|
|
31
|
-
export const greaterThan =
|
|
32
|
-
export const lessOrEqual =
|
|
33
|
-
export const greaterOrEqual =
|
|
37
|
+
export const equals = equalityComparison('equals');
|
|
38
|
+
export const isNot = equalityComparison('isNot');
|
|
39
|
+
export const lessThan = numericComparison('lessThan');
|
|
40
|
+
export const greaterThan = numericComparison('greaterThan');
|
|
41
|
+
export const lessOrEqual = numericComparison('lessOrEqual');
|
|
42
|
+
export const greaterOrEqual = numericComparison('greaterOrEqual');
|
|
34
43
|
/**
|
|
35
|
-
* A conditional
|
|
36
|
-
* Channel-agnostic — wrap it in a channel builder (`color`) to target something.
|
|
44
|
+
* A conditional colour: pick `ifTrue` when the condition holds, else `ifFalse`.
|
|
37
45
|
*
|
|
38
46
|
* when(lessThan(value, 100), '#E24B4A', '#378ADD')
|
|
39
47
|
* // → '#E24B4A' when this point's value is under 100, '#378ADD' otherwise
|
|
40
48
|
*
|
|
41
49
|
* `ifFalse` is optional and defaults to `null` — for a colour, that means no
|
|
42
|
-
* override (the chart's default is kept).
|
|
50
|
+
* override (the chart's default is kept). Branches are colour literals only;
|
|
51
|
+
* nested rules are intentionally unsupported in v1.
|
|
43
52
|
*/
|
|
44
|
-
export function when(condition, ifTrue, ifFalse) {
|
|
53
|
+
export function when(condition, ifTrue, ifFalse = null) {
|
|
45
54
|
if (ifTrue === undefined) {
|
|
46
55
|
throw new ChartRuleError('when(condition, ifTrue, ifFalse?) needs a value for the true case');
|
|
47
56
|
}
|
|
48
57
|
return {
|
|
49
58
|
kind: 'ifElse',
|
|
50
59
|
cond: condition,
|
|
51
|
-
then:
|
|
52
|
-
else:
|
|
60
|
+
then: literal(ifTrue),
|
|
61
|
+
else: literal(ifFalse),
|
|
53
62
|
};
|
|
54
63
|
}
|
|
55
64
|
/**
|
|
@@ -59,12 +68,10 @@ export function when(condition, ifTrue, ifFalse) {
|
|
|
59
68
|
* color(when(lessThan(value, 100), '#E24B4A', '#378ADD'))
|
|
60
69
|
* // → red when this point's value is under 100, blue otherwise
|
|
61
70
|
*
|
|
62
|
-
* Takes
|
|
63
|
-
*
|
|
64
|
-
* boolean, which is not a colour. `evaluate` enforces the same at runtime for a
|
|
65
|
-
* deserialized rule. Returns a `{$rule}` placeholder tagged `channel: 'color'`.
|
|
71
|
+
* Takes the flat conditional value produced by `when(...)`. Returns a `{$rule}`
|
|
72
|
+
* placeholder tagged `channel: 'color'`.
|
|
66
73
|
*/
|
|
67
74
|
export function color(rule) {
|
|
68
|
-
return { $rule:
|
|
75
|
+
return { $rule: rule, channel: 'color' };
|
|
69
76
|
}
|
|
70
77
|
//# sourceMappingURL=builders.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.mjs","sourceRoot":"","sources":["../../src/lib/charts/builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAiB;
|
|
1
|
+
{"version":3,"file":"builders.mjs","sourceRoot":"","sources":["../../src/lib/charts/builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAiB;AAkB1C,SAAS,MAAM,CAAC,KAAa,EAAE,GAAgB;IAC7C,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,aAAa,CAAC,OAAgB;IACrC,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACpF,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,OAAO,CAA8B,KAAa;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAA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iBAAiB,CAAC,UAAU,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;AAElE;;;;;;;;;GASG;AACH,MAAM,UAAU,IAAI,CAAC,SAAwB,EAAE,MAAc,EAAE,UAAyB,IAAI;IAC1F,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,cAAc,CAAC,mEAAmE,CAAC,CAAC;IAChG,CAAC;IACD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC;KACvB,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CAAC,IAAgB;IACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { type Control
|
|
1
|
+
import { type Control } from "./types.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Turn a rule into the shape the settings panel renders: a label plus its
|
|
4
|
-
* editable parts. Accepts a `{$rule}` placeholder or a bare
|
|
5
|
-
*
|
|
4
|
+
* editable parts. Accepts a `{$rule}` placeholder or a bare node. Reads the same
|
|
5
|
+
* value `evaluate` runs — and validates it the same way — so a malformed or
|
|
6
6
|
* unknown node throws a `ChartRuleError` here too, never a native `TypeError`.
|
|
7
|
-
* The
|
|
8
|
-
*
|
|
9
|
-
* A tree nested past `MAX_RULE_DEPTH` throws `RuleDepthError`.
|
|
7
|
+
* The Valibot parser rejects malformed or nested values before this flat
|
|
8
|
+
* formatter reads them.
|
|
10
9
|
*/
|
|
11
|
-
export declare function describe(rule:
|
|
10
|
+
export declare function describe(rule: unknown): Control;
|
|
12
11
|
//# sourceMappingURL=describe.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.mts","sourceRoot":"","sources":["../../src/lib/charts/describe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"describe.d.mts","sourceRoot":"","sources":["../../src/lib/charts/describe.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8B,KAAK,OAAO,EAAiB,oBAAgB;AAElF;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAM/C"}
|
package/lib/charts/describe.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { type Control
|
|
1
|
+
import { type Control } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Turn a rule into the shape the settings panel renders: a label plus its
|
|
4
|
-
* editable parts. Accepts a `{$rule}` placeholder or a bare
|
|
5
|
-
*
|
|
4
|
+
* editable parts. Accepts a `{$rule}` placeholder or a bare node. Reads the same
|
|
5
|
+
* value `evaluate` runs — and validates it the same way — so a malformed or
|
|
6
6
|
* unknown node throws a `ChartRuleError` here too, never a native `TypeError`.
|
|
7
|
-
* The
|
|
8
|
-
*
|
|
9
|
-
* A tree nested past `MAX_RULE_DEPTH` throws `RuleDepthError`.
|
|
7
|
+
* The Valibot parser rejects malformed or nested values before this flat
|
|
8
|
+
* formatter reads them.
|
|
10
9
|
*/
|
|
11
|
-
export declare function describe(rule:
|
|
10
|
+
export declare function describe(rule: unknown): Control;
|
|
12
11
|
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/lib/charts/describe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/lib/charts/describe.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8B,KAAK,OAAO,EAAiB,mBAAgB;AAElF;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAM/C"}
|
package/lib/charts/describe.js
CHANGED
|
@@ -1,62 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.describe = describe;
|
|
4
|
-
const builders_1 = require("./builders.js");
|
|
5
4
|
const errors_1 = require("./errors.js");
|
|
6
|
-
const
|
|
7
|
-
const types_1 = require("./types.js");
|
|
5
|
+
const schema_1 = require("./schema.js");
|
|
8
6
|
/**
|
|
9
7
|
* Turn a rule into the shape the settings panel renders: a label plus its
|
|
10
|
-
* editable parts. Accepts a `{$rule}` placeholder or a bare
|
|
11
|
-
*
|
|
8
|
+
* editable parts. Accepts a `{$rule}` placeholder or a bare node. Reads the same
|
|
9
|
+
* value `evaluate` runs — and validates it the same way — so a malformed or
|
|
12
10
|
* unknown node throws a `ChartRuleError` here too, never a native `TypeError`.
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
15
|
-
* A tree nested past `MAX_RULE_DEPTH` throws `RuleDepthError`.
|
|
11
|
+
* The Valibot parser rejects malformed or nested values before this flat
|
|
12
|
+
* formatter reads them.
|
|
16
13
|
*/
|
|
17
14
|
function describe(rule) {
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const parsedRule = (0, schema_1.parseChartRule)(rule);
|
|
16
|
+
if ('$rule' in parsedRule) {
|
|
17
|
+
return visit(parsedRule.$rule);
|
|
20
18
|
}
|
|
21
|
-
return visit(
|
|
19
|
+
return visit(parsedRule);
|
|
22
20
|
}
|
|
23
|
-
function visit(node
|
|
24
|
-
if (depth > types_1.MAX_RULE_DEPTH) {
|
|
25
|
-
throw new errors_1.RuleDepthError(types_1.MAX_RULE_DEPTH);
|
|
26
|
-
}
|
|
27
|
-
(0, guards_1.assertRuleNode)(node);
|
|
28
|
-
const next = depth + 1;
|
|
21
|
+
function visit(node) {
|
|
29
22
|
switch (node.kind) {
|
|
30
23
|
case 'value':
|
|
31
24
|
return { role: 'ref', label: "this row's value" };
|
|
32
25
|
case 'literal': {
|
|
33
|
-
const scalar =
|
|
26
|
+
const scalar = node.value;
|
|
34
27
|
return { role: 'literal', label: String(scalar), value: scalar };
|
|
35
28
|
}
|
|
36
29
|
case 'equals':
|
|
37
|
-
return comparison('is', node.left, node.right
|
|
30
|
+
return comparison('is', node.left, node.right);
|
|
38
31
|
case 'isNot':
|
|
39
|
-
return comparison('is not', node.left, node.right
|
|
32
|
+
return comparison('is not', node.left, node.right);
|
|
40
33
|
case 'lessThan':
|
|
41
|
-
return comparison('is under', node.left, node.right
|
|
34
|
+
return comparison('is under', node.left, node.right);
|
|
42
35
|
case 'greaterThan':
|
|
43
|
-
return comparison('is over', node.left, node.right
|
|
36
|
+
return comparison('is over', node.left, node.right);
|
|
44
37
|
case 'lessOrEqual':
|
|
45
|
-
return comparison('is at most', node.left, node.right
|
|
38
|
+
return comparison('is at most', node.left, node.right);
|
|
46
39
|
case 'greaterOrEqual':
|
|
47
|
-
return comparison('is at least', node.left, node.right
|
|
40
|
+
return comparison('is at least', node.left, node.right);
|
|
48
41
|
case 'ifElse':
|
|
49
42
|
return {
|
|
50
43
|
role: 'rule',
|
|
51
44
|
label: 'when',
|
|
52
|
-
parts: [visit(node.cond
|
|
45
|
+
parts: [visit(node.cond), literalControl(node.then.value), literalControl(node.else.value)],
|
|
53
46
|
};
|
|
54
47
|
default:
|
|
55
48
|
return unreachable(node);
|
|
56
49
|
}
|
|
57
50
|
}
|
|
58
|
-
function comparison(label, left, right
|
|
59
|
-
return { role: 'comparison', label, parts: [
|
|
51
|
+
function comparison(label, left, right) {
|
|
52
|
+
return { role: 'comparison', label, parts: [operandControl(left), operandControl(right)] };
|
|
53
|
+
}
|
|
54
|
+
function operandControl(node) {
|
|
55
|
+
return node.kind === 'value' ? { role: 'ref', label: "this row's value" } : literalControl(node.value);
|
|
56
|
+
}
|
|
57
|
+
function literalControl(value) {
|
|
58
|
+
return { role: 'literal', label: String(value), value };
|
|
60
59
|
}
|
|
61
60
|
function unreachable(node) {
|
|
62
61
|
throw new errors_1.UnknownNodeError(node.kind);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/lib/charts/describe.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/lib/charts/describe.ts"],"names":[],"mappings":";;AAYA,4BAMC;AAlBD,wCAA4C;AAC5C,wCAA0C;AAG1C;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,IAAa;IACpC,MAAM,UAAU,GAAG,IAAA,uBAAc,EAAC,IAAI,CAAC,CAAC;IACxC,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,KAAK,CAAC,IAAc;IAC3B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;QACpD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;YAC1B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACnE,CAAC;QAED,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjD,KAAK,OAAO;YACV,OAAO,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAA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G,CAAC;AAED,SAAS,cAAc,CAAC,KAAuC;IAC7D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,WAAW,CAAC,IAAW;IAC9B,MAAM,IAAI,yBAAgB,CAAE,IAA0B,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
package/lib/charts/describe.mjs
CHANGED
|
@@ -1,59 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { assertRuleNode, literalValue } from "./guards.mjs";
|
|
4
|
-
import { MAX_RULE_DEPTH } from "./types.mjs";
|
|
1
|
+
import { UnknownNodeError } from "./errors.mjs";
|
|
2
|
+
import { parseChartRule } from "./schema.mjs";
|
|
5
3
|
/**
|
|
6
4
|
* Turn a rule into the shape the settings panel renders: a label plus its
|
|
7
|
-
* editable parts. Accepts a `{$rule}` placeholder or a bare
|
|
8
|
-
*
|
|
5
|
+
* editable parts. Accepts a `{$rule}` placeholder or a bare node. Reads the same
|
|
6
|
+
* value `evaluate` runs — and validates it the same way — so a malformed or
|
|
9
7
|
* unknown node throws a `ChartRuleError` here too, never a native `TypeError`.
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
* A tree nested past `MAX_RULE_DEPTH` throws `RuleDepthError`.
|
|
8
|
+
* The Valibot parser rejects malformed or nested values before this flat
|
|
9
|
+
* formatter reads them.
|
|
13
10
|
*/
|
|
14
11
|
export function describe(rule) {
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const parsedRule = parseChartRule(rule);
|
|
13
|
+
if ('$rule' in parsedRule) {
|
|
14
|
+
return visit(parsedRule.$rule);
|
|
17
15
|
}
|
|
18
|
-
return visit(
|
|
16
|
+
return visit(parsedRule);
|
|
19
17
|
}
|
|
20
|
-
function visit(node
|
|
21
|
-
if (depth > MAX_RULE_DEPTH) {
|
|
22
|
-
throw new RuleDepthError(MAX_RULE_DEPTH);
|
|
23
|
-
}
|
|
24
|
-
assertRuleNode(node);
|
|
25
|
-
const next = depth + 1;
|
|
18
|
+
function visit(node) {
|
|
26
19
|
switch (node.kind) {
|
|
27
20
|
case 'value':
|
|
28
21
|
return { role: 'ref', label: "this row's value" };
|
|
29
22
|
case 'literal': {
|
|
30
|
-
const scalar =
|
|
23
|
+
const scalar = node.value;
|
|
31
24
|
return { role: 'literal', label: String(scalar), value: scalar };
|
|
32
25
|
}
|
|
33
26
|
case 'equals':
|
|
34
|
-
return comparison('is', node.left, node.right
|
|
27
|
+
return comparison('is', node.left, node.right);
|
|
35
28
|
case 'isNot':
|
|
36
|
-
return comparison('is not', node.left, node.right
|
|
29
|
+
return comparison('is not', node.left, node.right);
|
|
37
30
|
case 'lessThan':
|
|
38
|
-
return comparison('is under', node.left, node.right
|
|
31
|
+
return comparison('is under', node.left, node.right);
|
|
39
32
|
case 'greaterThan':
|
|
40
|
-
return comparison('is over', node.left, node.right
|
|
33
|
+
return comparison('is over', node.left, node.right);
|
|
41
34
|
case 'lessOrEqual':
|
|
42
|
-
return comparison('is at most', node.left, node.right
|
|
35
|
+
return comparison('is at most', node.left, node.right);
|
|
43
36
|
case 'greaterOrEqual':
|
|
44
|
-
return comparison('is at least', node.left, node.right
|
|
37
|
+
return comparison('is at least', node.left, node.right);
|
|
45
38
|
case 'ifElse':
|
|
46
39
|
return {
|
|
47
40
|
role: 'rule',
|
|
48
41
|
label: 'when',
|
|
49
|
-
parts: [visit(node.cond
|
|
42
|
+
parts: [visit(node.cond), literalControl(node.then.value), literalControl(node.else.value)],
|
|
50
43
|
};
|
|
51
44
|
default:
|
|
52
45
|
return unreachable(node);
|
|
53
46
|
}
|
|
54
47
|
}
|
|
55
|
-
function comparison(label, left, right
|
|
56
|
-
return { role: 'comparison', label, parts: [
|
|
48
|
+
function comparison(label, left, right) {
|
|
49
|
+
return { role: 'comparison', label, parts: [operandControl(left), operandControl(right)] };
|
|
50
|
+
}
|
|
51
|
+
function operandControl(node) {
|
|
52
|
+
return node.kind === 'value' ? { role: 'ref', label: "this row's value" } : literalControl(node.value);
|
|
53
|
+
}
|
|
54
|
+
function literalControl(value) {
|
|
55
|
+
return { role: 'literal', label: String(value), value };
|
|
57
56
|
}
|
|
58
57
|
function unreachable(node) {
|
|
59
58
|
throw new UnknownNodeError(node.kind);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.mjs","sourceRoot":"","sources":["../../src/lib/charts/describe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"describe.mjs","sourceRoot":"","sources":["../../src/lib/charts/describe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,qBAAiB;AAC5C,OAAO,EAAE,cAAc,EAAE,qBAAiB;AAG1C;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,KAAK,CAAC,IAAc;IAC3B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;QACpD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;YAC1B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACnE,CAAC;QAED,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE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AAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACzG,CAAC;AAED,SAAS,cAAc,CAAC,KAAuC;IAC7D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,WAAW,CAAC,IAAW;IAC9B,MAAM,IAAI,gBAAgB,CAAE,IAA0B,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
package/lib/charts/errors.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class RuleTypeError extends ChartRuleError {
|
|
|
14
14
|
constructor(message: string);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* A structurally invalid node in a deserialized
|
|
17
|
+
* A structurally invalid node in a deserialized value: not an object, no string
|
|
18
18
|
* `kind`, or a `literal` without a scalar `value`. Distinct from
|
|
19
19
|
* `UnknownNodeError` (a well-formed node whose `kind` is simply not in the
|
|
20
20
|
* vocabulary — the intentional escape hatch). Like the others it is a
|
|
@@ -24,11 +24,7 @@ export declare class RuleTypeError extends ChartRuleError {
|
|
|
24
24
|
export declare class MalformedRuleError extends ChartRuleError {
|
|
25
25
|
constructor(message: string);
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* A rule nested deeper than the evaluator will walk. Guards against a
|
|
29
|
-
* stack-overflowing tree from untrusted, deserialized input; like the others it
|
|
30
|
-
* is a `ChartRuleError`, so the caller's escape hatch catches it.
|
|
31
|
-
*/
|
|
27
|
+
/** @deprecated v1 is non-recursive. Retained for source compatibility. */
|
|
32
28
|
export declare class RuleDepthError extends ChartRuleError {
|
|
33
29
|
constructor(maxDepth: number);
|
|
34
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../../src/lib/charts/errors.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAE5C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;aACtB,IAAI,CAAC,EAAE,MAAM;gBAAb,IAAI,CAAC,EAAE,MAAM,YAAA;CAI1C;AAED,gFAAgF;AAChF,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED
|
|
1
|
+
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../../src/lib/charts/errors.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAE5C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;aACtB,IAAI,CAAC,EAAE,MAAM;gBAAb,IAAI,CAAC,EAAE,MAAM,YAAA;CAI1C;AAED,gFAAgF;AAChF,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED,0EAA0E;AAC1E,qBAAa,cAAe,SAAQ,cAAc;gBACpC,QAAQ,EAAE,MAAM;CAI7B"}
|
package/lib/charts/errors.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class RuleTypeError extends ChartRuleError {
|
|
|
14
14
|
constructor(message: string);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* A structurally invalid node in a deserialized
|
|
17
|
+
* A structurally invalid node in a deserialized value: not an object, no string
|
|
18
18
|
* `kind`, or a `literal` without a scalar `value`. Distinct from
|
|
19
19
|
* `UnknownNodeError` (a well-formed node whose `kind` is simply not in the
|
|
20
20
|
* vocabulary — the intentional escape hatch). Like the others it is a
|
|
@@ -24,11 +24,7 @@ export declare class RuleTypeError extends ChartRuleError {
|
|
|
24
24
|
export declare class MalformedRuleError extends ChartRuleError {
|
|
25
25
|
constructor(message: string);
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* A rule nested deeper than the evaluator will walk. Guards against a
|
|
29
|
-
* stack-overflowing tree from untrusted, deserialized input; like the others it
|
|
30
|
-
* is a `ChartRuleError`, so the caller's escape hatch catches it.
|
|
31
|
-
*/
|
|
27
|
+
/** @deprecated v1 is non-recursive. Retained for source compatibility. */
|
|
32
28
|
export declare class RuleDepthError extends ChartRuleError {
|
|
33
29
|
constructor(maxDepth: number);
|
|
34
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/charts/errors.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAE5C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;aACtB,IAAI,CAAC,EAAE,MAAM;gBAAb,IAAI,CAAC,EAAE,MAAM,YAAA;CAI1C;AAED,gFAAgF;AAChF,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/charts/errors.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAE5C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;aACtB,IAAI,CAAC,EAAE,MAAM;gBAAb,IAAI,CAAC,EAAE,MAAM,YAAA;CAI1C;AAED,gFAAgF;AAChF,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED,0EAA0E;AAC1E,qBAAa,cAAe,SAAQ,cAAc;gBACpC,QAAQ,EAAE,MAAM;CAI7B"}
|
package/lib/charts/errors.js
CHANGED
|
@@ -26,7 +26,7 @@ class RuleTypeError extends ChartRuleError {
|
|
|
26
26
|
}
|
|
27
27
|
exports.RuleTypeError = RuleTypeError;
|
|
28
28
|
/**
|
|
29
|
-
* A structurally invalid node in a deserialized
|
|
29
|
+
* A structurally invalid node in a deserialized value: not an object, no string
|
|
30
30
|
* `kind`, or a `literal` without a scalar `value`. Distinct from
|
|
31
31
|
* `UnknownNodeError` (a well-formed node whose `kind` is simply not in the
|
|
32
32
|
* vocabulary — the intentional escape hatch). Like the others it is a
|
|
@@ -40,11 +40,7 @@ class MalformedRuleError extends ChartRuleError {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
exports.MalformedRuleError = MalformedRuleError;
|
|
43
|
-
/**
|
|
44
|
-
* A rule nested deeper than the evaluator will walk. Guards against a
|
|
45
|
-
* stack-overflowing tree from untrusted, deserialized input; like the others it
|
|
46
|
-
* is a `ChartRuleError`, so the caller's escape hatch catches it.
|
|
47
|
-
*/
|
|
43
|
+
/** @deprecated v1 is non-recursive. Retained for source compatibility. */
|
|
48
44
|
class RuleDepthError extends ChartRuleError {
|
|
49
45
|
constructor(maxDepth) {
|
|
50
46
|
super(`chart rule nested deeper than ${maxDepth} levels`);
|
package/lib/charts/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/charts/errors.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,MAAa,cAAe,SAAQ,KAAK;CAAG;AAA5C,wCAA4C;AAE5C;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,cAAc;IAClD,YAA4B,IAAa;QACvC,KAAK,CAAC,4BAA4B,IAAI,IAAI,gBAAgB,EAAE,CAAC,CAAC;QADpC,SAAI,GAAJ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Y,QAAgB;QAC1B,KAAK,CAAC,iCAAiC,QAAQ,SAAS,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC"}
|
package/lib/charts/errors.mjs
CHANGED
|
@@ -20,7 +20,7 @@ export class RuleTypeError extends ChartRuleError {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* A structurally invalid node in a deserialized
|
|
23
|
+
* A structurally invalid node in a deserialized value: not an object, no string
|
|
24
24
|
* `kind`, or a `literal` without a scalar `value`. Distinct from
|
|
25
25
|
* `UnknownNodeError` (a well-formed node whose `kind` is simply not in the
|
|
26
26
|
* vocabulary — the intentional escape hatch). Like the others it is a
|
|
@@ -33,11 +33,7 @@ export class MalformedRuleError extends ChartRuleError {
|
|
|
33
33
|
this.name = 'MalformedRuleError';
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
37
|
-
* A rule nested deeper than the evaluator will walk. Guards against a
|
|
38
|
-
* stack-overflowing tree from untrusted, deserialized input; like the others it
|
|
39
|
-
* is a `ChartRuleError`, so the caller's escape hatch catches it.
|
|
40
|
-
*/
|
|
36
|
+
/** @deprecated v1 is non-recursive. Retained for source compatibility. */
|
|
41
37
|
export class RuleDepthError extends ChartRuleError {
|
|
42
38
|
constructor(maxDepth) {
|
|
43
39
|
super(`chart rule nested deeper than ${maxDepth} levels`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../../src/lib/charts/errors.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,OAAO,cAAe,SAAQ,KAAK;CAAG;AAE5C;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IAClD,YAA4B,IAAa;QACvC,KAAK,CAAC,4BAA4B,IAAI,IAAI,gBAAgB,EAAE,CAAC,CAAC;QADpC,SAAI,GAAJ,IAAI,CAAS;QAE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AC1D,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RuleContext, type RuleValue } from "./types.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a rule to a value against `ctx`. Accepts a `{$rule}` placeholder or a
|
|
4
|
-
* bare
|
|
4
|
+
* bare node. A malformed or unknown node throws a `ChartRuleError` (never a
|
|
5
5
|
* native `TypeError`), so a caller reading an untrusted, deserialized rule can
|
|
6
6
|
* catch every failure with one type. When the rule is a colour placeholder, the
|
|
7
7
|
* result is checked to be a colour (`string | null`) — a rule that resolves to a
|
|
8
8
|
* number or boolean is a `RuleTypeError`, not something the renderer paints.
|
|
9
9
|
*
|
|
10
|
-
* Pure: the only inputs are the
|
|
11
|
-
*
|
|
12
|
-
* and identical across the renderer, the panel readout, and a test. A tree
|
|
13
|
-
* nested past `MAX_RULE_DEPTH` throws `RuleDepthError` rather than overflowing.
|
|
10
|
+
* Pure and non-recursive: the only inputs are the validated flat rule and the
|
|
11
|
+
* context. No clock, randomness, callbacks, or I/O.
|
|
14
12
|
*/
|
|
15
|
-
export declare function evaluate(rule:
|
|
13
|
+
export declare function evaluate(rule: unknown, ctx: RuleContext): RuleValue;
|
|
16
14
|
//# sourceMappingURL=evaluate.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.mts","sourceRoot":"","sources":["../../src/lib/charts/evaluate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluate.d.mts","sourceRoot":"","sources":["../../src/lib/charts/evaluate.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,WAAW,EAEhB,KAAK,SAAS,EACf,oBAAgB;AAEjB;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,CAMnE"}
|
package/lib/charts/evaluate.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RuleContext, type RuleValue } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a rule to a value against `ctx`. Accepts a `{$rule}` placeholder or a
|
|
4
|
-
* bare
|
|
4
|
+
* bare node. A malformed or unknown node throws a `ChartRuleError` (never a
|
|
5
5
|
* native `TypeError`), so a caller reading an untrusted, deserialized rule can
|
|
6
6
|
* catch every failure with one type. When the rule is a colour placeholder, the
|
|
7
7
|
* result is checked to be a colour (`string | null`) — a rule that resolves to a
|
|
8
8
|
* number or boolean is a `RuleTypeError`, not something the renderer paints.
|
|
9
9
|
*
|
|
10
|
-
* Pure: the only inputs are the
|
|
11
|
-
*
|
|
12
|
-
* and identical across the renderer, the panel readout, and a test. A tree
|
|
13
|
-
* nested past `MAX_RULE_DEPTH` throws `RuleDepthError` rather than overflowing.
|
|
10
|
+
* Pure and non-recursive: the only inputs are the validated flat rule and the
|
|
11
|
+
* context. No clock, randomness, callbacks, or I/O.
|
|
14
12
|
*/
|
|
15
|
-
export declare function evaluate(rule:
|
|
13
|
+
export declare function evaluate(rule: unknown, ctx: RuleContext): RuleValue;
|
|
16
14
|
//# sourceMappingURL=evaluate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/lib/charts/evaluate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/lib/charts/evaluate.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,WAAW,EAEhB,KAAK,SAAS,EACf,mBAAgB;AAEjB;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,CAMnE"}
|