@orpc/shared 0.0.0-next.e6490f2 → 0.0.0-next.e710b76

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
@@ -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.
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 nextId;
84
- generate(): number;
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>>;
@@ -160,7 +160,9 @@ declare class AsyncIteratorClass<T, TReturn = unknown, TNext = unknown> implemen
160
160
  declare function replicateAsyncIterator<T, TReturn, TNext>(source: AsyncIterator<T, TReturn, TNext>, count: number): (AsyncIteratorClass<T, TReturn, TNext>)[];
161
161
 
162
162
  declare function parseEmptyableJSON(text: string | null | undefined): unknown;
163
- declare function stringifyJSON<T>(value: T): undefined extends T ? undefined | string : string;
163
+ declare function stringifyJSON<T>(value: T | {
164
+ toJSON(): T;
165
+ }): undefined extends T ? undefined | string : string;
164
166
 
165
167
  type Segment = string | number;
166
168
  declare function findDeepMatches(check: (value: unknown) => boolean, payload: unknown, segments?: Segment[], maps?: Segment[][], values?: unknown[]): {
@@ -183,7 +185,7 @@ declare const NullProtoObj: ({
183
185
  });
184
186
 
185
187
  interface AsyncIdQueueCloseOptions {
186
- id?: number;
188
+ id?: string;
187
189
  reason?: unknown;
188
190
  }
189
191
  declare class AsyncIdQueue<T> {
@@ -191,12 +193,12 @@ declare class AsyncIdQueue<T> {
191
193
  private readonly items;
192
194
  private readonly pendingPulls;
193
195
  get length(): number;
194
- open(id: number): void;
195
- isOpen(id: number): boolean;
196
- push(id: number, item: T): void;
197
- pull(id: number): Promise<T>;
196
+ open(id: string): void;
197
+ isOpen(id: string): boolean;
198
+ push(id: string, item: T): void;
199
+ pull(id: string): Promise<T>;
198
200
  close({ id, reason }?: AsyncIdQueueCloseOptions): void;
199
- assertOpen(id: number): void;
201
+ assertOpen(id: string): void;
200
202
  }
201
203
 
202
204
  type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
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 nextId;
84
- generate(): number;
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>>;
@@ -160,7 +160,9 @@ declare class AsyncIteratorClass<T, TReturn = unknown, TNext = unknown> implemen
160
160
  declare function replicateAsyncIterator<T, TReturn, TNext>(source: AsyncIterator<T, TReturn, TNext>, count: number): (AsyncIteratorClass<T, TReturn, TNext>)[];
161
161
 
162
162
  declare function parseEmptyableJSON(text: string | null | undefined): unknown;
163
- declare function stringifyJSON<T>(value: T): undefined extends T ? undefined | string : string;
163
+ declare function stringifyJSON<T>(value: T | {
164
+ toJSON(): T;
165
+ }): undefined extends T ? undefined | string : string;
164
166
 
165
167
  type Segment = string | number;
166
168
  declare function findDeepMatches(check: (value: unknown) => boolean, payload: unknown, segments?: Segment[], maps?: Segment[][], values?: unknown[]): {
@@ -183,7 +185,7 @@ declare const NullProtoObj: ({
183
185
  });
184
186
 
185
187
  interface AsyncIdQueueCloseOptions {
186
- id?: number;
188
+ id?: string;
187
189
  reason?: unknown;
188
190
  }
189
191
  declare class AsyncIdQueue<T> {
@@ -191,12 +193,12 @@ declare class AsyncIdQueue<T> {
191
193
  private readonly items;
192
194
  private readonly pendingPulls;
193
195
  get length(): number;
194
- open(id: number): void;
195
- isOpen(id: number): boolean;
196
- push(id: number, item: T): void;
197
- pull(id: number): Promise<T>;
196
+ open(id: string): void;
197
+ isOpen(id: string): boolean;
198
+ push(id: string, item: T): void;
199
+ pull(id: string): Promise<T>;
198
200
  close({ id, reason }?: AsyncIdQueueCloseOptions): void;
199
- assertOpen(id: number): void;
201
+ assertOpen(id: string): void;
200
202
  }
201
203
 
202
204
  type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
package/dist/index.mjs CHANGED
@@ -194,8 +194,8 @@ function replicateAsyncIterator(source, count) {
194
194
  while (true) {
195
195
  const item = await source.next();
196
196
  for (let id = 0; id < count; id++) {
197
- if (queue.isOpen(id)) {
198
- queue.push(id, item);
197
+ if (queue.isOpen(id.toString())) {
198
+ queue.push(id.toString(), item);
199
199
  }
200
200
  }
201
201
  if (item.done) {
@@ -207,12 +207,12 @@ function replicateAsyncIterator(source, count) {
207
207
  }
208
208
  });
209
209
  for (let id = 0; id < count; id++) {
210
- queue.open(id);
210
+ queue.open(id.toString());
211
211
  replicated.push(new AsyncIteratorClass(
212
212
  () => {
213
213
  start();
214
214
  return new Promise((resolve, reject) => {
215
- queue.pull(id).then(resolve).catch(reject);
215
+ queue.pull(id.toString()).then(resolve).catch(reject);
216
216
  defer(() => {
217
217
  if (error) {
218
218
  reject(error.value);
@@ -221,9 +221,9 @@ function replicateAsyncIterator(source, count) {
221
221
  });
222
222
  },
223
223
  async (reason) => {
224
- queue.close({ id });
224
+ queue.close({ id: id.toString() });
225
225
  if (reason !== "next") {
226
- if (replicated.every((_, id2) => !queue.isOpen(id2))) {
226
+ if (replicated.every((_, id2) => !queue.isOpen(id2.toString()))) {
227
227
  await source?.return?.();
228
228
  }
229
229
  }
@@ -270,6 +270,7 @@ class EventPublisher {
270
270
  }
271
271
  const signal = listenerOrOptions?.signal;
272
272
  const maxBufferedEvents = listenerOrOptions?.maxBufferedEvents ?? this.#maxBufferedEvents;
273
+ signal?.throwIfAborted();
273
274
  const bufferedEvents = [];
274
275
  const pullResolvers = [];
275
276
  const unsubscribe = this.subscribe(event, (payload) => {
@@ -311,13 +312,11 @@ class EventPublisher {
311
312
  }
312
313
 
313
314
  class SequentialIdGenerator {
314
- nextId = 0;
315
+ index = BigInt(0);
315
316
  generate() {
316
- if (this.nextId === Number.MAX_SAFE_INTEGER) {
317
- this.nextId = 0;
318
- return Number.MAX_SAFE_INTEGER;
319
- }
320
- return this.nextId++;
317
+ const id = this.index.toString(32);
318
+ this.index++;
319
+ return id;
321
320
  }
322
321
  }
323
322
 
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.e6490f2",
4
+ "version": "0.0.0-next.e710b76",
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.0",
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.49"
33
+ "zod": "^3.25.67"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "unbuild",