@xlr-lib/xlr-utils 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,58 @@
1
+ import type { NamedType, NamedTypeWithGenerics, NodeType, NodeTypeWithGenerics, PrimitiveTypes, StringType, NumberType, BooleanType, ObjectType, ArrayType, RefType, OrType, AndType, RecordType } from "@xlr-lib/xlr";
2
+ /**
3
+ * Returns if the NodeType has generic tokens
4
+ */
5
+ export declare function isGenericNodeType<T extends NodeType = NodeType>(nt: NodeType): nt is NodeTypeWithGenerics<T>;
6
+ /**
7
+ * Returns if the named type has generic tokens
8
+ */
9
+ export declare function isGenericNamedType<T extends NamedType = NamedType>(nt: NodeType): nt is NamedTypeWithGenerics<T>;
10
+ /**
11
+ * Returns if the node is a `PrimitiveTypes`
12
+ */
13
+ export declare function isPrimitiveTypeNode(node: NodeType): node is PrimitiveTypes;
14
+ /**
15
+ * Type Guard for non-null values
16
+ */
17
+ export declare function isNonNullable<T>(a: T | null | undefined): a is NonNullable<T>;
18
+ /**
19
+ * Type guard for string type nodes
20
+ */
21
+ export declare function isStringType(node: NodeType): node is StringType;
22
+ /**
23
+ * Type guard for number type nodes
24
+ */
25
+ export declare function isNumberType(node: NodeType): node is NumberType;
26
+ /**
27
+ * Type guard for boolean type nodes
28
+ */
29
+ export declare function isBooleanType(node: NodeType): node is BooleanType;
30
+ /**
31
+ * Type guard for object type nodes
32
+ */
33
+ export declare function isObjectType(node: NodeType): node is ObjectType;
34
+ /**
35
+ * Type guard for array type nodes
36
+ */
37
+ export declare function isArrayType(node: NodeType): node is ArrayType;
38
+ /**
39
+ * Type guard for ref type nodes
40
+ */
41
+ export declare function isRefType(node: NodeType): node is RefType;
42
+ /**
43
+ * Type guard for or (union) type nodes
44
+ */
45
+ export declare function isOrType(node: NodeType): node is OrType;
46
+ /**
47
+ * Type guard for and (intersection) type nodes
48
+ */
49
+ export declare function isAndType(node: NodeType): node is AndType;
50
+ /**
51
+ * Type guard for record type nodes
52
+ */
53
+ export declare function isRecordType(node: NodeType): node is RecordType;
54
+ /**
55
+ * Type guard for named types (have name and source)
56
+ */
57
+ export declare function isNamedType<T extends NodeType = NodeType>(node: NodeType): node is NamedType<T>;
58
+ //# sourceMappingURL=type-checks.d.ts.map
@@ -0,0 +1,41 @@
1
+ import type { Node } from "jsonc-parser";
2
+ import type { ConditionalType, NodeType, ObjectType, RefNode } from "@xlr-lib/xlr";
3
+ export interface PropertyNode {
4
+ /** Equivalent Property Name */
5
+ key: string;
6
+ /** Equivalent Property Value */
7
+ value: Node;
8
+ }
9
+ /**
10
+ * Takes a property node and returns the underlying Key/Value Pairs
11
+ */
12
+ export declare function propertyToTuple(node: Node): PropertyNode;
13
+ /**
14
+ * Turns a node's children into a map for easy access
15
+ */
16
+ export declare function makePropertyMap(node: Node): Map<string, Node>;
17
+ /**
18
+ * Checks if property is a leaf node or another node
19
+ */
20
+ export declare function isNode(obj: Node | string | number | boolean): obj is Node;
21
+ /**
22
+ * Computes if the first arg extends the second arg
23
+ */
24
+ export declare function computeExtends(a: NodeType, b: NodeType): boolean;
25
+ /**
26
+ * Attempts to resolve a conditional type
27
+ */
28
+ export declare function resolveConditional(conditional: ConditionalType): NodeType;
29
+ /**
30
+ * Resolve referenced node with potential generic arguments
31
+ */
32
+ export declare function resolveReferenceNode(genericReference: RefNode, typeToFill: NodeType): NodeType;
33
+ /**
34
+ * Combines two ObjectType objects to get a representation of the effective TypeScript interface of `base` extending `operand`
35
+ - * @param base The base interface
36
+ - * @param operand The interface that is extended
37
+ - * @param errorOnOverlap whether or not conflicting properties should throw an error or use the property from operand
38
+ - * @returns `ObjectType`
39
+ */
40
+ export declare function computeEffectiveObject(base: ObjectType, operand: ObjectType, errorOnOverlap?: boolean): ObjectType;
41
+ //# sourceMappingURL=validation-helpers.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { NodeType, OrType } from "@xlr-lib/xlr";
2
+ /**
3
+ * Walks generics to fill in values from a combination of the default, constraint, and passed in map values
4
+ * TODO convert this to use simpleTransformGenerator
5
+ */
6
+ export declare function fillInGenerics(xlrNode: NodeType, generics?: Map<string, NodeType>, preferLocalGenerics?: boolean): NodeType;
7
+ /** Applies the TS `Pick` or `Omit` type to an interface/union/intersection */
8
+ export declare function applyPickOrOmitToNodeType(baseObject: NodeType, operation: "Pick" | "Omit", properties: Set<string>): NodeType | undefined;
9
+ /** Applies the TS `Partial` or `Required` type to an interface/union/intersection */
10
+ export declare function applyPartialOrRequiredToNodeType(baseObject: NodeType, modifier: boolean): NodeType;
11
+ /** Applies the TS `Exclude` type to a union */
12
+ export declare function applyExcludeToNodeType(baseObject: OrType, filters: NodeType | OrType): NodeType;
13
+ //# sourceMappingURL=xlr-helpers.d.ts.map