@dlovans/tenet-core 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/engine.js +1 -1
- package/dist/core/lint.js +13 -0
- package/dist/core/types.d.ts +2 -1
- package/dist/core/validate.d.ts +1 -0
- package/dist/core/validate.js +1 -0
- package/package.json +1 -1
package/dist/core/engine.js
CHANGED
|
@@ -118,7 +118,7 @@ function applyAction(state, action, ruleId, lawRef) {
|
|
|
118
118
|
}
|
|
119
119
|
// Emit error if specified
|
|
120
120
|
if (action.error_msg) {
|
|
121
|
-
addError(state, '', ruleId, '
|
|
121
|
+
addError(state, '', ruleId, action.error_kind ?? 'constraint_violation', action.error_msg, lawRef);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
/**
|
package/dist/core/lint.js
CHANGED
|
@@ -507,6 +507,19 @@ function checkAction(ctx, action, rulePath, ruleId, fieldsSetBy) {
|
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
+
// Validate error_kind if present
|
|
511
|
+
if (action.error_kind !== undefined) {
|
|
512
|
+
const validKinds = new Set([
|
|
513
|
+
'type_mismatch', 'missing_required', 'constraint_violation',
|
|
514
|
+
'attestation_incomplete', 'runtime_warning', 'cycle_detected', 'notice',
|
|
515
|
+
]);
|
|
516
|
+
if (typeof action.error_kind !== 'string' || !validKinds.has(action.error_kind)) {
|
|
517
|
+
addIssue(ctx, 'error', 'invalid_error_kind', `Rule '${ruleId}' has invalid error_kind '${action.error_kind}'`, {
|
|
518
|
+
path: `${rulePath}.then.error_kind`,
|
|
519
|
+
rule_id: ruleId,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
510
523
|
if (action.ui_modify) {
|
|
511
524
|
for (const field of Object.keys(action.ui_modify)) {
|
|
512
525
|
// W18: ui_modify targets undefined field
|
package/dist/core/types.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ export interface Action {
|
|
|
86
86
|
set?: Record<string, unknown>;
|
|
87
87
|
ui_modify?: Record<string, unknown>;
|
|
88
88
|
error_msg?: string;
|
|
89
|
+
error_kind?: ErrorKind;
|
|
89
90
|
}
|
|
90
91
|
export interface TemporalBranch {
|
|
91
92
|
valid_range: [string | null, string | null];
|
|
@@ -99,7 +100,7 @@ export interface StateModel {
|
|
|
99
100
|
export interface DerivedDef {
|
|
100
101
|
eval: Record<string, unknown>;
|
|
101
102
|
}
|
|
102
|
-
export type ErrorKind = 'type_mismatch' | 'missing_required' | 'constraint_violation' | 'attestation_incomplete' | 'runtime_warning' | 'cycle_detected';
|
|
103
|
+
export type ErrorKind = 'type_mismatch' | 'missing_required' | 'constraint_violation' | 'attestation_incomplete' | 'runtime_warning' | 'cycle_detected' | 'notice';
|
|
103
104
|
export interface ValidationError {
|
|
104
105
|
field_id?: string;
|
|
105
106
|
rule_id?: string;
|
package/dist/core/validate.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export declare function validateDefinitions(state: EvalState): void;
|
|
|
17
17
|
export declare function checkAttestations(state: EvalState, applyAction: (action: Action, ruleId: string, lawRef: string) => void): void;
|
|
18
18
|
/**
|
|
19
19
|
* Determine document status based on ErrorKind.
|
|
20
|
+
* Non-blocking kinds (runtime_warning, cycle_detected, notice) do not affect status.
|
|
20
21
|
*/
|
|
21
22
|
export declare function determineStatus(state: EvalState): DocStatus;
|
package/dist/core/validate.js
CHANGED
|
@@ -180,6 +180,7 @@ export function checkAttestations(state, applyAction) {
|
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
182
|
* Determine document status based on ErrorKind.
|
|
183
|
+
* Non-blocking kinds (runtime_warning, cycle_detected, notice) do not affect status.
|
|
183
184
|
*/
|
|
184
185
|
export function determineStatus(state) {
|
|
185
186
|
for (const err of state.errors) {
|
package/package.json
CHANGED