@spotto/manifest-rules 0.0.0-stage → 1.0.70-alpha.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +189 -0
- package/dist/index.js +485 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -4
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest rules: the one evaluator (MANIFEST_RULES.md, MANIFEST_IMPLEMENTATION.md §4).
|
|
3
|
+
*
|
|
4
|
+
* A manifest's lines count what was found; its rules judge it. This module
|
|
5
|
+
* evaluates the rules over a set of found items and, for READINESS rules, over
|
|
6
|
+
* a check's answers. It is shared by everything that has to reach the same
|
|
7
|
+
* result from the same items: the snapshot write, the kit recompute, and the
|
|
8
|
+
* client's check screen.
|
|
9
|
+
*
|
|
10
|
+
* Two things it does NOT have, by design, so that it can run in all three:
|
|
11
|
+
*
|
|
12
|
+
* - **No database.** The caller loads the items and says which type each rule
|
|
13
|
+
* names. What "the items found" are is the caller's decision too (at a check,
|
|
14
|
+
* the entries the lines count; between checks, what the kit holds).
|
|
15
|
+
* - **No expression engine of its own.** Expressions go through `@spotto/excelexp`,
|
|
16
|
+
* the engine behind readiness, and the caller hands it in (`RuleEngine`). The
|
|
17
|
+
* API and the client each have their own copy of that engine, at their own
|
|
18
|
+
* version, and a field value in their own stored form; the caller turns a
|
|
19
|
+
* value into the engine's form and this module never looks inside one.
|
|
20
|
+
*
|
|
21
|
+
* What it decides, so that no two callers can decide it differently:
|
|
22
|
+
*
|
|
23
|
+
* - **Order is by code unit.** Names are compared as plain `<` compares
|
|
24
|
+
* strings, then ids, never by locale. A device set to another language and
|
|
25
|
+
* the server must take the same items, because which `to` items a rule takes
|
|
26
|
+
* decides which later rule comes out short.
|
|
27
|
+
* - **`match` compares stored values.** Two items match on a field when they
|
|
28
|
+
* hold the same stored value of the same kind. Text `18` and text `18.0` are
|
|
29
|
+
* different values, though a filter's `==` would read both as the number 18.
|
|
30
|
+
* - **An expression follows a readiness rule's missing-value policy.** Text
|
|
31
|
+
* with no value reads as `''`, a yes/no as `false`; a number or a date with
|
|
32
|
+
* no value fails the rule closed, as "Missing data: …", unless the
|
|
33
|
+
* expression tests it with `ISSET()` or `ISBLANK()`.
|
|
34
|
+
* - **A filter (`where`) is different.** It chooses, it does not judge: an item
|
|
35
|
+
* with no value in a name the filter reads is left out, unless the filter
|
|
36
|
+
* tests that name with `ISSET()` or `ISBLANK()`.
|
|
37
|
+
*/
|
|
38
|
+
import { IManifestRule, IManifestRuleResult, ManifestRuleKind, ManifestRuleLevel, ManifestRuleValue } from '@spotto/contract';
|
|
39
|
+
/**
|
|
40
|
+
* The expression engine, as `@spotto/excelexp` exports it: pass the module
|
|
41
|
+
* itself. `F` is its field value, which this module only passes through.
|
|
42
|
+
*/
|
|
43
|
+
export interface RuleEngine<F> {
|
|
44
|
+
EvaluateCondition(fields: F[], condition: string, now: Date, zone: string): boolean;
|
|
45
|
+
FormatMessage(template: string, fields: F[], zone: string): {
|
|
46
|
+
rendered: string;
|
|
47
|
+
};
|
|
48
|
+
ReferencedFields(expression: string): string[];
|
|
49
|
+
PresenceGuardedFields(expression: string): string[];
|
|
50
|
+
TemplateFields(template: string): string[];
|
|
51
|
+
newFieldValue(init: {
|
|
52
|
+
Name: string;
|
|
53
|
+
Type: number;
|
|
54
|
+
StringValue?: string;
|
|
55
|
+
BoolValue?: boolean;
|
|
56
|
+
}): F;
|
|
57
|
+
FieldType: {
|
|
58
|
+
String: number;
|
|
59
|
+
Bool: number;
|
|
60
|
+
Checkboxes: number;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export declare type RuleDataType = 'STRING' | 'INTEGER' | 'DECIMAL' | 'BOOLEAN' | 'DATE' | 'DATETIME';
|
|
64
|
+
/** A stored value, for `match` and as evidence. A multi-select is its ticked options. */
|
|
65
|
+
export declare type RuleStoredValue = string | number | boolean | string[];
|
|
66
|
+
/** What a subject holds under one name. */
|
|
67
|
+
export interface RuleField<F> {
|
|
68
|
+
/** The field's data type, where the subject defines the name at all. */
|
|
69
|
+
dataType?: RuleDataType;
|
|
70
|
+
/** A multi-select: its entries are a set, and an empty set is not missing data. */
|
|
71
|
+
checkboxes?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The value in the engine's form: one entry, or one per ticked option for a
|
|
74
|
+
* multi-select. Empty when the subject has no value under the name; an
|
|
75
|
+
* empty multi-select may be given empty too, and still resolves.
|
|
76
|
+
*/
|
|
77
|
+
fields: F[];
|
|
78
|
+
/** The value as stored. Undefined when there is none. */
|
|
79
|
+
stored?: RuleStoredValue;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Something an expression is evaluated over: a found item, or a check (its
|
|
83
|
+
* answers over the checked asset's values and the context).
|
|
84
|
+
*/
|
|
85
|
+
export interface RuleSubject<F> {
|
|
86
|
+
/** The subject's EFFECTIVE value under a name: its own, with its type's
|
|
87
|
+
* type-level value filling in where it has none. */
|
|
88
|
+
field(name: string): RuleField<F>;
|
|
89
|
+
}
|
|
90
|
+
/** A found item. */
|
|
91
|
+
export interface RuleItem<F> extends RuleSubject<F> {
|
|
92
|
+
assetId: string;
|
|
93
|
+
name: string;
|
|
94
|
+
/** The item's type path. An item is of a type, or beneath it, when its path
|
|
95
|
+
* starts with that type's path. */
|
|
96
|
+
typePath: string;
|
|
97
|
+
}
|
|
98
|
+
export interface EvaluateManifestRulesInput<F> {
|
|
99
|
+
/** The manifest's `rules`, in order. */
|
|
100
|
+
rules: IManifestRule[];
|
|
101
|
+
/** The items found. */
|
|
102
|
+
items: RuleItem<F>[];
|
|
103
|
+
/** What READINESS rules read, or `null` to leave them unevaluated. */
|
|
104
|
+
env: RuleSubject<F> | null;
|
|
105
|
+
/** A type's path by its id. Undefined when the type no longer exists: a
|
|
106
|
+
* rule that names it then fails with that reason, rather than silently
|
|
107
|
+
* never applying. */
|
|
108
|
+
typePath: (typeId: string) => string | undefined;
|
|
109
|
+
engine: RuleEngine<F>;
|
|
110
|
+
/** For the engine: the moment of the evaluation, and the organisation's zone. */
|
|
111
|
+
now: Date;
|
|
112
|
+
timezone: string;
|
|
113
|
+
}
|
|
114
|
+
/** Plain code-unit order: what `<` gives two strings, on every runtime. */
|
|
115
|
+
export declare const compareCodeUnits: (a: string, b: string) => number;
|
|
116
|
+
declare type Context<F> = Pick<EvaluateManifestRulesInput<F>, 'engine' | 'now' | 'timezone' | 'typePath'>;
|
|
117
|
+
/**
|
|
118
|
+
* Does the subject pass the filter? A filter chooses; it does not judge. So
|
|
119
|
+
* a subject with no value in a name the filter reads is left out, before the
|
|
120
|
+
* expression runs, unless the filter tests that name's presence itself. A
|
|
121
|
+
* filter that cannot be read or evaluated leaves the subject out.
|
|
122
|
+
*/
|
|
123
|
+
export declare function passesFilter<F>(subject: RuleSubject<F>, where: string | undefined, ctx: Pick<Context<F>, 'engine' | 'now' | 'timezone'>): boolean;
|
|
124
|
+
export interface RuleJudgement {
|
|
125
|
+
/** The expression describes the problem: fired means there is one. */
|
|
126
|
+
fired: boolean;
|
|
127
|
+
reason?: string;
|
|
128
|
+
/** Names the expression reads that the subject has no value for. */
|
|
129
|
+
missingFields?: string[];
|
|
130
|
+
/** What the expression read, as stored. */
|
|
131
|
+
values: Record<string, ManifestRuleValue>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A message rendered over a subject, as a readiness rule's is: a missing
|
|
135
|
+
* number or date reads "(not set)", missing text reads as nothing.
|
|
136
|
+
*/
|
|
137
|
+
export declare function renderMessage<F>(subject: RuleSubject<F>, message: string, ctx: Pick<Context<F>, 'engine' | 'timezone'>): string;
|
|
138
|
+
/**
|
|
139
|
+
* Judge one subject with an expression that describes a problem, exactly as a
|
|
140
|
+
* readiness rule on a type is judged (`readiness/evaluate.ts`): it fires when
|
|
141
|
+
* the expression is true, when a number or a date it reads is missing and
|
|
142
|
+
* unguarded, and when it cannot be parsed or evaluated.
|
|
143
|
+
*/
|
|
144
|
+
export declare function judge<F>(subject: RuleSubject<F>, expression: string, message: string, ctx: Pick<Context<F>, 'engine' | 'now' | 'timezone'>): RuleJudgement;
|
|
145
|
+
/**
|
|
146
|
+
* Evaluate a manifest's rules: one result per rule, in the rules' order.
|
|
147
|
+
*
|
|
148
|
+
* RELATION rules run as one pass in array order, and a `to` item one rule
|
|
149
|
+
* takes stays taken for every later rule: a battery serves one tool. Among a
|
|
150
|
+
* group's candidates a rule takes first those the fewest later RELATION rules
|
|
151
|
+
* could take, then by name, then by id (§3.2), so a general rule leaves the
|
|
152
|
+
* particular items for a narrower rule after it. A SUITABILITY rule takes
|
|
153
|
+
* nothing, so its place in the array changes no result.
|
|
154
|
+
*/
|
|
155
|
+
export declare function evaluateManifestRules<F>(input: EvaluateManifestRulesInput<F>): IManifestRuleResult[];
|
|
156
|
+
/** How many rules failed: a check's `computed.rulesFailed`. */
|
|
157
|
+
export declare const rulesFailed: (results?: IManifestRuleResult[]) => number;
|
|
158
|
+
/** The level-2 rules that failed, by name: what a check's verdict counts. */
|
|
159
|
+
export declare const failedLevel2: (results?: IManifestRuleResult[]) => string[];
|
|
160
|
+
/** A readiness issue a failed rule raises, before it is given to an asset. */
|
|
161
|
+
export interface ManifestRuleIssue {
|
|
162
|
+
ruleName: string;
|
|
163
|
+
kind: ManifestRuleKind;
|
|
164
|
+
level: ManifestRuleLevel;
|
|
165
|
+
reason: string;
|
|
166
|
+
missingFields?: string[];
|
|
167
|
+
/** The item the issue names, where it names one. */
|
|
168
|
+
itemId?: string;
|
|
169
|
+
itemName?: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The issues failed rules raise (§5.2):
|
|
173
|
+
* - one per short group of a RELATION rule, its message rendered against the
|
|
174
|
+
* group's first unmatched item, and one per `from` item with no value in a
|
|
175
|
+
* `match` field;
|
|
176
|
+
* - one per unsuitable item, naming it;
|
|
177
|
+
* - one per triggered READINESS rule;
|
|
178
|
+
* - one for a rule that could not be applied at all.
|
|
179
|
+
*/
|
|
180
|
+
export declare function ruleIssues(results?: IManifestRuleResult[]): ManifestRuleIssue[];
|
|
181
|
+
/**
|
|
182
|
+
* The field names a rule reads from the ITEMS found: its `match` fields, the
|
|
183
|
+
* names in its filters, and a SUITABILITY rule's expression. A change to one
|
|
184
|
+
* of these on a member, or on a member's type, is what makes a kit's rules
|
|
185
|
+
* worth evaluating again. A READINESS rule reads the check, not the items,
|
|
186
|
+
* and gives none.
|
|
187
|
+
*/
|
|
188
|
+
export declare function ruleItemReads<F>(rule: IManifestRule, engine: Pick<RuleEngine<F>, 'ReferencedFields'>): string[];
|
|
189
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ruleItemReads = exports.ruleIssues = exports.failedLevel2 = exports.rulesFailed = exports.evaluateManifestRules = exports.judge = exports.renderMessage = exports.passesFilter = exports.compareCodeUnits = void 0;
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Order and equality
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
/** Plain code-unit order: what `<` gives two strings, on every runtime. */
|
|
8
|
+
const compareCodeUnits = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
9
|
+
exports.compareCodeUnits = compareCodeUnits;
|
|
10
|
+
const byName = (a, b) => (0, exports.compareCodeUnits)(a.name, b.name) || (0, exports.compareCodeUnits)(a.assetId, b.assetId);
|
|
11
|
+
const isBlank = (value) => value === undefined ||
|
|
12
|
+
value === '' ||
|
|
13
|
+
(Array.isArray(value) && value.length === 0);
|
|
14
|
+
/** A stored value as a key: equal keys are the same value of the same kind. */
|
|
15
|
+
const valueKey = (value) => JSON.stringify([typeof value, value]);
|
|
16
|
+
const whole = (n) => typeof n === 'number' && Number.isInteger(n) && n >= 1 ? n : 1;
|
|
17
|
+
const uniq = (names) => Array.from(new Set(names));
|
|
18
|
+
/**
|
|
19
|
+
* Does the subject pass the filter? A filter chooses; it does not judge. So
|
|
20
|
+
* a subject with no value in a name the filter reads is left out, before the
|
|
21
|
+
* expression runs, unless the filter tests that name's presence itself. A
|
|
22
|
+
* filter that cannot be read or evaluated leaves the subject out.
|
|
23
|
+
*/
|
|
24
|
+
function passesFilter(subject, where, ctx) {
|
|
25
|
+
if (!where || !where.trim())
|
|
26
|
+
return true;
|
|
27
|
+
const { engine } = ctx;
|
|
28
|
+
let names;
|
|
29
|
+
let guarded;
|
|
30
|
+
try {
|
|
31
|
+
names = engine.ReferencedFields(where);
|
|
32
|
+
guarded = new Set(engine.PresenceGuardedFields(where));
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const fields = [];
|
|
38
|
+
for (const name of names) {
|
|
39
|
+
const held = subject.field(name);
|
|
40
|
+
if (held.fields.length) {
|
|
41
|
+
fields.push(...held.fields);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// An empty selection is an empty set to the engine, not a missing value.
|
|
45
|
+
if (held.checkboxes) {
|
|
46
|
+
fields.push(emptySet(name, engine));
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
// A blank the filter does not test for: the subject is not in scope.
|
|
50
|
+
if (!guarded.has(name))
|
|
51
|
+
return false;
|
|
52
|
+
// One it does test for is the author's to judge, so ISSET() and
|
|
53
|
+
// ISBLANK() must see it. Blank text is given to the engine as blank
|
|
54
|
+
// text, as a rule's expression is given it (`judge`): the engine works
|
|
55
|
+
// out both sides of `||` and `&&`, so `ISBLANK(Brand) || Brand ==
|
|
56
|
+
// 'Makita'` over a name left absent throws on its second half and the
|
|
57
|
+
// blank item the author asked for is left out. A blank number, date or
|
|
58
|
+
// yes/no stays absent: there is no value of theirs that reads as blank.
|
|
59
|
+
if (held.dataType === 'STRING') {
|
|
60
|
+
const blank = blankField(name, held.dataType, engine);
|
|
61
|
+
if (blank)
|
|
62
|
+
fields.push(blank);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
return engine.EvaluateCondition(fields, where, ctx.now, ctx.timezone);
|
|
67
|
+
}
|
|
68
|
+
catch (_b) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.passesFilter = passesFilter;
|
|
73
|
+
/** Is the item on a rule's side: of its type or beneath it, and through its filter? */
|
|
74
|
+
function onSide(item, side, ctx) {
|
|
75
|
+
if (!side)
|
|
76
|
+
return false;
|
|
77
|
+
const path = ctx.typePath(side.typeId);
|
|
78
|
+
if (!path || !item.typePath.startsWith(path))
|
|
79
|
+
return false;
|
|
80
|
+
return passesFilter(item, side.where, ctx);
|
|
81
|
+
}
|
|
82
|
+
/** The engine fields a message's placeholders need from a subject. */
|
|
83
|
+
function messageFields(subject, names, ctx) {
|
|
84
|
+
const fields = [];
|
|
85
|
+
for (const name of names) {
|
|
86
|
+
const held = subject.field(name);
|
|
87
|
+
if (held.fields.length)
|
|
88
|
+
fields.push(...held.fields);
|
|
89
|
+
else if (held.checkboxes)
|
|
90
|
+
fields.push(emptySet(name, ctx.engine));
|
|
91
|
+
else {
|
|
92
|
+
const blank = blankField(name, held.dataType, ctx.engine);
|
|
93
|
+
if (blank)
|
|
94
|
+
fields.push(blank);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return fields;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* An empty multi-select, in the engine's form: one blank entry, which the
|
|
101
|
+
* engine drops when it builds the set. So the name still resolves, to an
|
|
102
|
+
* empty set, where no entry at all would be an unknown name. It is the
|
|
103
|
+
* convention the readiness evaluation's own converter follows
|
|
104
|
+
* (`toCheckboxEngineFields`).
|
|
105
|
+
*/
|
|
106
|
+
function emptySet(name, engine) {
|
|
107
|
+
return engine.newFieldValue({
|
|
108
|
+
Name: name,
|
|
109
|
+
Type: engine.FieldType.Checkboxes,
|
|
110
|
+
StringValue: '',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/** What a missing text or yes/no value reads as. Nothing for the rest. */
|
|
114
|
+
function blankField(name, dataType, engine) {
|
|
115
|
+
if (dataType === 'STRING')
|
|
116
|
+
return engine.newFieldValue({
|
|
117
|
+
Name: name,
|
|
118
|
+
Type: engine.FieldType.String,
|
|
119
|
+
StringValue: '',
|
|
120
|
+
});
|
|
121
|
+
if (dataType === 'BOOLEAN')
|
|
122
|
+
return engine.newFieldValue({
|
|
123
|
+
Name: name,
|
|
124
|
+
Type: engine.FieldType.Bool,
|
|
125
|
+
BoolValue: false,
|
|
126
|
+
});
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A message rendered over a subject, as a readiness rule's is: a missing
|
|
131
|
+
* number or date reads "(not set)", missing text reads as nothing.
|
|
132
|
+
*/
|
|
133
|
+
function renderMessage(subject, message, ctx) {
|
|
134
|
+
try {
|
|
135
|
+
const names = ctx.engine.TemplateFields(message);
|
|
136
|
+
return ctx.engine.FormatMessage(message, messageFields(subject, names, ctx), ctx.timezone).rendered;
|
|
137
|
+
}
|
|
138
|
+
catch (_a) {
|
|
139
|
+
return String(message !== null && message !== void 0 ? message : '');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.renderMessage = renderMessage;
|
|
143
|
+
/**
|
|
144
|
+
* Judge one subject with an expression that describes a problem, exactly as a
|
|
145
|
+
* readiness rule on a type is judged (`readiness/evaluate.ts`): it fires when
|
|
146
|
+
* the expression is true, when a number or a date it reads is missing and
|
|
147
|
+
* unguarded, and when it cannot be parsed or evaluated.
|
|
148
|
+
*/
|
|
149
|
+
function judge(subject, expression, message, ctx) {
|
|
150
|
+
const { engine } = ctx;
|
|
151
|
+
let exprFields;
|
|
152
|
+
let msgFields;
|
|
153
|
+
try {
|
|
154
|
+
exprFields = engine.ReferencedFields(expression);
|
|
155
|
+
msgFields = engine.TemplateFields(message);
|
|
156
|
+
}
|
|
157
|
+
catch (_a) {
|
|
158
|
+
return { fired: true, reason: 'Rule could not be parsed', values: {} };
|
|
159
|
+
}
|
|
160
|
+
const values = {};
|
|
161
|
+
for (const name of exprFields) {
|
|
162
|
+
const stored = subject.field(name).stored;
|
|
163
|
+
values[name] = stored === undefined ? null : stored;
|
|
164
|
+
}
|
|
165
|
+
const fields = [];
|
|
166
|
+
const missing = [];
|
|
167
|
+
for (const name of uniq([...exprFields, ...msgFields])) {
|
|
168
|
+
const held = subject.field(name);
|
|
169
|
+
if (held.fields.length) {
|
|
170
|
+
fields.push(...held.fields);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (held.checkboxes) {
|
|
174
|
+
fields.push(emptySet(name, engine));
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const blank = blankField(name, held.dataType, engine);
|
|
178
|
+
if (blank)
|
|
179
|
+
fields.push(blank);
|
|
180
|
+
// A number, a date or an unknown name the expression reads: it cannot be
|
|
181
|
+
// judged without the data. A name only the message reads is "(not set)".
|
|
182
|
+
else if (exprFields.includes(name))
|
|
183
|
+
missing.push(name);
|
|
184
|
+
}
|
|
185
|
+
if (missing.length) {
|
|
186
|
+
// ISSET()/ISBLANK() is the author's opt-out of failing closed.
|
|
187
|
+
let guarded;
|
|
188
|
+
try {
|
|
189
|
+
guarded = new Set(engine.PresenceGuardedFields(expression));
|
|
190
|
+
}
|
|
191
|
+
catch (_b) {
|
|
192
|
+
guarded = new Set();
|
|
193
|
+
}
|
|
194
|
+
const unguarded = missing
|
|
195
|
+
.filter((name) => !guarded.has(name))
|
|
196
|
+
.sort(exports.compareCodeUnits);
|
|
197
|
+
if (unguarded.length) {
|
|
198
|
+
return {
|
|
199
|
+
fired: true,
|
|
200
|
+
reason: `Missing data: ${unguarded.join(', ')}`,
|
|
201
|
+
missingFields: unguarded,
|
|
202
|
+
values,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let fired;
|
|
207
|
+
try {
|
|
208
|
+
fired = engine.EvaluateCondition(fields, expression, ctx.now, ctx.timezone);
|
|
209
|
+
}
|
|
210
|
+
catch (_c) {
|
|
211
|
+
return { fired: true, reason: 'Rule could not be evaluated', values };
|
|
212
|
+
}
|
|
213
|
+
if (!fired)
|
|
214
|
+
return { fired: false, values };
|
|
215
|
+
// Rendered over the very fields it was evaluated over, as a readiness
|
|
216
|
+
// rule's message is.
|
|
217
|
+
return {
|
|
218
|
+
fired: true,
|
|
219
|
+
reason: engine.FormatMessage(message, fields, ctx.timezone).rendered,
|
|
220
|
+
values,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
exports.judge = judge;
|
|
224
|
+
const failed = (base, level, reason) => (Object.assign(Object.assign({}, base), { triggered: true, passed: false, level,
|
|
225
|
+
reason }));
|
|
226
|
+
/**
|
|
227
|
+
* Evaluate a manifest's rules: one result per rule, in the rules' order.
|
|
228
|
+
*
|
|
229
|
+
* RELATION rules run as one pass in array order, and a `to` item one rule
|
|
230
|
+
* takes stays taken for every later rule: a battery serves one tool. Among a
|
|
231
|
+
* group's candidates a rule takes first those the fewest later RELATION rules
|
|
232
|
+
* could take, then by name, then by id (§3.2), so a general rule leaves the
|
|
233
|
+
* particular items for a narrower rule after it. A SUITABILITY rule takes
|
|
234
|
+
* nothing, so its place in the array changes no result.
|
|
235
|
+
*/
|
|
236
|
+
function evaluateManifestRules(input) {
|
|
237
|
+
const { rules, env } = input;
|
|
238
|
+
const ctx = input;
|
|
239
|
+
const items = input.items.slice().sort(byName);
|
|
240
|
+
const relations = rules
|
|
241
|
+
.map((rule, index) => ({ rule, index }))
|
|
242
|
+
.filter((entry) => entry.rule.kind === 'RELATION');
|
|
243
|
+
// How many LATER RELATION rules could take the item: of the rule's `to`
|
|
244
|
+
// type or beneath it, and through its `to` filter. Worked out once per
|
|
245
|
+
// item and rule, since a filter runs the engine.
|
|
246
|
+
const admits = new Map();
|
|
247
|
+
const laterTakers = (index, item) => relations.filter((later) => {
|
|
248
|
+
if (later.index <= index)
|
|
249
|
+
return false;
|
|
250
|
+
const key = `${later.index}|${item.assetId}`;
|
|
251
|
+
let admitted = admits.get(key);
|
|
252
|
+
if (admitted === undefined) {
|
|
253
|
+
admitted = onSide(item, later.rule.to, ctx);
|
|
254
|
+
admits.set(key, admitted);
|
|
255
|
+
}
|
|
256
|
+
return admitted;
|
|
257
|
+
}).length;
|
|
258
|
+
const taken = new Set();
|
|
259
|
+
return rules.map((rule, index) => {
|
|
260
|
+
var _a;
|
|
261
|
+
const base = Object.assign({ name: rule.name, kind: rule.kind }, (rule.section ? { section: rule.section } : {}));
|
|
262
|
+
const level = (_a = rule.level) !== null && _a !== void 0 ? _a : 2;
|
|
263
|
+
// The rules of a check come from the copy a device embedded. One that is
|
|
264
|
+
// not shaped as a rule fails, with a reason, and stops no other.
|
|
265
|
+
try {
|
|
266
|
+
switch (rule.kind) {
|
|
267
|
+
case 'READINESS':
|
|
268
|
+
return evaluateReadiness(rule, base, env, ctx);
|
|
269
|
+
case 'SUITABILITY':
|
|
270
|
+
return evaluateSuitability(rule, base, items, ctx);
|
|
271
|
+
case 'RELATION':
|
|
272
|
+
return evaluateRelation(rule, base, items, taken, ctx, (item) => laterTakers(index, item));
|
|
273
|
+
default:
|
|
274
|
+
return failed(base, level, `${base.name}: unknown kind of rule`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch (_b) {
|
|
278
|
+
return failed(base, level, `${base.name}: the rule could not be evaluated`);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
exports.evaluateManifestRules = evaluateManifestRules;
|
|
283
|
+
/** A READINESS rule: a readiness rule over the check instead of an asset. */
|
|
284
|
+
function evaluateReadiness(rule, base, env, ctx) {
|
|
285
|
+
if (!env)
|
|
286
|
+
return Object.assign(Object.assign({}, base), { evaluated: false });
|
|
287
|
+
const judgement = judge(env, rule.expression, rule.message, ctx);
|
|
288
|
+
if (!judgement.fired)
|
|
289
|
+
return Object.assign(Object.assign({}, base), { triggered: false, passed: true });
|
|
290
|
+
return Object.assign(Object.assign(Object.assign({}, base), { triggered: true, passed: false, level: rule.level, reason: judgement.reason }), (judgement.missingFields
|
|
291
|
+
? { missingFields: judgement.missingFields }
|
|
292
|
+
: {}));
|
|
293
|
+
}
|
|
294
|
+
/** A SUITABILITY rule: each item on its side, judged for this manifest. */
|
|
295
|
+
function evaluateSuitability(rule, base, items, ctx) {
|
|
296
|
+
var _a;
|
|
297
|
+
if (!rule.items || !ctx.typePath(rule.items.typeId))
|
|
298
|
+
return failed(base, rule.level, `${rule.name}: its type no longer exists`);
|
|
299
|
+
const judged = items.filter((item) => onSide(item, rule.items, ctx));
|
|
300
|
+
if (!judged.length)
|
|
301
|
+
return Object.assign(Object.assign({}, base), { triggered: false, passed: true });
|
|
302
|
+
const unsuitable = [];
|
|
303
|
+
for (const item of judged) {
|
|
304
|
+
const judgement = judge(item, rule.expression, rule.message, ctx);
|
|
305
|
+
if (!judgement.fired)
|
|
306
|
+
continue;
|
|
307
|
+
unsuitable.push(Object.assign({ assetId: item.assetId, assetName: item.name, values: judgement.values, reason: (_a = judgement.reason) !== null && _a !== void 0 ? _a : rule.message }, (judgement.missingFields
|
|
308
|
+
? { missingFields: judgement.missingFields }
|
|
309
|
+
: {})));
|
|
310
|
+
}
|
|
311
|
+
const passed = unsuitable.length === 0;
|
|
312
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base), { triggered: true, passed }), (passed ? {} : { level: rule.level })), { judged: judged.map((item) => item.assetId) }), (passed ? {} : { unsuitable }));
|
|
313
|
+
}
|
|
314
|
+
/** A RELATION rule: what each `from` item needs alongside it. */
|
|
315
|
+
function evaluateRelation(rule, base, items, taken, ctx, laterTakers) {
|
|
316
|
+
var _a;
|
|
317
|
+
for (const side of ['from', 'to']) {
|
|
318
|
+
if (!rule[side] || !ctx.typePath(rule[side].typeId))
|
|
319
|
+
return failed(base, rule.level, `${rule.name}: its ${side} type no longer exists`);
|
|
320
|
+
}
|
|
321
|
+
const from = items.filter((item) => onSide(item, rule.from, ctx));
|
|
322
|
+
if (!from.length)
|
|
323
|
+
return Object.assign(Object.assign({}, base), { triggered: false, passed: true });
|
|
324
|
+
const match = (_a = rule.match) !== null && _a !== void 0 ? _a : [];
|
|
325
|
+
const every = whole(rule.from.every);
|
|
326
|
+
const needs = whole(rule.to.needs);
|
|
327
|
+
const unmatched = [];
|
|
328
|
+
// Group the `from` items by their `match` values. One with no value in a
|
|
329
|
+
// `match` field cannot be matched at all.
|
|
330
|
+
const groups = new Map();
|
|
331
|
+
for (const item of from) {
|
|
332
|
+
const stored = match.map((name) => item.field(name).stored);
|
|
333
|
+
const blanks = match.filter((_, i) => isBlank(stored[i]));
|
|
334
|
+
if (blanks.length) {
|
|
335
|
+
unmatched.push({
|
|
336
|
+
assetId: item.assetId,
|
|
337
|
+
assetName: item.name,
|
|
338
|
+
reason: `no ${blanks.join(' or ')} recorded`,
|
|
339
|
+
blank: true,
|
|
340
|
+
});
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
const id = JSON.stringify(stored.map(valueKey));
|
|
344
|
+
let group = groups.get(id);
|
|
345
|
+
if (!group) {
|
|
346
|
+
const key = {};
|
|
347
|
+
match.forEach((name, i) => {
|
|
348
|
+
key[name] = stored[i];
|
|
349
|
+
});
|
|
350
|
+
group = { key, items: [] };
|
|
351
|
+
groups.set(id, group);
|
|
352
|
+
}
|
|
353
|
+
group.items.push(item);
|
|
354
|
+
}
|
|
355
|
+
// The `to` side is the same for every group: worked out once. Run per
|
|
356
|
+
// group, its filter was parsed and evaluated for every item of the kit
|
|
357
|
+
// once per group, which is quadratic where `match` is on a value most
|
|
358
|
+
// items hold alone (a serial, a slot).
|
|
359
|
+
const toSide = items.filter((item) => onSide(item, rule.to, ctx));
|
|
360
|
+
const results = Array.from(groups.entries())
|
|
361
|
+
.sort((a, b) => (0, exports.compareCodeUnits)(a[0], b[0]))
|
|
362
|
+
.map(([, group], groupIndex) => {
|
|
363
|
+
const needed = Math.ceil(group.items.length / every) * needs;
|
|
364
|
+
const candidates = toSide
|
|
365
|
+
.filter((item) => !taken.has(item.assetId) &&
|
|
366
|
+
match.every((name) => {
|
|
367
|
+
const stored = item.field(name).stored;
|
|
368
|
+
return (!isBlank(stored) &&
|
|
369
|
+
valueKey(stored) === valueKey(group.key[name]));
|
|
370
|
+
}))
|
|
371
|
+
.map((item) => ({ item, later: laterTakers(item) }))
|
|
372
|
+
.sort((a, b) => a.later - b.later || byName(a.item, b.item))
|
|
373
|
+
.map((candidate) => candidate.item);
|
|
374
|
+
const took = candidates.slice(0, needed);
|
|
375
|
+
for (const item of took)
|
|
376
|
+
taken.add(item.assetId);
|
|
377
|
+
// A short group still takes what it finds. The `from` items it leaves
|
|
378
|
+
// uncovered, last in name order, are the unmatched ones.
|
|
379
|
+
const covered = Math.min(group.items.length, Math.floor(took.length / needs) * every);
|
|
380
|
+
for (const item of group.items.slice(covered)) {
|
|
381
|
+
unmatched.push({
|
|
382
|
+
assetId: item.assetId,
|
|
383
|
+
assetName: item.name,
|
|
384
|
+
reason: renderMessage(item, rule.message, ctx),
|
|
385
|
+
group: groupIndex,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
return Object.assign({ key: group.key, from: group.items.map((item) => item.assetId), needed, taken: took.map((item) => item.assetId) }, (took.length < needed ? { short: true } : {}));
|
|
389
|
+
});
|
|
390
|
+
const passed = unmatched.length === 0;
|
|
391
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base), { triggered: true, passed }), (passed ? {} : { level: rule.level })), { groups: results }), (passed ? {} : { unmatched }));
|
|
392
|
+
}
|
|
393
|
+
// ---------------------------------------------------------------------------
|
|
394
|
+
// What the results come to
|
|
395
|
+
// ---------------------------------------------------------------------------
|
|
396
|
+
/** How many rules failed: a check's `computed.rulesFailed`. */
|
|
397
|
+
const rulesFailed = (results = []) => results.filter((result) => result.passed === false).length;
|
|
398
|
+
exports.rulesFailed = rulesFailed;
|
|
399
|
+
/** The level-2 rules that failed, by name: what a check's verdict counts. */
|
|
400
|
+
const failedLevel2 = (results = []) => results
|
|
401
|
+
.filter((result) => result.passed === false && result.level === 2)
|
|
402
|
+
.map((result) => result.name);
|
|
403
|
+
exports.failedLevel2 = failedLevel2;
|
|
404
|
+
/**
|
|
405
|
+
* The issues failed rules raise (§5.2):
|
|
406
|
+
* - one per short group of a RELATION rule, its message rendered against the
|
|
407
|
+
* group's first unmatched item, and one per `from` item with no value in a
|
|
408
|
+
* `match` field;
|
|
409
|
+
* - one per unsuitable item, naming it;
|
|
410
|
+
* - one per triggered READINESS rule;
|
|
411
|
+
* - one for a rule that could not be applied at all.
|
|
412
|
+
*/
|
|
413
|
+
function ruleIssues(results = []) {
|
|
414
|
+
var _a, _b, _c, _d;
|
|
415
|
+
const issues = [];
|
|
416
|
+
for (const result of results) {
|
|
417
|
+
if (result.passed !== false)
|
|
418
|
+
continue;
|
|
419
|
+
const level = (_a = result.level) !== null && _a !== void 0 ? _a : 2;
|
|
420
|
+
const issue = (reason, extra = {}) => (Object.assign({ ruleName: result.name, kind: result.kind, level,
|
|
421
|
+
reason }, extra));
|
|
422
|
+
if (result.reason !== undefined) {
|
|
423
|
+
issues.push(issue(result.reason, result.missingFields ? { missingFields: result.missingFields } : {}));
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
for (const item of (_b = result.unsuitable) !== null && _b !== void 0 ? _b : []) {
|
|
427
|
+
issues.push(issue(`${item.assetName}: ${item.reason}`, Object.assign({ itemId: item.assetId, itemName: item.assetName }, (item.missingFields ? { missingFields: item.missingFields } : {}))));
|
|
428
|
+
}
|
|
429
|
+
for (const item of ((_c = result.unmatched) !== null && _c !== void 0 ? _c : []).filter((u) => u.blank)) {
|
|
430
|
+
issues.push(issue(`${item.assetName}: ${item.reason}`, {
|
|
431
|
+
itemId: item.assetId,
|
|
432
|
+
itemName: item.assetName,
|
|
433
|
+
}));
|
|
434
|
+
}
|
|
435
|
+
;
|
|
436
|
+
((_d = result.groups) !== null && _d !== void 0 ? _d : []).forEach((group, index) => {
|
|
437
|
+
var _a;
|
|
438
|
+
if (!group.short)
|
|
439
|
+
return;
|
|
440
|
+
const first = ((_a = result.unmatched) !== null && _a !== void 0 ? _a : []).find((u) => u.group === index);
|
|
441
|
+
if (first)
|
|
442
|
+
issues.push(issue(first.reason, {
|
|
443
|
+
itemId: first.assetId,
|
|
444
|
+
itemName: first.assetName,
|
|
445
|
+
}));
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
return issues;
|
|
449
|
+
}
|
|
450
|
+
exports.ruleIssues = ruleIssues;
|
|
451
|
+
/**
|
|
452
|
+
* The field names a rule reads from the ITEMS found: its `match` fields, the
|
|
453
|
+
* names in its filters, and a SUITABILITY rule's expression. A change to one
|
|
454
|
+
* of these on a member, or on a member's type, is what makes a kit's rules
|
|
455
|
+
* worth evaluating again. A READINESS rule reads the check, not the items,
|
|
456
|
+
* and gives none.
|
|
457
|
+
*/
|
|
458
|
+
function ruleItemReads(rule, engine) {
|
|
459
|
+
var _a, _b, _c, _d;
|
|
460
|
+
const names = new Set();
|
|
461
|
+
const read = (expression) => {
|
|
462
|
+
if (!expression)
|
|
463
|
+
return;
|
|
464
|
+
try {
|
|
465
|
+
for (const name of engine.ReferencedFields(expression))
|
|
466
|
+
names.add(name);
|
|
467
|
+
}
|
|
468
|
+
catch (_a) {
|
|
469
|
+
// Unreadable: reported where the rule is saved.
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
if (rule.kind === 'RELATION') {
|
|
473
|
+
for (const name of (_a = rule.match) !== null && _a !== void 0 ? _a : [])
|
|
474
|
+
names.add(name);
|
|
475
|
+
read((_b = rule.from) === null || _b === void 0 ? void 0 : _b.where);
|
|
476
|
+
read((_c = rule.to) === null || _c === void 0 ? void 0 : _c.where);
|
|
477
|
+
}
|
|
478
|
+
else if (rule.kind === 'SUITABILITY') {
|
|
479
|
+
read((_d = rule.items) === null || _d === void 0 ? void 0 : _d.where);
|
|
480
|
+
read(rule.expression);
|
|
481
|
+
}
|
|
482
|
+
return Array.from(names).sort(exports.compareCodeUnits);
|
|
483
|
+
}
|
|
484
|
+
exports.ruleItemReads = ruleItemReads;
|
|
485
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA0IA,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,2EAA2E;AACpE,MAAM,gBAAgB,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAC/D,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AADf,QAAA,gBAAgB,oBACD;AAE5B,MAAM,MAAM,GAAG,CAAI,CAAc,EAAE,CAAc,EAAU,EAAE,CAC3D,IAAA,wBAAgB,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,IAAA,wBAAgB,EAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;AAE5E,MAAM,OAAO,GAAG,CAAC,KAAkC,EAAW,EAAE,CAC9D,KAAK,KAAK,SAAS;IACnB,KAAK,KAAK,EAAE;IACZ,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;AAE9C,+EAA+E;AAC/E,MAAM,QAAQ,GAAG,CAAC,KAAkC,EAAU,EAAE,CAC9D,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;AAEvC,MAAM,KAAK,GAAG,CAAC,CAAqB,EAAU,EAAE,CAC9C,OAAO,CAAC,KAAK,QAAQ,IA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AAE,KAAK,CAAC,CAAA;KACrB;SAAM,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE;QACtC,IAAI,CAAC,MAAA,IAAI,CAAC,KAAK,0CAAE,KAAK,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;KACtB;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,wBAAgB,CAAC,CAAA;AACjD,CAAC;AAtBD,sCAsBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spotto/manifest-rules",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.70-alpha.42",
|
|
4
|
+
"description": "The one evaluator of a manifest's rules (RELATION, READINESS, SUITABILITY), shared by the snapshot write, the kit recompute and the client's check screen, so a rule reaches the same result everywhere. No database and no expression engine of its own: the caller hands both the items and the engine in.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "shx rm -rf dist && tsc --project tsconfig.json",
|
|
12
|
+
"clean": "shx rm -rf node_modules dist",
|
|
13
|
+
"test": "jest -w 1"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@spotto/contract": "^1.0.70-alpha.42"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@spotto/excelexp": "^1.0.70-alpha.41",
|
|
23
|
+
"@types/jest": "^28.1.1",
|
|
24
|
+
"jest": "^28.0.2",
|
|
25
|
+
"shx": "^0.3.4",
|
|
26
|
+
"ts-jest": "^28.0.1"
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "ee16b0b496f6e6d0c4e6f7744ce8fad60096f047"
|
|
29
|
+
}
|
package/README.md
DELETED