@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/evaluate.js
CHANGED
|
@@ -1,54 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.evaluate = evaluate;
|
|
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
|
* Resolve a rule to a value against `ctx`. Accepts a `{$rule}` placeholder or a
|
|
10
|
-
* bare
|
|
8
|
+
* bare node. A malformed or unknown node throws a `ChartRuleError` (never a
|
|
11
9
|
* native `TypeError`), so a caller reading an untrusted, deserialized rule can
|
|
12
10
|
* catch every failure with one type. When the rule is a colour placeholder, the
|
|
13
11
|
* result is checked to be a colour (`string | null`) — a rule that resolves to a
|
|
14
12
|
* number or boolean is a `RuleTypeError`, not something the renderer paints.
|
|
15
13
|
*
|
|
16
|
-
* Pure: the only inputs are the
|
|
17
|
-
*
|
|
18
|
-
* and identical across the renderer, the panel readout, and a test. A tree
|
|
19
|
-
* nested past `MAX_RULE_DEPTH` throws `RuleDepthError` rather than overflowing.
|
|
14
|
+
* Pure and non-recursive: the only inputs are the validated flat rule and the
|
|
15
|
+
* context. No clock, randomness, callbacks, or I/O.
|
|
20
16
|
*/
|
|
21
17
|
function evaluate(rule, ctx) {
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const parsedRule = (0, schema_1.parseChartRule)(rule);
|
|
19
|
+
if ('$rule' in parsedRule) {
|
|
20
|
+
return coerceForChannel(parsedRule.channel, visit(parsedRule.$rule, ctx));
|
|
24
21
|
}
|
|
25
|
-
return visit(
|
|
22
|
+
return visit(parsedRule, ctx);
|
|
26
23
|
}
|
|
27
|
-
function visit(node, ctx
|
|
28
|
-
if (depth > types_1.MAX_RULE_DEPTH) {
|
|
29
|
-
throw new errors_1.RuleDepthError(types_1.MAX_RULE_DEPTH);
|
|
30
|
-
}
|
|
31
|
-
(0, guards_1.assertRuleNode)(node);
|
|
32
|
-
const next = depth + 1;
|
|
24
|
+
function visit(node, ctx) {
|
|
33
25
|
switch (node.kind) {
|
|
34
26
|
case 'value':
|
|
35
27
|
return ctx.value;
|
|
36
28
|
case 'literal':
|
|
37
|
-
return
|
|
29
|
+
return node.value;
|
|
38
30
|
case 'equals':
|
|
39
|
-
return
|
|
31
|
+
return operand(node.left, ctx) === operand(node.right, ctx);
|
|
40
32
|
case 'isNot':
|
|
41
|
-
return
|
|
33
|
+
return operand(node.left, ctx) !== operand(node.right, ctx);
|
|
42
34
|
case 'lessThan':
|
|
43
|
-
return
|
|
35
|
+
return numericOperand(node.left, ctx) < numericOperand(node.right, ctx);
|
|
44
36
|
case 'greaterThan':
|
|
45
|
-
return
|
|
37
|
+
return numericOperand(node.left, ctx) > numericOperand(node.right, ctx);
|
|
46
38
|
case 'lessOrEqual':
|
|
47
|
-
return
|
|
39
|
+
return numericOperand(node.left, ctx) <= numericOperand(node.right, ctx);
|
|
48
40
|
case 'greaterOrEqual':
|
|
49
|
-
return
|
|
41
|
+
return numericOperand(node.left, ctx) >= numericOperand(node.right, ctx);
|
|
50
42
|
case 'ifElse':
|
|
51
|
-
return
|
|
43
|
+
return visit(node.cond, ctx) ? node.then.value : node.else.value;
|
|
52
44
|
default:
|
|
53
45
|
return unreachable(node);
|
|
54
46
|
}
|
|
@@ -56,17 +48,11 @@ function visit(node, ctx, depth) {
|
|
|
56
48
|
/* -------------------------------------------------------------------------- */
|
|
57
49
|
/* Coercions — narrow a RuleValue, or throw a typed error. */
|
|
58
50
|
/* -------------------------------------------------------------------------- */
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
return value;
|
|
62
|
-
}
|
|
63
|
-
throw new errors_1.RuleTypeError(`expected a number, got ${typeName(value)}`);
|
|
51
|
+
function operand(node, ctx) {
|
|
52
|
+
return node.kind === 'value' ? ctx.value : node.value;
|
|
64
53
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
return value;
|
|
68
|
-
}
|
|
69
|
-
throw new errors_1.RuleTypeError(`expected a boolean, got ${typeName(value)}`);
|
|
54
|
+
function numericOperand(node, ctx) {
|
|
55
|
+
return node.kind === 'value' ? ctx.value : node.value;
|
|
70
56
|
}
|
|
71
57
|
/** A colour channel must resolve to a colour string, or null for "no override". */
|
|
72
58
|
function asColor(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/lib/charts/evaluate.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/lib/charts/evaluate.ts"],"names":[],"mappings":";;AAsBA,4BAMC;AA5BD,wCAA+E;AAC/E,wCAA0C;AAU1C;;;;;;;;;;GAUG;AACH,SAAgB,QAAQ,CAAC,IAAa,EAAE,GAAgB;IACtD,MAAM,UAAU,GAAG,IAAA,uBAAc,EAAC,IAAI,CAAC,CAAC;IACxC,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;QAC1B,OAAO,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,KAAK,CAAC,IAAc,EAAE,GAAgB;IAC7C,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,GAAG,CAAC,KAAK,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,IAAI,CAAC,KAAK,CAAC;QAEpB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9D,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9D,KAAK,UAAU;YACb,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GA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ACf,CAAC;IACD,MAAM,IAAI,sBAAa,CAAC,8DAA8D,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC3G,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,OAAoB,EAAE,KAAgB;IAC9D,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB;YACE,MAAM,IAAI,2BAAkB,CAAC,kDAAkD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtG,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAgB;IAChC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;AAChD,CAAC;AAED,SAAS,WAAW,CAAC,IAAW;IAC9B,MAAM,IAAI,yBAAgB,CAAE,IAA0B,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
package/lib/charts/evaluate.mjs
CHANGED
|
@@ -1,51 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { assertRuleNode, literalValue } from "./guards.mjs";
|
|
4
|
-
import { MAX_RULE_DEPTH, } from "./types.mjs";
|
|
1
|
+
import { MalformedRuleError, RuleTypeError, UnknownNodeError } from "./errors.mjs";
|
|
2
|
+
import { parseChartRule } from "./schema.mjs";
|
|
5
3
|
/**
|
|
6
4
|
* Resolve a rule to a value against `ctx`. Accepts a `{$rule}` placeholder or a
|
|
7
|
-
* bare
|
|
5
|
+
* bare node. A malformed or unknown node throws a `ChartRuleError` (never a
|
|
8
6
|
* native `TypeError`), so a caller reading an untrusted, deserialized rule can
|
|
9
7
|
* catch every failure with one type. When the rule is a colour placeholder, the
|
|
10
8
|
* result is checked to be a colour (`string | null`) — a rule that resolves to a
|
|
11
9
|
* number or boolean is a `RuleTypeError`, not something the renderer paints.
|
|
12
10
|
*
|
|
13
|
-
* Pure: the only inputs are the
|
|
14
|
-
*
|
|
15
|
-
* and identical across the renderer, the panel readout, and a test. A tree
|
|
16
|
-
* nested past `MAX_RULE_DEPTH` throws `RuleDepthError` rather than overflowing.
|
|
11
|
+
* Pure and non-recursive: the only inputs are the validated flat rule and the
|
|
12
|
+
* context. No clock, randomness, callbacks, or I/O.
|
|
17
13
|
*/
|
|
18
14
|
export function evaluate(rule, ctx) {
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const parsedRule = parseChartRule(rule);
|
|
16
|
+
if ('$rule' in parsedRule) {
|
|
17
|
+
return coerceForChannel(parsedRule.channel, visit(parsedRule.$rule, ctx));
|
|
21
18
|
}
|
|
22
|
-
return visit(
|
|
19
|
+
return visit(parsedRule, ctx);
|
|
23
20
|
}
|
|
24
|
-
function visit(node, ctx
|
|
25
|
-
if (depth > MAX_RULE_DEPTH) {
|
|
26
|
-
throw new RuleDepthError(MAX_RULE_DEPTH);
|
|
27
|
-
}
|
|
28
|
-
assertRuleNode(node);
|
|
29
|
-
const next = depth + 1;
|
|
21
|
+
function visit(node, ctx) {
|
|
30
22
|
switch (node.kind) {
|
|
31
23
|
case 'value':
|
|
32
24
|
return ctx.value;
|
|
33
25
|
case 'literal':
|
|
34
|
-
return
|
|
26
|
+
return node.value;
|
|
35
27
|
case 'equals':
|
|
36
|
-
return
|
|
28
|
+
return operand(node.left, ctx) === operand(node.right, ctx);
|
|
37
29
|
case 'isNot':
|
|
38
|
-
return
|
|
30
|
+
return operand(node.left, ctx) !== operand(node.right, ctx);
|
|
39
31
|
case 'lessThan':
|
|
40
|
-
return
|
|
32
|
+
return numericOperand(node.left, ctx) < numericOperand(node.right, ctx);
|
|
41
33
|
case 'greaterThan':
|
|
42
|
-
return
|
|
34
|
+
return numericOperand(node.left, ctx) > numericOperand(node.right, ctx);
|
|
43
35
|
case 'lessOrEqual':
|
|
44
|
-
return
|
|
36
|
+
return numericOperand(node.left, ctx) <= numericOperand(node.right, ctx);
|
|
45
37
|
case 'greaterOrEqual':
|
|
46
|
-
return
|
|
38
|
+
return numericOperand(node.left, ctx) >= numericOperand(node.right, ctx);
|
|
47
39
|
case 'ifElse':
|
|
48
|
-
return
|
|
40
|
+
return visit(node.cond, ctx) ? node.then.value : node.else.value;
|
|
49
41
|
default:
|
|
50
42
|
return unreachable(node);
|
|
51
43
|
}
|
|
@@ -53,17 +45,11 @@ function visit(node, ctx, depth) {
|
|
|
53
45
|
/* -------------------------------------------------------------------------- */
|
|
54
46
|
/* Coercions — narrow a RuleValue, or throw a typed error. */
|
|
55
47
|
/* -------------------------------------------------------------------------- */
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
throw new RuleTypeError(`expected a number, got ${typeName(value)}`);
|
|
48
|
+
function operand(node, ctx) {
|
|
49
|
+
return node.kind === 'value' ? ctx.value : node.value;
|
|
61
50
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
66
|
-
throw new RuleTypeError(`expected a boolean, got ${typeName(value)}`);
|
|
51
|
+
function numericOperand(node, ctx) {
|
|
52
|
+
return node.kind === 'value' ? ctx.value : node.value;
|
|
67
53
|
}
|
|
68
54
|
/** A colour channel must resolve to a colour string, or null for "no override". */
|
|
69
55
|
function asColor(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.mjs","sourceRoot":"","sources":["../../src/lib/charts/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"evaluate.mjs","sourceRoot":"","sources":["../../src/lib/charts/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAiB;AAC/E,OAAO,EAAE,cAAc,EAAE,qBAAiB;AAU1C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAa,EAAE,GAAgB;IACtD,MAAM,UAAU,GAAG,cAAc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AAQ,CAAC,KAAgB;IAChC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;AAChD,CAAC;AAED,SAAS,WAAW,CAAC,IAAW;IAC9B,MAAM,IAAI,gBAAgB,CAAE,IAA0B,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
package/lib/charts/schema.d.mts
CHANGED
|
@@ -1,101 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { type BaseIssue, type GenericSchema } from 'valibot';
|
|
2
|
+
import { type ParsedRule, type Rule } from "./types.mjs";
|
|
3
|
+
/** @deprecated Use `CHART_RULE_CONTRACT_VERSION` to identify the executable contract. */
|
|
2
4
|
export declare const CHART_RULE_SCHEMA_ID: string;
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This is the contract. A consumer that keeps its own rule evaluator (rather
|
|
7
|
-
* than importing `evaluate`) can validate against this so the two never drift —
|
|
8
|
-
* every kind and operand shape the builders can emit is described here.
|
|
6
|
+
* Runtime schema for either a bare rule node or a chart-option placeholder.
|
|
7
|
+
* Persisted and agent-authored JSON crosses this boundary as `unknown`.
|
|
9
8
|
*/
|
|
10
|
-
export declare const chartRuleSchema:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly title: "Chart rule placeholder";
|
|
14
|
-
readonly description: "A rule tree the chart agent emits into a chart option, marked with $rule.";
|
|
15
|
-
readonly type: "object";
|
|
16
|
-
readonly required: readonly ["$rule", "channel"];
|
|
17
|
-
readonly additionalProperties: false;
|
|
18
|
-
readonly properties: {
|
|
19
|
-
readonly $rule: {
|
|
20
|
-
readonly $ref: "#/$defs/ifElse";
|
|
21
|
-
};
|
|
22
|
-
readonly channel: {
|
|
23
|
-
readonly const: "color";
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
readonly $defs: {
|
|
27
|
-
readonly scalar: {
|
|
28
|
-
readonly type: readonly ["number", "string", "boolean", "null"];
|
|
29
|
-
};
|
|
30
|
-
readonly node: {
|
|
31
|
-
readonly oneOf: readonly [{
|
|
32
|
-
readonly $ref: "#/$defs/ref";
|
|
33
|
-
}, {
|
|
34
|
-
readonly $ref: "#/$defs/literal";
|
|
35
|
-
}, {
|
|
36
|
-
readonly $ref: "#/$defs/comparison";
|
|
37
|
-
}, {
|
|
38
|
-
readonly $ref: "#/$defs/ifElse";
|
|
39
|
-
}];
|
|
40
|
-
};
|
|
41
|
-
readonly ref: {
|
|
42
|
-
readonly type: "object";
|
|
43
|
-
readonly required: readonly ["kind"];
|
|
44
|
-
readonly additionalProperties: false;
|
|
45
|
-
readonly properties: {
|
|
46
|
-
readonly kind: {
|
|
47
|
-
readonly const: "value";
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
readonly literal: {
|
|
52
|
-
readonly type: "object";
|
|
53
|
-
readonly required: readonly ["kind", "value"];
|
|
54
|
-
readonly additionalProperties: false;
|
|
55
|
-
readonly properties: {
|
|
56
|
-
readonly kind: {
|
|
57
|
-
readonly const: "literal";
|
|
58
|
-
};
|
|
59
|
-
readonly value: {
|
|
60
|
-
readonly $ref: "#/$defs/scalar";
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
readonly comparison: {
|
|
65
|
-
readonly type: "object";
|
|
66
|
-
readonly required: readonly ["kind", "left", "right"];
|
|
67
|
-
readonly additionalProperties: false;
|
|
68
|
-
readonly properties: {
|
|
69
|
-
readonly kind: {
|
|
70
|
-
readonly enum: readonly ["equals", "isNot", "lessThan", "greaterThan", "lessOrEqual", "greaterOrEqual"];
|
|
71
|
-
};
|
|
72
|
-
readonly left: {
|
|
73
|
-
readonly $ref: "#/$defs/node";
|
|
74
|
-
};
|
|
75
|
-
readonly right: {
|
|
76
|
-
readonly $ref: "#/$defs/node";
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
readonly ifElse: {
|
|
81
|
-
readonly type: "object";
|
|
82
|
-
readonly required: readonly ["kind", "cond", "then", "else"];
|
|
83
|
-
readonly additionalProperties: false;
|
|
84
|
-
readonly properties: {
|
|
85
|
-
readonly kind: {
|
|
86
|
-
readonly const: "ifElse";
|
|
87
|
-
};
|
|
88
|
-
readonly cond: {
|
|
89
|
-
readonly $ref: "#/$defs/node";
|
|
90
|
-
};
|
|
91
|
-
readonly then: {
|
|
92
|
-
readonly $ref: "#/$defs/node";
|
|
93
|
-
};
|
|
94
|
-
readonly else: {
|
|
95
|
-
readonly $ref: "#/$defs/node";
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
};
|
|
9
|
+
export declare const chartRuleSchema: GenericSchema<unknown, Rule, BaseIssue<unknown>>;
|
|
10
|
+
/** Parse untrusted chart-rule JSON and return an immutable validated clone. */
|
|
11
|
+
export declare function parseChartRule(input: unknown): ParsedRule;
|
|
101
12
|
//# sourceMappingURL=schema.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.mts","sourceRoot":"","sources":["../../src/lib/charts/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.mts","sourceRoot":"","sources":["../../src/lib/charts/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,aAAa,EAanB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAA+B,KAAK,UAAU,EAAE,KAAK,IAAI,EAA8B,oBAAgB;AAoB9G,yFAAyF;AACzF,eAAO,MAAM,oBAAoB,QAAqE,CAAC;AAiEvG;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAG3E,CAAC;AAEH,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAUzD"}
|
package/lib/charts/schema.d.ts
CHANGED
|
@@ -1,101 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { type BaseIssue, type GenericSchema } from 'valibot';
|
|
2
|
+
import { type ParsedRule, type Rule } from "./types.js";
|
|
3
|
+
/** @deprecated Use `CHART_RULE_CONTRACT_VERSION` to identify the executable contract. */
|
|
2
4
|
export declare const CHART_RULE_SCHEMA_ID: string;
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This is the contract. A consumer that keeps its own rule evaluator (rather
|
|
7
|
-
* than importing `evaluate`) can validate against this so the two never drift —
|
|
8
|
-
* every kind and operand shape the builders can emit is described here.
|
|
6
|
+
* Runtime schema for either a bare rule node or a chart-option placeholder.
|
|
7
|
+
* Persisted and agent-authored JSON crosses this boundary as `unknown`.
|
|
9
8
|
*/
|
|
10
|
-
export declare const chartRuleSchema:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly title: "Chart rule placeholder";
|
|
14
|
-
readonly description: "A rule tree the chart agent emits into a chart option, marked with $rule.";
|
|
15
|
-
readonly type: "object";
|
|
16
|
-
readonly required: readonly ["$rule", "channel"];
|
|
17
|
-
readonly additionalProperties: false;
|
|
18
|
-
readonly properties: {
|
|
19
|
-
readonly $rule: {
|
|
20
|
-
readonly $ref: "#/$defs/ifElse";
|
|
21
|
-
};
|
|
22
|
-
readonly channel: {
|
|
23
|
-
readonly const: "color";
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
readonly $defs: {
|
|
27
|
-
readonly scalar: {
|
|
28
|
-
readonly type: readonly ["number", "string", "boolean", "null"];
|
|
29
|
-
};
|
|
30
|
-
readonly node: {
|
|
31
|
-
readonly oneOf: readonly [{
|
|
32
|
-
readonly $ref: "#/$defs/ref";
|
|
33
|
-
}, {
|
|
34
|
-
readonly $ref: "#/$defs/literal";
|
|
35
|
-
}, {
|
|
36
|
-
readonly $ref: "#/$defs/comparison";
|
|
37
|
-
}, {
|
|
38
|
-
readonly $ref: "#/$defs/ifElse";
|
|
39
|
-
}];
|
|
40
|
-
};
|
|
41
|
-
readonly ref: {
|
|
42
|
-
readonly type: "object";
|
|
43
|
-
readonly required: readonly ["kind"];
|
|
44
|
-
readonly additionalProperties: false;
|
|
45
|
-
readonly properties: {
|
|
46
|
-
readonly kind: {
|
|
47
|
-
readonly const: "value";
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
readonly literal: {
|
|
52
|
-
readonly type: "object";
|
|
53
|
-
readonly required: readonly ["kind", "value"];
|
|
54
|
-
readonly additionalProperties: false;
|
|
55
|
-
readonly properties: {
|
|
56
|
-
readonly kind: {
|
|
57
|
-
readonly const: "literal";
|
|
58
|
-
};
|
|
59
|
-
readonly value: {
|
|
60
|
-
readonly $ref: "#/$defs/scalar";
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
readonly comparison: {
|
|
65
|
-
readonly type: "object";
|
|
66
|
-
readonly required: readonly ["kind", "left", "right"];
|
|
67
|
-
readonly additionalProperties: false;
|
|
68
|
-
readonly properties: {
|
|
69
|
-
readonly kind: {
|
|
70
|
-
readonly enum: readonly ["equals", "isNot", "lessThan", "greaterThan", "lessOrEqual", "greaterOrEqual"];
|
|
71
|
-
};
|
|
72
|
-
readonly left: {
|
|
73
|
-
readonly $ref: "#/$defs/node";
|
|
74
|
-
};
|
|
75
|
-
readonly right: {
|
|
76
|
-
readonly $ref: "#/$defs/node";
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
readonly ifElse: {
|
|
81
|
-
readonly type: "object";
|
|
82
|
-
readonly required: readonly ["kind", "cond", "then", "else"];
|
|
83
|
-
readonly additionalProperties: false;
|
|
84
|
-
readonly properties: {
|
|
85
|
-
readonly kind: {
|
|
86
|
-
readonly const: "ifElse";
|
|
87
|
-
};
|
|
88
|
-
readonly cond: {
|
|
89
|
-
readonly $ref: "#/$defs/node";
|
|
90
|
-
};
|
|
91
|
-
readonly then: {
|
|
92
|
-
readonly $ref: "#/$defs/node";
|
|
93
|
-
};
|
|
94
|
-
readonly else: {
|
|
95
|
-
readonly $ref: "#/$defs/node";
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
};
|
|
9
|
+
export declare const chartRuleSchema: GenericSchema<unknown, Rule, BaseIssue<unknown>>;
|
|
10
|
+
/** Parse untrusted chart-rule JSON and return an immutable validated clone. */
|
|
11
|
+
export declare function parseChartRule(input: unknown): ParsedRule;
|
|
101
12
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/charts/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/charts/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,aAAa,EAanB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAA+B,KAAK,UAAU,EAAE,KAAK,IAAI,EAA8B,mBAAgB;AAoB9G,yFAAyF;AACzF,eAAO,MAAM,oBAAoB,QAAqE,CAAC;AAiEvG;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAG3E,CAAC;AAEH,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAUzD"}
|