@orpc/shared 0.0.0-next.2ebf00e → 0.0.0-next.2f7ecd8

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
@@ -65,11 +65,21 @@ You can find the full documentation [here](https://orpc.unnoq.com).
65
65
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
66
66
  - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
67
67
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
68
+ - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
69
+ - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
68
70
 
69
71
  ## `@orpc/shared`
70
72
 
71
73
  Provides shared utilities for oRPC packages.
72
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
+
73
83
  ## License
74
84
 
75
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, retry, 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>;
@@ -74,11 +79,12 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
74
79
  */
75
80
  declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
76
81
  declare function clone<T>(value: T): T;
82
+ declare function get(object: object, path: readonly string[]): unknown;
77
83
 
78
- type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
79
84
  type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
85
+ type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
80
86
 
81
87
  type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => Promisable<T>);
82
88
  declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): Promise<T extends Value<infer U, any> ? U : never>;
83
89
 
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 };
90
+ 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, get, 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, retry, 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>;
@@ -74,11 +79,12 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
74
79
  */
75
80
  declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
76
81
  declare function clone<T>(value: T): T;
82
+ declare function get(object: object, path: readonly string[]): unknown;
77
83
 
78
- type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
79
84
  type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
85
+ type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
80
86
 
81
87
  type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => Promisable<T>);
82
88
  declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): Promise<T extends Value<infer U, any> ? U : never>;
83
89
 
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 };
90
+ 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, get, 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, retry, 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) {
@@ -127,6 +135,16 @@ function clone(value) {
127
135
  }
128
136
  return value;
129
137
  }
138
+ function get(object, path) {
139
+ let current = object;
140
+ for (const key of path) {
141
+ if (!isTypescriptObject(current)) {
142
+ return void 0;
143
+ }
144
+ current = current[key];
145
+ }
146
+ return current;
147
+ }
130
148
 
131
149
  function value(value2, ...args) {
132
150
  if (typeof value2 === "function") {
@@ -135,4 +153,4 @@ function value(value2, ...args) {
135
153
  return value2;
136
154
  }
137
155
 
138
- export { clone, findDeepMatches, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, stringifyJSON, toError, value };
156
+ export { clone, findDeepMatches, get, 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": "0.0.0-next.2ebf00e",
4
+ "version": "0.0.0-next.2f7ecd8",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {