@orpc/shared 1.0.0-beta.2 → 1.0.0-beta.4

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 CHANGED
@@ -72,6 +72,14 @@ You can find the full documentation [here](https://orpc.unnoq.com).
72
72
 
73
73
  Provides shared utilities for oRPC packages.
74
74
 
75
+ ## Sponsors
76
+
77
+ <p align="center">
78
+ <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
79
+ <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
80
+ </a>
81
+ </p>
82
+
75
83
  ## License
76
84
 
77
85
  Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { Promisable } from 'type-fest';
2
2
  export { IsEqual, IsNever, PartialDeep, Promisable } from 'type-fest';
3
- export { group, guard, mapEntries, mapValues, omit, trim } from 'radash';
3
+ export { group, guard, mapEntries, mapValues, omit } from 'radash';
4
+
5
+ type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
6
+ declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
7
+
8
+ declare function toArray<T>(value: T | T[] | null | undefined): T[];
4
9
 
5
10
  type AnyFunction = (...args: any[]) => any;
6
11
  declare function once<T extends () => any>(fn: T): () => ReturnType<T>;
@@ -75,10 +80,10 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
75
80
  declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
76
81
  declare function clone<T>(value: T): T;
77
82
 
78
- type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
79
83
  type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
84
+ type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
80
85
 
81
86
  type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => Promisable<T>);
82
87
  declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): Promise<T extends Value<infer U, any> ? U : never>;
83
88
 
84
- export { type AnyFunction, type InterceptableOptions, type Interceptor, type InterceptorOptions, type MaybeOptionalOptions, type OmitChainMethodDeep, type OnFinishState, type Segment, type SetOptional, type Value, clone, findDeepMatches, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, stringifyJSON, toError, value };
89
+ export { type AnyFunction, type InterceptableOptions, type Interceptor, type InterceptorOptions, type IntersectPick, type MaybeOptionalOptions, type OmitChainMethodDeep, type OnFinishState, type Segment, type SetOptional, type Value, clone, findDeepMatches, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, stringifyJSON, toArray, toError, value };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { Promisable } from 'type-fest';
2
2
  export { IsEqual, IsNever, PartialDeep, Promisable } from 'type-fest';
3
- export { group, guard, mapEntries, mapValues, omit, trim } from 'radash';
3
+ export { group, guard, mapEntries, mapValues, omit } from 'radash';
4
+
5
+ type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
6
+ declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
7
+
8
+ declare function toArray<T>(value: T | T[] | null | undefined): T[];
4
9
 
5
10
  type AnyFunction = (...args: any[]) => any;
6
11
  declare function once<T extends () => any>(fn: T): () => ReturnType<T>;
@@ -75,10 +80,10 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
75
80
  declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
76
81
  declare function clone<T>(value: T): T;
77
82
 
78
- type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
79
83
  type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
84
+ type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
80
85
 
81
86
  type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => Promisable<T>);
82
87
  declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): Promise<T extends Value<infer U, any> ? U : never>;
83
88
 
84
- export { type AnyFunction, type InterceptableOptions, type Interceptor, type InterceptorOptions, type MaybeOptionalOptions, type OmitChainMethodDeep, type OnFinishState, type Segment, type SetOptional, type Value, clone, findDeepMatches, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, stringifyJSON, toError, value };
89
+ export { type AnyFunction, type InterceptableOptions, type Interceptor, type InterceptorOptions, type IntersectPick, type MaybeOptionalOptions, type OmitChainMethodDeep, type OnFinishState, type Segment, type SetOptional, type Value, clone, findDeepMatches, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, stringifyJSON, toArray, toError, value };
package/dist/index.mjs CHANGED
@@ -1,4 +1,12 @@
1
- export { group, guard, mapEntries, mapValues, omit, trim } from 'radash';
1
+ export { group, guard, mapEntries, mapValues, omit } from 'radash';
2
+
3
+ function resolveMaybeOptionalOptions(rest) {
4
+ return rest[0] ?? {};
5
+ }
6
+
7
+ function toArray(value) {
8
+ return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
9
+ }
2
10
 
3
11
  function toError(error) {
4
12
  if (error instanceof Error) {
@@ -135,4 +143,4 @@ function value(value2, ...args) {
135
143
  return value2;
136
144
  }
137
145
 
138
- export { clone, findDeepMatches, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, stringifyJSON, toError, value };
146
+ export { clone, findDeepMatches, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, stringifyJSON, toArray, toError, value };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/shared",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0-beta.4",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {