uni-types 1.1.0 → 1.3.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/README.md +157 -1
- package/dist/index.d.cts +1868 -236
- package/dist/index.d.mts +1868 -236
- package/package.json +34 -3
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ A comprehensive collection of type helpers for TypeScript development
|
|
|
18
18
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
|
-
- 🎯 **
|
|
21
|
+
- 🎯 **250+ Type Utilities** - Comprehensive type helpers for every use case
|
|
22
22
|
- 🔒 **Type Safe** - Full TypeScript support with strict type checking
|
|
23
23
|
- 📦 **Zero Dependencies** - Lightweight and tree-shakeable
|
|
24
24
|
- 🚀 **TypeScript 5.x** - Built with the latest TypeScript features
|
|
@@ -212,6 +212,162 @@ type Result = If<true, 'success', 'error'> // 'success'
|
|
|
212
212
|
| `DeepNonNullable<T>` | Remove null/undefined from all properties |
|
|
213
213
|
| `Exact<T, Shape>` | Ensure exact shape match |
|
|
214
214
|
|
|
215
|
+
### Schema Validation *(v1.2.0)*
|
|
216
|
+
|
|
217
|
+
| Type | Description |
|
|
218
|
+
|------|-------------|
|
|
219
|
+
| `RuntimeGuard<T>` | Define type guard function for runtime checking |
|
|
220
|
+
| `GuardedType<G>` | Extract type from type guard function |
|
|
221
|
+
| `HasRuntimeCheck<T>` | Check if type has runtime check available |
|
|
222
|
+
| `ZodOutput<T>` | Extract output type from Zod schema |
|
|
223
|
+
| `ZodInput<T>` | Extract input type from Zod schema |
|
|
224
|
+
| `ZodShape<T>` | Extract shape from ZodObject schema |
|
|
225
|
+
| `ZodRequiredKeys<T>` | Get required keys from Zod schema |
|
|
226
|
+
| `ZodOptionalKeys<T>` | Get optional keys from Zod schema |
|
|
227
|
+
| `YupOutput<T>` | Extract output type from Yup schema |
|
|
228
|
+
| `YupInput<T>` | Extract input type from Yup schema |
|
|
229
|
+
|
|
230
|
+
### Ecosystem Integration *(v1.2.0)*
|
|
231
|
+
|
|
232
|
+
| Type | Description |
|
|
233
|
+
|------|-------------|
|
|
234
|
+
| `ComponentProps<T>` | Extract props from React component |
|
|
235
|
+
| `PropsWithChildren<P>` | Add children to props type |
|
|
236
|
+
| `RequiredProps<P>` | Get required prop keys |
|
|
237
|
+
| `OptionalProps<P>` | Get optional prop keys |
|
|
238
|
+
| `VuePropType<T>` | Vue prop type definition |
|
|
239
|
+
| `VueEmitType<T>` | Vue emit function type |
|
|
240
|
+
| `PrismaCreateInput<T>` | Create input type for Prisma models |
|
|
241
|
+
| `PrismaUpdateInput<T>` | Update input type for Prisma models |
|
|
242
|
+
| `PrismaWhereInput<T>` | Where input type for Prisma queries |
|
|
243
|
+
| `TRPCProcedureInput<T>` | Extract input from tRPC procedure |
|
|
244
|
+
| `TRPCProcedureOutput<T>` | Extract output from tRPC procedure |
|
|
245
|
+
|
|
246
|
+
### Performance Optimization *(v1.2.0)*
|
|
247
|
+
|
|
248
|
+
| Type | Description |
|
|
249
|
+
|------|-------------|
|
|
250
|
+
| `Simplify<T>` | Flatten intersection types |
|
|
251
|
+
| `DeepSimplify<T>` | Recursively simplify nested types |
|
|
252
|
+
| `Compact<T>` | Remove never and undefined properties |
|
|
253
|
+
| `StripNever<T>` | Remove never properties |
|
|
254
|
+
| `StripUndefined<T>` | Remove undefined properties |
|
|
255
|
+
| `MergeAll<T>` | Merge multiple object types |
|
|
256
|
+
| `Lazy<T>` | Defer type evaluation |
|
|
257
|
+
| `Cached<T>` | Cache type computation |
|
|
258
|
+
| `Memoized<T>` | Memoize type computation |
|
|
259
|
+
|
|
260
|
+
### Advanced Type Patterns *(v1.3.0)*
|
|
261
|
+
|
|
262
|
+
| Type | Description |
|
|
263
|
+
|------|-------------|
|
|
264
|
+
| `Match<T, Patterns>` | Type-level pattern matching |
|
|
265
|
+
| `Recurse<T, Limit>` | Type-level recursion with depth limit |
|
|
266
|
+
| `Depth<T>` | Get maximum depth of nested type |
|
|
267
|
+
| `TypeFilter<T, P>` | Filter tuple by predicate |
|
|
268
|
+
| `TypeFind<T, P>` | Find first matching element |
|
|
269
|
+
| `TypeIncludes<T, E>` | Check if tuple includes element |
|
|
270
|
+
| `TypeEvery<T, P>` | Check if all elements match |
|
|
271
|
+
| `TypeSome<T, P>` | Check if any element matches |
|
|
272
|
+
|
|
273
|
+
### Type-Level Collections *(v1.3.0)*
|
|
274
|
+
|
|
275
|
+
| Type | Description |
|
|
276
|
+
|------|-------------|
|
|
277
|
+
| `TypeSet<T>` | Type-level Set representation |
|
|
278
|
+
| `SetAdd<S, T>` | Add element to type set |
|
|
279
|
+
| `SetRemove<S, T>` | Remove element from type set |
|
|
280
|
+
| `SetUnion<A, B>` | Union of two type sets |
|
|
281
|
+
| `SetIntersection<A, B>` | Intersection of two type sets |
|
|
282
|
+
| `SetDifference<A, B>` | Difference of two type sets |
|
|
283
|
+
| `TypeMap<K, V>` | Type-level Map representation |
|
|
284
|
+
| `MapGet<M, K>` | Get value from type map |
|
|
285
|
+
| `MapSet<M, K, V>` | Set value in type map |
|
|
286
|
+
| `ListFilter<T, P>` | Filter list elements |
|
|
287
|
+
| `ListReverse<T>` | Reverse a list |
|
|
288
|
+
| `ListConcat<A, B>` | Concatenate two lists |
|
|
289
|
+
| `ListTake<T, N>` | Take first N elements |
|
|
290
|
+
| `ListChunk<T, N>` | Chunk list into sublists |
|
|
291
|
+
|
|
292
|
+
### Type Assertions & Constraints *(v1.3.0)*
|
|
293
|
+
|
|
294
|
+
| Type | Description |
|
|
295
|
+
|------|-------------|
|
|
296
|
+
| `AssertEqual<T, Expected>` | Assert types are equal |
|
|
297
|
+
| `AssertExtends<T, U>` | Assert T extends U |
|
|
298
|
+
| `RequireKeys<T, K>` | Require specific keys |
|
|
299
|
+
| `RequireAtLeastOne<T, K>` | Require at least one key |
|
|
300
|
+
| `RequireExactlyOne<T, K>` | Require exactly one key |
|
|
301
|
+
| `RequireAllOrNone<T, K>` | Require all or none keys |
|
|
302
|
+
| `HasProperty<T, K>` | Ensure object has property |
|
|
303
|
+
| `RequireArray<T>` | Ensure type is array |
|
|
304
|
+
| `RequireFunction<T>` | Ensure type is function |
|
|
305
|
+
|
|
306
|
+
### String Operations *(v1.3.0)*
|
|
307
|
+
|
|
308
|
+
| Type | Description |
|
|
309
|
+
|------|-------------|
|
|
310
|
+
| `Split<S, D>` | Split string by delimiter |
|
|
311
|
+
| `Join<T, S>` | Join string array with separator |
|
|
312
|
+
| `KebabCase<S>` | Convert to kebab-case |
|
|
313
|
+
| `PascalCase<S>` | Convert to PascalCase |
|
|
314
|
+
| `ConstantCase<S>` | Convert to CONSTANT_CASE |
|
|
315
|
+
| `IsEmail<S>` | Check if string is email |
|
|
316
|
+
| `IsUUID<S>` | Check if string is UUID |
|
|
317
|
+
| `IsURL<S>` | Check if string is URL |
|
|
318
|
+
| `ReverseString<S>` | Reverse a string |
|
|
319
|
+
|
|
320
|
+
### Promise & Async Utilities *(v1.3.0)*
|
|
321
|
+
|
|
322
|
+
| Type | Description |
|
|
323
|
+
|------|-------------|
|
|
324
|
+
| `PromiseValue<T>` | Extract value from Promise (deep) |
|
|
325
|
+
| `IsPromise<T>` | Check if type is Promise |
|
|
326
|
+
| `UnwrapPromise<T>` | Unwrap or return original |
|
|
327
|
+
| `AsyncReturnType<T>` | Return type of async function |
|
|
328
|
+
| `MakeAsync<T>` | Make function async |
|
|
329
|
+
| `PromiseAll<T>` | Await all promises |
|
|
330
|
+
| `AsyncResult<T, E>` | Rust-style Result type |
|
|
331
|
+
| `Deferred<T>` | Deferred promise type |
|
|
332
|
+
|
|
333
|
+
### Object Operations *(v1.3.0)*
|
|
334
|
+
|
|
335
|
+
| Type | Description |
|
|
336
|
+
|------|-------------|
|
|
337
|
+
| `ObjectMap<T, F>` | Map over object values |
|
|
338
|
+
| `ObjectFilter<T, P>` | Filter object properties |
|
|
339
|
+
| `ObjectPickByType<T, U>` | Pick by value type |
|
|
340
|
+
| `ObjectInvert<T>` | Invert object (swap keys/values) |
|
|
341
|
+
| `DeepMerge<A, B>` | Deep merge objects |
|
|
342
|
+
| `ObjectPath<T, P>` | Get value at path |
|
|
343
|
+
| `PathExists<T, P>` | Check if path exists |
|
|
344
|
+
| `KeysOfType<T, U>` | Get keys of specific type |
|
|
345
|
+
|
|
346
|
+
### JSON Schema *(v1.3.0)*
|
|
347
|
+
|
|
348
|
+
| Type | Description |
|
|
349
|
+
|------|-------------|
|
|
350
|
+
| `JsonSchemaType<T>` | Map TS types to JSON Schema types |
|
|
351
|
+
| `JsonSchema<T>` | Full JSON Schema type |
|
|
352
|
+
| `OpenAPISchema<T>` | OpenAPI 3.0 Schema |
|
|
353
|
+
| `OpenAPIResponse<T>` | OpenAPI Response |
|
|
354
|
+
| `OpenAPIRequestBody<T>` | OpenAPI Request Body |
|
|
355
|
+
| `OpenAPIParameter<Name, T, In>` | OpenAPI Parameter |
|
|
356
|
+
| `OpenAPIDocument<Title, Version, Paths>` | OpenAPI Document |
|
|
357
|
+
|
|
358
|
+
### Extended Ecosystem *(v1.3.0)*
|
|
359
|
+
|
|
360
|
+
| Type | Description |
|
|
361
|
+
|------|-------------|
|
|
362
|
+
| `NextPageProps<T>` | Next.js page props |
|
|
363
|
+
| `ServerComponentProps<T>` | Next.js server component props |
|
|
364
|
+
| `NuxtPageMeta<T>` | Nuxt page meta |
|
|
365
|
+
| `NuxtComposable<T>` | Nuxt composable type |
|
|
366
|
+
| `SolidSignal<T>` | SolidJS signal type |
|
|
367
|
+
| `SolidResource<T>` | SolidJS resource type |
|
|
368
|
+
| `SvelteStore<T>` | Svelte store type |
|
|
369
|
+
| `SvelteAction<Element, Params>` | Svelte action type |
|
|
370
|
+
|
|
215
371
|
## Examples
|
|
216
372
|
|
|
217
373
|
```typescript
|