@player-tools/xlr 0.1.0 → 0.2.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/index.d.ts CHANGED
@@ -83,10 +83,12 @@ interface ObjectProperty {
83
83
  node: NodeType;
84
84
  }
85
85
  interface ObjectNode extends TypeNode<'object'> {
86
- /** the properties associated with an object */
86
+ /** The properties associated with an object */
87
87
  properties: {
88
88
  [name: string]: ObjectProperty;
89
89
  };
90
+ /** A custom primitive that this object extends that is to be resolved when used */
91
+ extends?: RefType;
90
92
  /** What type, if any, of additional properties are allowed on the object */
91
93
  additionalProperties: false | NodeType;
92
94
  }
@@ -160,6 +162,12 @@ declare type FunctionType = TypeNode<'function'> & Annotations & {
160
162
  declare type PrimitiveTypes = NeverType | NullType | StringType | NumberType | BooleanType | AnyType | UnknownType | UndefinedType;
161
163
  /** Set of all Node Types */
162
164
  declare type NodeType = AnyType | UnknownType | UndefinedType | NullType | NeverType | StringType | TemplateLiteralType | NumberType | BooleanType | ObjectType | ArrayType | TupleType | RecordType | AndType | OrType | RefType | FunctionType | ConditionalType;
165
+ declare type NodeTypeStrings = Pick<NodeType, 'type'>['type'];
166
+ declare type NodeTypeMap = {
167
+ [K in NodeTypeStrings]: Extract<NodeType, {
168
+ type: K;
169
+ }>;
170
+ };
163
171
  declare type NamedType<T extends NodeType = NodeType> = T & {
164
172
  /** Name of the exported interface/type */
165
173
  name: string;
@@ -183,7 +191,7 @@ declare type NodeTypeWithGenerics<T extends NodeType = NodeType> = T & {
183
191
  genericTokens: Array<ParamTypeNode>;
184
192
  };
185
193
 
186
- declare type TransformFunction = (input: NamedType<NodeType>, capabilityType: string) => void;
194
+ declare type TransformFunction = (input: NamedType<NodeType> | NodeType, capabilityType: string) => void;
187
195
  interface Capability {
188
196
  /** Name of the capability that is provided to Player */
189
197
  name: string;
@@ -205,4 +213,4 @@ interface TSManifest {
205
213
  };
206
214
  }
207
215
 
208
- export { AndType, Annotations, AnyType, ArrayNode, ArrayType, BooleanType, Capability, CommonTypeInfo, ConditionalNode, ConditionalType, Const, Enum, FunctionType, FunctionTypeParameters, Manifest, NamedType, NamedTypeWithGenerics, NeverType, NodeType, NodeTypeWithGenerics, NullType, NumberType, ObjectNode, ObjectProperty, ObjectType, OrType, ParamTypeNode, PrimitiveTypes, RecordType, RefNode, RefType, StringType, TSManifest, TemplateLiteralType, TransformFunction, TupleNode, TupleType, TypeMap, TypeNode, UndefinedType, UnknownType };
216
+ export { AndType, Annotations, AnyType, ArrayNode, ArrayType, BooleanType, Capability, CommonTypeInfo, ConditionalNode, ConditionalType, Const, Enum, FunctionType, FunctionTypeParameters, Manifest, NamedType, NamedTypeWithGenerics, NeverType, NodeType, NodeTypeMap, NodeTypeStrings, NodeTypeWithGenerics, NullType, NumberType, ObjectNode, ObjectProperty, ObjectType, OrType, ParamTypeNode, PrimitiveTypes, RecordType, RefNode, RefType, StringType, TSManifest, TemplateLiteralType, TransformFunction, TupleNode, TupleType, TypeMap, TypeNode, UndefinedType, UnknownType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@player-tools/xlr",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
package/src/core.ts CHANGED
@@ -100,10 +100,12 @@ export interface ObjectProperty {
100
100
  node: NodeType;
101
101
  }
102
102
  export interface ObjectNode extends TypeNode<'object'> {
103
- /** the properties associated with an object */
103
+ /** The properties associated with an object */
104
104
  properties: {
105
105
  [name: string]: ObjectProperty;
106
106
  };
107
+ /** A custom primitive that this object extends that is to be resolved when used */
108
+ extends?: RefType;
107
109
  /** What type, if any, of additional properties are allowed on the object */
108
110
  additionalProperties: false | NodeType;
109
111
  }
@@ -224,6 +226,13 @@ export type NodeType =
224
226
  | FunctionType
225
227
  | ConditionalType;
226
228
 
229
+ export type NodeTypeStrings = Pick<NodeType, 'type'>['type'];
230
+
231
+ export type NodeTypeMap = {
232
+ // eslint-disable-next-line jsdoc/require-jsdoc, prettier/prettier
233
+ [K in NodeTypeStrings]: Extract<NodeType,{type: K}>;
234
+ };
235
+
227
236
  export type NamedType<T extends NodeType = NodeType> = T & {
228
237
  /** Name of the exported interface/type */
229
238
  name: string;
package/src/utility.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { NamedType, NodeType } from '.';
2
2
 
3
3
  export type TransformFunction = (
4
- input: NamedType<NodeType>,
4
+ input: NamedType<NodeType> | NodeType,
5
5
  capabilityType: string
6
6
  ) => void;
7
7