@xlr-lib/xlr-sdk 0.1.1--canary.9.190

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.
@@ -0,0 +1,30 @@
1
+ import type { Node } from "jsonc-parser";
2
+ export interface BaseValidationMessage<ErrorType extends string = string> {
3
+ /** Validation Type */
4
+ type: ErrorType;
5
+ /** Error message text */
6
+ message: string;
7
+ /** JSONC node that the error originates from */
8
+ node: Node;
9
+ /** Level of the message */
10
+ severity: ValidationSeverity;
11
+ }
12
+ export interface TypeValidationError extends BaseValidationMessage<"type"> {
13
+ /** Expected types */
14
+ expected?: string[] | string | number | boolean;
15
+ }
16
+ export type MissingValidationError = BaseValidationMessage<"missing">;
17
+ export type UnknownValidationError = BaseValidationMessage<"unknown">;
18
+ export interface ValueValidationError extends BaseValidationMessage<"value"> {
19
+ /** Expected value */
20
+ expected?: string;
21
+ }
22
+ export type UnexpectedValidationError = BaseValidationMessage<"unexpected">;
23
+ export type ValidationMessage = TypeValidationError | MissingValidationError | UnknownValidationError | ValueValidationError | UnexpectedValidationError;
24
+ export declare enum ValidationSeverity {
25
+ Error = 1,
26
+ Warning = 2,
27
+ Info = 3,
28
+ Trace = 4
29
+ }
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { NodeTypeStrings, NodeTypeMap, TransformFunction, NodeType } from "@xlr-lib/xlr";
2
+ type TypedTransformFunction<T extends NodeTypeStrings = NodeTypeStrings> = (input: NodeTypeMap[T]) => NodeTypeMap[T];
3
+ export type TransformFunctionMap = {
4
+ [nodeType in NodeTypeStrings]?: Array<TypedTransformFunction<nodeType>>;
5
+ };
6
+ export declare function xlrTransformWalker(transformMap: TransformFunctionMap): (node: NodeType) => NodeType;
7
+ /**
8
+ * Helper function for simple transforms
9
+ * Walks an XLR tree looking for the specified node type calls the supplied function when called
10
+ */
11
+ export declare function simpleTransformGenerator<T extends NodeTypeStrings = NodeTypeStrings>(typeToTransform: T, capabilityToTransform: string | Array<string>, functionToRun: TypedTransformFunction<T>): TransformFunction;
12
+ export {};
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,27 @@
1
+ import type { Node } from "jsonc-parser";
2
+ import type { NamedType, NodeType, ObjectType, OrType, RefType } from "@xlr-lib/xlr";
3
+ import type { ValidationMessage } from "./types";
4
+ export interface XLRValidatorConfig {
5
+ /** URL mapping for supplemental documentation */
6
+ urlMapping?: Record<string, string>;
7
+ }
8
+ /**
9
+ * Validator for XLRs on JSON Nodes
10
+ */
11
+ export declare class XLRValidator {
12
+ private config;
13
+ private resolveType;
14
+ private regexCache;
15
+ constructor(resolveType: (id: string) => NamedType<NodeType> | undefined, config?: XLRValidatorConfig);
16
+ /** Main entrypoint for validation */
17
+ validateType(rootNode: Node, xlrNode: NodeType): Array<ValidationMessage>;
18
+ private generateNestedTypesInfo;
19
+ private validateTemplate;
20
+ private validateArray;
21
+ private validateObject;
22
+ private validateLiteralType;
23
+ getRefType(ref: RefType): NodeType;
24
+ private getRegex;
25
+ computeIntersectionType(types: Array<NodeType>): ObjectType | OrType;
26
+ }
27
+ //# sourceMappingURL=validator.d.ts.map