@orpc/standard-server 0.0.0-next.b2e67f7 → 0.0.0-next.cc4cb21
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
CHANGED
|
@@ -151,10 +151,8 @@ function encodeEventMessage(message) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// src/event-source/meta.ts
|
|
154
|
+
import { isTypescriptObject } from "@orpc/shared";
|
|
154
155
|
var EVENT_SOURCE_META_SYMBOL = Symbol("ORPC_EVENT_SOURCE_META");
|
|
155
|
-
function isEventMetaContainer(value) {
|
|
156
|
-
return !!value && (typeof value === "object" || typeof value === "function");
|
|
157
|
-
}
|
|
158
156
|
function withEventMeta(container, meta) {
|
|
159
157
|
if (meta.id !== void 0) {
|
|
160
158
|
assertEventId(meta.id);
|
|
@@ -172,34 +170,11 @@ function withEventMeta(container, meta) {
|
|
|
172
170
|
});
|
|
173
171
|
}
|
|
174
172
|
function getEventMeta(container) {
|
|
175
|
-
return
|
|
173
|
+
return isTypescriptObject(container) ? Reflect.get(container, EVENT_SOURCE_META_SYMBOL) : void 0;
|
|
176
174
|
}
|
|
177
175
|
|
|
178
176
|
// src/utils.ts
|
|
179
177
|
import { contentDisposition, parse } from "@tinyhttp/content-disposition";
|
|
180
|
-
function once(fn) {
|
|
181
|
-
let cached;
|
|
182
|
-
return () => {
|
|
183
|
-
if (cached) {
|
|
184
|
-
return cached.result;
|
|
185
|
-
}
|
|
186
|
-
const result = fn();
|
|
187
|
-
cached = { result };
|
|
188
|
-
return result;
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
function parseEmptyableJSON(text) {
|
|
192
|
-
if (!text) {
|
|
193
|
-
return void 0;
|
|
194
|
-
}
|
|
195
|
-
return JSON.parse(text);
|
|
196
|
-
}
|
|
197
|
-
function isAsyncIteratorObject(maybe) {
|
|
198
|
-
if (!maybe || typeof maybe !== "object") {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
return Symbol.asyncIterator in maybe && typeof maybe[Symbol.asyncIterator] === "function";
|
|
202
|
-
}
|
|
203
178
|
export {
|
|
204
179
|
ErrorEvent,
|
|
205
180
|
EventDecoder,
|
|
@@ -215,11 +190,7 @@ export {
|
|
|
215
190
|
encodeEventData,
|
|
216
191
|
encodeEventMessage,
|
|
217
192
|
getEventMeta,
|
|
218
|
-
isAsyncIteratorObject,
|
|
219
|
-
isEventMetaContainer,
|
|
220
|
-
once,
|
|
221
193
|
parse as parseContentDisposition,
|
|
222
|
-
parseEmptyableJSON,
|
|
223
194
|
withEventMeta
|
|
224
195
|
};
|
|
225
196
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { JsonValue } from 'type-fest';
|
|
2
1
|
export declare class EventEncoderError extends TypeError {
|
|
3
2
|
}
|
|
4
3
|
export declare class EventDecoderError extends TypeError {
|
|
5
4
|
}
|
|
6
5
|
export interface ErrorEventOptions extends ErrorOptions {
|
|
7
6
|
message?: string;
|
|
8
|
-
data?:
|
|
7
|
+
data?: unknown;
|
|
9
8
|
}
|
|
10
9
|
export declare class ErrorEvent extends Error {
|
|
11
|
-
data:
|
|
10
|
+
data: unknown;
|
|
12
11
|
constructor(options?: ErrorEventOptions);
|
|
13
12
|
}
|
|
14
13
|
export declare class UnknownEvent extends ErrorEvent {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { EventMessage } from './types';
|
|
2
2
|
export type EventMeta = Partial<Pick<EventMessage, 'retry' | 'id'>>;
|
|
3
|
-
export declare function isEventMetaContainer(value: unknown): value is Record<PropertyKey, unknown>;
|
|
4
3
|
export declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
|
|
5
4
|
export declare function getEventMeta(container: unknown): EventMeta | undefined;
|
|
6
5
|
//# sourceMappingURL=meta.d.ts.map
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { JsonValue } from 'type-fest';
|
|
2
|
-
export type { JsonValue };
|
|
3
1
|
export interface StandardHeaders {
|
|
4
2
|
[key: string]: string | string[] | undefined;
|
|
5
3
|
}
|
|
6
|
-
export type StandardBody = undefined |
|
|
4
|
+
export type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
7
5
|
export interface StandardRequest {
|
|
8
6
|
/**
|
|
9
7
|
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import type { JsonValue } from 'type-fest';
|
|
2
|
-
export declare function once<T extends () => any>(fn: T): () => ReturnType<T>;
|
|
3
|
-
export declare function parseEmptyableJSON(text: string): JsonValue | undefined;
|
|
4
|
-
export declare function isAsyncIteratorObject(maybe: unknown): maybe is AsyncIteratorObject<any, any, any>;
|
|
5
1
|
export { contentDisposition, parse as parseContentDisposition } from '@tinyhttp/content-disposition';
|
|
6
2
|
//# sourceMappingURL=utils.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.cc4cb21",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@tinyhttp/content-disposition": "^2.2.2",
|
|
32
|
-
"
|
|
32
|
+
"@orpc/shared": "0.0.0-next.cc4cb21"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|