@orpc/shared 2.0.0-beta.10 → 2.0.0-beta.12
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 +1 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +26 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
50
50
|
- [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect): Integrate with [Effect](https://effect.website/).
|
|
51
51
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Implement your contract with [NestJS](https://nestjs.com/).
|
|
52
52
|
- [@orpc/bun](https://www.npmjs.com/package/@orpc/bun): Adapters for [Bun's Redis](https://bun.sh/).
|
|
53
|
+
- [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare): Adapters for [Cloudflare's RateLimit and Durable Objects](https://developers.cloudflare.com/workers/).
|
|
53
54
|
|
|
54
55
|
**Observability**
|
|
55
56
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Promisable } from 'type-fest';
|
|
2
|
-
export { IsEqual, PartialDeep, Promisable, Writable } from 'type-fest';
|
|
1
|
+
import { Arrayable, Promisable } from 'type-fest';
|
|
2
|
+
export { Arrayable, IsEqual, PartialDeep, Promisable, Writable } from 'type-fest';
|
|
3
3
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
4
4
|
import { AsyncIteratorClass } from '@standardserver/shared';
|
|
5
|
-
export { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sleep, stringifyJSON, toArray } from '@standardserver/shared';
|
|
5
|
+
export { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@standardserver/shared';
|
|
6
6
|
|
|
7
7
|
type MaybeOptionalOptions<TOptions> = object extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
8
8
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
@@ -14,13 +14,13 @@ declare function splitInHalf<T>(arr: readonly T[]): [T[], T[]];
|
|
|
14
14
|
*
|
|
15
15
|
* Prefers the newer `.bytes` method when available as it more efficient but not widely supported yet.
|
|
16
16
|
*/
|
|
17
|
-
declare function loadBytes(source: Pick<Blob, 'arrayBuffer' | 'bytes'>):
|
|
17
|
+
declare function loadBytes(source: Pick<Blob, 'arrayBuffer' | 'bytes'>): ReturnType<Blob['bytes']>;
|
|
18
18
|
/**
|
|
19
19
|
* Normalize text or binary-like inputs to either:
|
|
20
20
|
* - the original string value, or
|
|
21
21
|
* - a Uint8Array view over the source bytes.
|
|
22
22
|
*/
|
|
23
|
-
declare function toStringOrBytes(source: string | ArrayBuffer |
|
|
23
|
+
declare function toStringOrBytes(source: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>): string | Awaited<ReturnType<Blob['bytes']>>;
|
|
24
24
|
|
|
25
25
|
declare function isDeepEqual(a: unknown, b: unknown): boolean;
|
|
26
26
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Promisable } from 'type-fest';
|
|
2
|
-
export { IsEqual, PartialDeep, Promisable, Writable } from 'type-fest';
|
|
1
|
+
import { Arrayable, Promisable } from 'type-fest';
|
|
2
|
+
export { Arrayable, IsEqual, PartialDeep, Promisable, Writable } from 'type-fest';
|
|
3
3
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
4
4
|
import { AsyncIteratorClass } from '@standardserver/shared';
|
|
5
|
-
export { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sleep, stringifyJSON, toArray } from '@standardserver/shared';
|
|
5
|
+
export { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@standardserver/shared';
|
|
6
6
|
|
|
7
7
|
type MaybeOptionalOptions<TOptions> = object extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
8
8
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
@@ -14,13 +14,13 @@ declare function splitInHalf<T>(arr: readonly T[]): [T[], T[]];
|
|
|
14
14
|
*
|
|
15
15
|
* Prefers the newer `.bytes` method when available as it more efficient but not widely supported yet.
|
|
16
16
|
*/
|
|
17
|
-
declare function loadBytes(source: Pick<Blob, 'arrayBuffer' | 'bytes'>):
|
|
17
|
+
declare function loadBytes(source: Pick<Blob, 'arrayBuffer' | 'bytes'>): ReturnType<Blob['bytes']>;
|
|
18
18
|
/**
|
|
19
19
|
* Normalize text or binary-like inputs to either:
|
|
20
20
|
* - the original string value, or
|
|
21
21
|
* - a Uint8Array view over the source bytes.
|
|
22
22
|
*/
|
|
23
|
-
declare function toStringOrBytes(source: string | ArrayBuffer |
|
|
23
|
+
declare function toStringOrBytes(source: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>): string | Awaited<ReturnType<Blob['bytes']>>;
|
|
24
24
|
|
|
25
25
|
declare function isDeepEqual(a: unknown, b: unknown): boolean;
|
|
26
26
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbortError, AsyncIteratorClass, isTypescriptObject, getOrBind } from '@standardserver/shared';
|
|
2
|
-
export { AbortError, AsyncIteratorClass, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sleep, stringifyJSON, toArray } from '@standardserver/shared';
|
|
2
|
+
export { AbortError, AsyncIteratorClass, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@standardserver/shared';
|
|
3
3
|
|
|
4
4
|
function resolveMaybeOptionalOptions(rest) {
|
|
5
5
|
return rest[0] ?? {};
|
|
@@ -16,24 +16,44 @@ async function loadBytes(source) {
|
|
|
16
16
|
}
|
|
17
17
|
return new Uint8Array(await source.arrayBuffer());
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
function toStringOrBytes(source) {
|
|
20
20
|
if (typeof source === "string") {
|
|
21
21
|
return source;
|
|
22
22
|
}
|
|
23
23
|
if (source instanceof ArrayBuffer) {
|
|
24
24
|
return new Uint8Array(source);
|
|
25
25
|
}
|
|
26
|
-
if (source instanceof Blob) {
|
|
27
|
-
return loadBytes(source);
|
|
28
|
-
}
|
|
29
26
|
if (Array.isArray(source)) {
|
|
30
|
-
return
|
|
27
|
+
return concatBytes(source);
|
|
31
28
|
}
|
|
32
29
|
if (source instanceof Uint8Array) {
|
|
33
30
|
return source;
|
|
34
31
|
}
|
|
35
32
|
return new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
36
33
|
}
|
|
34
|
+
function toBytes(item) {
|
|
35
|
+
if (typeof item === "string") {
|
|
36
|
+
return new TextEncoder().encode(item);
|
|
37
|
+
}
|
|
38
|
+
if (item instanceof ArrayBuffer) {
|
|
39
|
+
return new Uint8Array(item);
|
|
40
|
+
}
|
|
41
|
+
if (item instanceof Uint8Array) {
|
|
42
|
+
return item;
|
|
43
|
+
}
|
|
44
|
+
return new Uint8Array(item.buffer, item.byteOffset, item.byteLength);
|
|
45
|
+
}
|
|
46
|
+
function concatBytes(items) {
|
|
47
|
+
const chunks = items.map(toBytes);
|
|
48
|
+
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.byteLength, 0);
|
|
49
|
+
const result = new Uint8Array(totalLength);
|
|
50
|
+
let offset = 0;
|
|
51
|
+
for (const chunk of chunks) {
|
|
52
|
+
result.set(chunk, offset);
|
|
53
|
+
offset += chunk.byteLength;
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
37
57
|
|
|
38
58
|
function isDeepEqual(a, b) {
|
|
39
59
|
return isDeepEqualInternal(a, b, /* @__PURE__ */ new WeakMap());
|