@orpc/shared 0.0.0-next.7b09958 → 0.0.0-next.7d3bd71
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.js +3 -63
- package/dist/src/function.d.ts +0 -1
- package/dist/src/index.d.ts +2 -5
- package/dist/src/interceptor.d.ts +0 -2
- package/dist/src/object.d.ts +1 -2
- package/dist/src/value.d.ts +1 -1
- package/package.json +1 -1
- package/dist/src/constants.d.ts +0 -3
- package/dist/src/json.d.ts +0 -2
- package/dist/src/proxy.d.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// src/constants.ts
|
|
2
|
-
var ORPC_HANDLER_HEADER = "x-orpc-handler";
|
|
3
|
-
var ORPC_HANDLER_VALUE = "orpc";
|
|
4
|
-
|
|
5
1
|
// src/object.ts
|
|
6
2
|
function set(root, segments, value2) {
|
|
7
3
|
const ref = { root };
|
|
@@ -50,7 +46,7 @@ function isObject(value2) {
|
|
|
50
46
|
return false;
|
|
51
47
|
}
|
|
52
48
|
const proto = Object.getPrototypeOf(value2);
|
|
53
|
-
return proto === Object.prototype || proto
|
|
49
|
+
return proto === Object.prototype || !proto || !proto.constructor;
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
// src/error.ts
|
|
@@ -72,19 +68,6 @@ function toError(error) {
|
|
|
72
68
|
return new Error("Unknown error", { cause: error });
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
// src/function.ts
|
|
76
|
-
function once(fn) {
|
|
77
|
-
let cached;
|
|
78
|
-
return () => {
|
|
79
|
-
if (cached) {
|
|
80
|
-
return cached.result;
|
|
81
|
-
}
|
|
82
|
-
const result = fn();
|
|
83
|
-
cached = { result };
|
|
84
|
-
return result;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
71
|
// src/interceptor.ts
|
|
89
72
|
function onStart(callback) {
|
|
90
73
|
return async (options, ...rest) => {
|
|
@@ -139,45 +122,6 @@ async function intercept(interceptors, options, main) {
|
|
|
139
122
|
return await next(options);
|
|
140
123
|
}
|
|
141
124
|
|
|
142
|
-
// src/json.ts
|
|
143
|
-
function parseJSONSafely(text) {
|
|
144
|
-
if (text === "")
|
|
145
|
-
return void 0;
|
|
146
|
-
try {
|
|
147
|
-
return JSON.parse(text);
|
|
148
|
-
} catch {
|
|
149
|
-
return text;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// src/proxy.ts
|
|
154
|
-
function createCallableObject(obj, handler) {
|
|
155
|
-
const proxy = new Proxy(handler, {
|
|
156
|
-
has(target, key) {
|
|
157
|
-
return Reflect.has(obj, key) || Reflect.has(target, key);
|
|
158
|
-
},
|
|
159
|
-
ownKeys(target) {
|
|
160
|
-
return Array.from(new Set(Reflect.ownKeys(obj).concat(...Reflect.ownKeys(target))));
|
|
161
|
-
},
|
|
162
|
-
get(target, key) {
|
|
163
|
-
if (!Reflect.has(target, key) || Reflect.has(obj, key)) {
|
|
164
|
-
return Reflect.get(obj, key);
|
|
165
|
-
}
|
|
166
|
-
return Reflect.get(target, key);
|
|
167
|
-
},
|
|
168
|
-
defineProperty(_, key, descriptor) {
|
|
169
|
-
return Reflect.defineProperty(obj, key, descriptor);
|
|
170
|
-
},
|
|
171
|
-
set(_, key, value2) {
|
|
172
|
-
return Reflect.set(obj, key, value2);
|
|
173
|
-
},
|
|
174
|
-
deleteProperty(target, key) {
|
|
175
|
-
return Reflect.deleteProperty(target, key) && Reflect.deleteProperty(obj, key);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
return proxy;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
125
|
// src/value.ts
|
|
182
126
|
function value(value2, ...args) {
|
|
183
127
|
if (typeof value2 === "function") {
|
|
@@ -187,11 +131,8 @@ function value(value2, ...args) {
|
|
|
187
131
|
}
|
|
188
132
|
|
|
189
133
|
// src/index.ts
|
|
190
|
-
import { group, guard, mapEntries, mapValues, omit, trim } from "radash";
|
|
134
|
+
import { group, guard, mapEntries, mapValues, omit, retry, trim } from "radash";
|
|
191
135
|
export {
|
|
192
|
-
ORPC_HANDLER_HEADER,
|
|
193
|
-
ORPC_HANDLER_VALUE,
|
|
194
|
-
createCallableObject,
|
|
195
136
|
findDeepMatches,
|
|
196
137
|
get,
|
|
197
138
|
group,
|
|
@@ -205,8 +146,7 @@ export {
|
|
|
205
146
|
onFinish,
|
|
206
147
|
onStart,
|
|
207
148
|
onSuccess,
|
|
208
|
-
|
|
209
|
-
parseJSONSafely,
|
|
149
|
+
retry,
|
|
210
150
|
set,
|
|
211
151
|
toError,
|
|
212
152
|
trim,
|
package/dist/src/function.d.ts
CHANGED
package/dist/src/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export * from './chain';
|
|
2
|
-
export * from './constants';
|
|
3
2
|
export * from './error';
|
|
4
3
|
export * from './function';
|
|
5
4
|
export * from './interceptor';
|
|
6
|
-
export * from './json';
|
|
7
5
|
export * from './object';
|
|
8
|
-
export * from './proxy';
|
|
9
6
|
export * from './types';
|
|
10
7
|
export * from './value';
|
|
11
|
-
export { group, guard, mapEntries, mapValues, omit, trim } from 'radash';
|
|
12
|
-
export type { IsEqual, IsNever,
|
|
8
|
+
export { group, guard, mapEntries, mapValues, omit, retry, trim } from 'radash';
|
|
9
|
+
export type { IsEqual, IsNever, PartialDeep, Promisable } from 'type-fest';
|
|
13
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
|
-
import type { AnyFunction } from './function';
|
|
3
2
|
export type InterceptableOptions = Record<string, any>;
|
|
4
3
|
export type InterceptorOptions<TOptions extends InterceptableOptions, TResult> = Omit<TOptions, 'next'> & {
|
|
5
4
|
next(options?: TOptions): Promise<TResult>;
|
|
@@ -21,7 +20,6 @@ export declare function onStart<TOptions extends {
|
|
|
21
20
|
export declare function onSuccess<TOptions extends {
|
|
22
21
|
next(): any;
|
|
23
22
|
}, TRest extends any[]>(callback: NoInfer<(result: Awaited<ReturnType<TOptions['next']>>, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
24
|
-
export type InferError<T extends AnyFunction> = T extends Interceptor<any, any, infer TError> ? TError : unknown;
|
|
25
23
|
/**
|
|
26
24
|
* Can used for interceptors or middlewares
|
|
27
25
|
*/
|
package/dist/src/object.d.ts
CHANGED
|
@@ -6,8 +6,7 @@ export declare function findDeepMatches(check: (value: unknown) => boolean, payl
|
|
|
6
6
|
values: unknown[];
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
|
-
* Check if the value is an object.
|
|
10
|
-
* Even object created by Object.create(null) is considered an object.
|
|
9
|
+
* Check if the value is an object even it created by `Object.create(null)` or more tricky way.
|
|
11
10
|
*/
|
|
12
11
|
export declare function isObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
13
12
|
//# sourceMappingURL=object.d.ts.map
|
package/dist/src/value.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
2
|
export type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => Promisable<T>);
|
|
3
|
-
export declare function value<T
|
|
3
|
+
export declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): Promise<T extends Value<infer U, any> ? U : never>;
|
|
4
4
|
//# sourceMappingURL=value.d.ts.map
|
package/package.json
CHANGED
package/dist/src/constants.d.ts
DELETED
package/dist/src/json.d.ts
DELETED
package/dist/src/proxy.d.ts
DELETED