@orpc/shared 0.0.0-next.dd4e882 → 0.0.0-next.dda04c5
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 +5 -7
- package/dist/index.d.mts +35 -15
- package/dist/index.d.ts +35 -15
- package/dist/index.mjs +63 -57
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
36
36
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
37
37
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
38
|
-
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
38
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
|
|
39
39
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
40
40
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
41
41
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -54,14 +54,12 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
54
54
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
55
55
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
56
56
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
57
|
-
- [@orpc/
|
|
57
|
+
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
58
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
58
59
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
59
|
-
- [@orpc/
|
|
60
|
-
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
|
61
|
-
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
62
|
-
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
|
60
|
+
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
63
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
64
|
-
- [@orpc/
|
|
62
|
+
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
65
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
66
64
|
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
67
65
|
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Promisable } from 'type-fest';
|
|
2
|
-
export { IsEqual, IsNever, PartialDeep, Promisable } from 'type-fest';
|
|
2
|
+
export { IsEqual, IsNever, JsonValue, PartialDeep, Promisable } from 'type-fest';
|
|
3
3
|
export { group, guard, mapEntries, mapValues, omit } from 'radash';
|
|
4
4
|
|
|
5
5
|
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
@@ -80,8 +80,8 @@ declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
declare class SequentialIdGenerator {
|
|
83
|
-
private
|
|
84
|
-
generate():
|
|
83
|
+
private index;
|
|
84
|
+
generate(): string;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
@@ -135,14 +135,34 @@ declare function onFinish<T, TOptions extends {
|
|
|
135
135
|
declare function intercept<TOptions extends InterceptableOptions, TResult>(interceptors: Interceptor<TOptions, TResult>[], options: NoInfer<TOptions>, main: NoInfer<(options: TOptions) => TResult>): TResult;
|
|
136
136
|
|
|
137
137
|
declare function isAsyncIteratorObject(maybe: unknown): maybe is AsyncIteratorObject<any, any, any>;
|
|
138
|
-
interface
|
|
138
|
+
interface AsyncIteratorClassNextFn<T, TReturn> {
|
|
139
|
+
(): Promise<IteratorResult<T, TReturn>>;
|
|
140
|
+
}
|
|
141
|
+
interface AsyncIteratorClassCleanupFn {
|
|
139
142
|
(reason: 'return' | 'throw' | 'next' | 'dispose'): Promise<void>;
|
|
140
143
|
}
|
|
141
|
-
declare
|
|
142
|
-
declare
|
|
144
|
+
declare const fallbackAsyncDisposeSymbol: unique symbol;
|
|
145
|
+
declare const asyncDisposeSymbol: typeof Symbol extends {
|
|
146
|
+
asyncDispose: infer T;
|
|
147
|
+
} ? T : typeof fallbackAsyncDisposeSymbol;
|
|
148
|
+
declare class AsyncIteratorClass<T, TReturn = unknown, TNext = unknown> implements AsyncIteratorObject<T, TReturn, TNext>, AsyncGenerator<T, TReturn, TNext> {
|
|
149
|
+
#private;
|
|
150
|
+
constructor(next: AsyncIteratorClassNextFn<T, TReturn>, cleanup: AsyncIteratorClassCleanupFn);
|
|
151
|
+
next(): Promise<IteratorResult<T, TReturn>>;
|
|
152
|
+
return(value?: any): Promise<IteratorResult<T, TReturn>>;
|
|
153
|
+
throw(err: any): Promise<IteratorResult<T, TReturn>>;
|
|
154
|
+
/**
|
|
155
|
+
* asyncDispose symbol only available in esnext, we should fallback to Symbol.for('asyncDispose')
|
|
156
|
+
*/
|
|
157
|
+
[asyncDisposeSymbol](): Promise<void>;
|
|
158
|
+
[Symbol.asyncIterator](): this;
|
|
159
|
+
}
|
|
160
|
+
declare function replicateAsyncIterator<T, TReturn, TNext>(source: AsyncIterator<T, TReturn, TNext>, count: number): (AsyncIteratorClass<T, TReturn, TNext>)[];
|
|
143
161
|
|
|
144
162
|
declare function parseEmptyableJSON(text: string | null | undefined): unknown;
|
|
145
|
-
declare function stringifyJSON<T>(value: T
|
|
163
|
+
declare function stringifyJSON<T>(value: T | {
|
|
164
|
+
toJSON(): T;
|
|
165
|
+
}): undefined extends T ? undefined | string : string;
|
|
146
166
|
|
|
147
167
|
type Segment = string | number;
|
|
148
168
|
declare function findDeepMatches(check: (value: unknown) => boolean, payload: unknown, segments?: Segment[], maps?: Segment[][], values?: unknown[]): {
|
|
@@ -165,7 +185,7 @@ declare const NullProtoObj: ({
|
|
|
165
185
|
});
|
|
166
186
|
|
|
167
187
|
interface AsyncIdQueueCloseOptions {
|
|
168
|
-
id?:
|
|
188
|
+
id?: string;
|
|
169
189
|
reason?: unknown;
|
|
170
190
|
}
|
|
171
191
|
declare class AsyncIdQueue<T> {
|
|
@@ -173,16 +193,16 @@ declare class AsyncIdQueue<T> {
|
|
|
173
193
|
private readonly items;
|
|
174
194
|
private readonly pendingPulls;
|
|
175
195
|
get length(): number;
|
|
176
|
-
open(id:
|
|
177
|
-
isOpen(id:
|
|
178
|
-
push(id:
|
|
179
|
-
pull(id:
|
|
196
|
+
open(id: string): void;
|
|
197
|
+
isOpen(id: string): boolean;
|
|
198
|
+
push(id: string, item: T): void;
|
|
199
|
+
pull(id: string): Promise<T>;
|
|
180
200
|
close({ id, reason }?: AsyncIdQueueCloseOptions): void;
|
|
181
|
-
assertOpen(id:
|
|
201
|
+
assertOpen(id: string): void;
|
|
182
202
|
}
|
|
183
203
|
|
|
184
204
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
185
205
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
186
206
|
|
|
187
|
-
export { AsyncIdQueue, EventPublisher, NullProtoObj, SequentialIdGenerator, clone,
|
|
188
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions,
|
|
207
|
+
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
208
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Promisable } from 'type-fest';
|
|
2
|
-
export { IsEqual, IsNever, PartialDeep, Promisable } from 'type-fest';
|
|
2
|
+
export { IsEqual, IsNever, JsonValue, PartialDeep, Promisable } from 'type-fest';
|
|
3
3
|
export { group, guard, mapEntries, mapValues, omit } from 'radash';
|
|
4
4
|
|
|
5
5
|
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
@@ -80,8 +80,8 @@ declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
declare class SequentialIdGenerator {
|
|
83
|
-
private
|
|
84
|
-
generate():
|
|
83
|
+
private index;
|
|
84
|
+
generate(): string;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
@@ -135,14 +135,34 @@ declare function onFinish<T, TOptions extends {
|
|
|
135
135
|
declare function intercept<TOptions extends InterceptableOptions, TResult>(interceptors: Interceptor<TOptions, TResult>[], options: NoInfer<TOptions>, main: NoInfer<(options: TOptions) => TResult>): TResult;
|
|
136
136
|
|
|
137
137
|
declare function isAsyncIteratorObject(maybe: unknown): maybe is AsyncIteratorObject<any, any, any>;
|
|
138
|
-
interface
|
|
138
|
+
interface AsyncIteratorClassNextFn<T, TReturn> {
|
|
139
|
+
(): Promise<IteratorResult<T, TReturn>>;
|
|
140
|
+
}
|
|
141
|
+
interface AsyncIteratorClassCleanupFn {
|
|
139
142
|
(reason: 'return' | 'throw' | 'next' | 'dispose'): Promise<void>;
|
|
140
143
|
}
|
|
141
|
-
declare
|
|
142
|
-
declare
|
|
144
|
+
declare const fallbackAsyncDisposeSymbol: unique symbol;
|
|
145
|
+
declare const asyncDisposeSymbol: typeof Symbol extends {
|
|
146
|
+
asyncDispose: infer T;
|
|
147
|
+
} ? T : typeof fallbackAsyncDisposeSymbol;
|
|
148
|
+
declare class AsyncIteratorClass<T, TReturn = unknown, TNext = unknown> implements AsyncIteratorObject<T, TReturn, TNext>, AsyncGenerator<T, TReturn, TNext> {
|
|
149
|
+
#private;
|
|
150
|
+
constructor(next: AsyncIteratorClassNextFn<T, TReturn>, cleanup: AsyncIteratorClassCleanupFn);
|
|
151
|
+
next(): Promise<IteratorResult<T, TReturn>>;
|
|
152
|
+
return(value?: any): Promise<IteratorResult<T, TReturn>>;
|
|
153
|
+
throw(err: any): Promise<IteratorResult<T, TReturn>>;
|
|
154
|
+
/**
|
|
155
|
+
* asyncDispose symbol only available in esnext, we should fallback to Symbol.for('asyncDispose')
|
|
156
|
+
*/
|
|
157
|
+
[asyncDisposeSymbol](): Promise<void>;
|
|
158
|
+
[Symbol.asyncIterator](): this;
|
|
159
|
+
}
|
|
160
|
+
declare function replicateAsyncIterator<T, TReturn, TNext>(source: AsyncIterator<T, TReturn, TNext>, count: number): (AsyncIteratorClass<T, TReturn, TNext>)[];
|
|
143
161
|
|
|
144
162
|
declare function parseEmptyableJSON(text: string | null | undefined): unknown;
|
|
145
|
-
declare function stringifyJSON<T>(value: T
|
|
163
|
+
declare function stringifyJSON<T>(value: T | {
|
|
164
|
+
toJSON(): T;
|
|
165
|
+
}): undefined extends T ? undefined | string : string;
|
|
146
166
|
|
|
147
167
|
type Segment = string | number;
|
|
148
168
|
declare function findDeepMatches(check: (value: unknown) => boolean, payload: unknown, segments?: Segment[], maps?: Segment[][], values?: unknown[]): {
|
|
@@ -165,7 +185,7 @@ declare const NullProtoObj: ({
|
|
|
165
185
|
});
|
|
166
186
|
|
|
167
187
|
interface AsyncIdQueueCloseOptions {
|
|
168
|
-
id?:
|
|
188
|
+
id?: string;
|
|
169
189
|
reason?: unknown;
|
|
170
190
|
}
|
|
171
191
|
declare class AsyncIdQueue<T> {
|
|
@@ -173,16 +193,16 @@ declare class AsyncIdQueue<T> {
|
|
|
173
193
|
private readonly items;
|
|
174
194
|
private readonly pendingPulls;
|
|
175
195
|
get length(): number;
|
|
176
|
-
open(id:
|
|
177
|
-
isOpen(id:
|
|
178
|
-
push(id:
|
|
179
|
-
pull(id:
|
|
196
|
+
open(id: string): void;
|
|
197
|
+
isOpen(id: string): boolean;
|
|
198
|
+
push(id: string, item: T): void;
|
|
199
|
+
pull(id: string): Promise<T>;
|
|
180
200
|
close({ id, reason }?: AsyncIdQueueCloseOptions): void;
|
|
181
|
-
assertOpen(id:
|
|
201
|
+
assertOpen(id: string): void;
|
|
182
202
|
}
|
|
183
203
|
|
|
184
204
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
185
205
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
186
206
|
|
|
187
|
-
export { AsyncIdQueue, EventPublisher, NullProtoObj, SequentialIdGenerator, clone,
|
|
188
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions,
|
|
207
|
+
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
208
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
package/dist/index.mjs
CHANGED
|
@@ -122,61 +122,68 @@ function isAsyncIteratorObject(maybe) {
|
|
|
122
122
|
}
|
|
123
123
|
return Symbol.asyncIterator in maybe && typeof maybe[Symbol.asyncIterator] === "function";
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
const fallbackAsyncDisposeSymbol = Symbol.for("asyncDispose");
|
|
126
|
+
const asyncDisposeSymbol = Symbol.asyncDispose ?? fallbackAsyncDisposeSymbol;
|
|
127
|
+
class AsyncIteratorClass {
|
|
128
|
+
#isDone = false;
|
|
129
|
+
#isExecuteComplete = false;
|
|
130
|
+
#cleanup;
|
|
131
|
+
#next;
|
|
132
|
+
constructor(next, cleanup) {
|
|
133
|
+
this.#cleanup = cleanup;
|
|
134
|
+
this.#next = sequential(async () => {
|
|
135
|
+
if (this.#isDone) {
|
|
131
136
|
return { done: true, value: void 0 };
|
|
132
137
|
}
|
|
133
138
|
try {
|
|
134
139
|
const result = await next();
|
|
135
140
|
if (result.done) {
|
|
136
|
-
isDone = true;
|
|
141
|
+
this.#isDone = true;
|
|
137
142
|
}
|
|
138
143
|
return result;
|
|
139
144
|
} catch (err) {
|
|
140
|
-
isDone = true;
|
|
145
|
+
this.#isDone = true;
|
|
141
146
|
throw err;
|
|
142
147
|
} finally {
|
|
143
|
-
if (isDone && !isExecuteComplete) {
|
|
144
|
-
isExecuteComplete = true;
|
|
145
|
-
await cleanup("next");
|
|
148
|
+
if (this.#isDone && !this.#isExecuteComplete) {
|
|
149
|
+
this.#isExecuteComplete = true;
|
|
150
|
+
await this.#cleanup("next");
|
|
146
151
|
}
|
|
147
152
|
}
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
isDone = true;
|
|
159
|
-
if (!isExecuteComplete) {
|
|
160
|
-
isExecuteComplete = true;
|
|
161
|
-
await cleanup("throw");
|
|
162
|
-
}
|
|
163
|
-
throw err;
|
|
164
|
-
},
|
|
165
|
-
/**
|
|
166
|
-
* asyncDispose symbol only available in esnext, we should fallback to Symbol.for('asyncDispose')
|
|
167
|
-
*/
|
|
168
|
-
async [Symbol.asyncDispose ?? Symbol.for("asyncDispose")]() {
|
|
169
|
-
isDone = true;
|
|
170
|
-
if (!isExecuteComplete) {
|
|
171
|
-
isExecuteComplete = true;
|
|
172
|
-
await cleanup("dispose");
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
[Symbol.asyncIterator]() {
|
|
176
|
-
return iterator;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
next() {
|
|
156
|
+
return this.#next();
|
|
157
|
+
}
|
|
158
|
+
async return(value) {
|
|
159
|
+
this.#isDone = true;
|
|
160
|
+
if (!this.#isExecuteComplete) {
|
|
161
|
+
this.#isExecuteComplete = true;
|
|
162
|
+
await this.#cleanup("return");
|
|
177
163
|
}
|
|
178
|
-
|
|
179
|
-
|
|
164
|
+
return { done: true, value };
|
|
165
|
+
}
|
|
166
|
+
async throw(err) {
|
|
167
|
+
this.#isDone = true;
|
|
168
|
+
if (!this.#isExecuteComplete) {
|
|
169
|
+
this.#isExecuteComplete = true;
|
|
170
|
+
await this.#cleanup("throw");
|
|
171
|
+
}
|
|
172
|
+
throw err;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* asyncDispose symbol only available in esnext, we should fallback to Symbol.for('asyncDispose')
|
|
176
|
+
*/
|
|
177
|
+
async [asyncDisposeSymbol]() {
|
|
178
|
+
this.#isDone = true;
|
|
179
|
+
if (!this.#isExecuteComplete) {
|
|
180
|
+
this.#isExecuteComplete = true;
|
|
181
|
+
await this.#cleanup("dispose");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
[Symbol.asyncIterator]() {
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
180
187
|
}
|
|
181
188
|
function replicateAsyncIterator(source, count) {
|
|
182
189
|
const queue = new AsyncIdQueue();
|
|
@@ -187,8 +194,8 @@ function replicateAsyncIterator(source, count) {
|
|
|
187
194
|
while (true) {
|
|
188
195
|
const item = await source.next();
|
|
189
196
|
for (let id = 0; id < count; id++) {
|
|
190
|
-
if (queue.isOpen(id)) {
|
|
191
|
-
queue.push(id, item);
|
|
197
|
+
if (queue.isOpen(id.toString())) {
|
|
198
|
+
queue.push(id.toString(), item);
|
|
192
199
|
}
|
|
193
200
|
}
|
|
194
201
|
if (item.done) {
|
|
@@ -200,12 +207,12 @@ function replicateAsyncIterator(source, count) {
|
|
|
200
207
|
}
|
|
201
208
|
});
|
|
202
209
|
for (let id = 0; id < count; id++) {
|
|
203
|
-
queue.open(id);
|
|
204
|
-
replicated.push(
|
|
210
|
+
queue.open(id.toString());
|
|
211
|
+
replicated.push(new AsyncIteratorClass(
|
|
205
212
|
() => {
|
|
206
213
|
start();
|
|
207
214
|
return new Promise((resolve, reject) => {
|
|
208
|
-
queue.pull(id).then(resolve).catch(reject);
|
|
215
|
+
queue.pull(id.toString()).then(resolve).catch(reject);
|
|
209
216
|
defer(() => {
|
|
210
217
|
if (error) {
|
|
211
218
|
reject(error.value);
|
|
@@ -214,9 +221,9 @@ function replicateAsyncIterator(source, count) {
|
|
|
214
221
|
});
|
|
215
222
|
},
|
|
216
223
|
async (reason) => {
|
|
217
|
-
queue.close({ id });
|
|
224
|
+
queue.close({ id: id.toString() });
|
|
218
225
|
if (reason !== "next") {
|
|
219
|
-
if (replicated.every((_, id2) => !queue.isOpen(id2))) {
|
|
226
|
+
if (replicated.every((_, id2) => !queue.isOpen(id2.toString()))) {
|
|
220
227
|
await source?.return?.();
|
|
221
228
|
}
|
|
222
229
|
}
|
|
@@ -263,6 +270,7 @@ class EventPublisher {
|
|
|
263
270
|
}
|
|
264
271
|
const signal = listenerOrOptions?.signal;
|
|
265
272
|
const maxBufferedEvents = listenerOrOptions?.maxBufferedEvents ?? this.#maxBufferedEvents;
|
|
273
|
+
signal?.throwIfAborted();
|
|
266
274
|
const bufferedEvents = [];
|
|
267
275
|
const pullResolvers = [];
|
|
268
276
|
const unsubscribe = this.subscribe(event, (payload) => {
|
|
@@ -283,7 +291,7 @@ class EventPublisher {
|
|
|
283
291
|
bufferedEvents.length = 0;
|
|
284
292
|
};
|
|
285
293
|
signal?.addEventListener("abort", abortListener, { once: true });
|
|
286
|
-
return
|
|
294
|
+
return new AsyncIteratorClass(async () => {
|
|
287
295
|
if (signal?.aborted) {
|
|
288
296
|
throw signal.reason;
|
|
289
297
|
}
|
|
@@ -304,13 +312,11 @@ class EventPublisher {
|
|
|
304
312
|
}
|
|
305
313
|
|
|
306
314
|
class SequentialIdGenerator {
|
|
307
|
-
|
|
315
|
+
index = BigInt(0);
|
|
308
316
|
generate() {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
return this.nextId++;
|
|
317
|
+
const id = this.index.toString(32);
|
|
318
|
+
this.index++;
|
|
319
|
+
return id;
|
|
314
320
|
}
|
|
315
321
|
}
|
|
316
322
|
|
|
@@ -443,4 +449,4 @@ function value(value2, ...args) {
|
|
|
443
449
|
return value2;
|
|
444
450
|
}
|
|
445
451
|
|
|
446
|
-
export { AsyncIdQueue, EventPublisher, NullProtoObj, SequentialIdGenerator, clone,
|
|
452
|
+
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, 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.
|
|
4
|
+
"version": "0.0.0-next.dda04c5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"radash": "^12.1.
|
|
27
|
+
"radash": "^12.1.1",
|
|
28
28
|
"type-fest": "^4.39.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"arktype": "2.1.20",
|
|
32
32
|
"valibot": "^1.1.0",
|
|
33
|
-
"zod": "^3.25.
|
|
33
|
+
"zod": "^3.25.67"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "unbuild",
|