@nxgt/httpyz 0.1.0

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.
Files changed (54) hide show
  1. package/README.md +1295 -0
  2. package/dist/cancel/abort.d.ts +20 -0
  3. package/dist/cancel/abort.d.ts.map +1 -0
  4. package/dist/cancel/latest.d.ts +3 -0
  5. package/dist/cancel/latest.d.ts.map +1 -0
  6. package/dist/client/create-http-client.d.ts +14 -0
  7. package/dist/client/create-http-client.d.ts.map +1 -0
  8. package/dist/client/types.d.ts +123 -0
  9. package/dist/client/types.d.ts.map +1 -0
  10. package/dist/errors/errors.d.ts +80 -0
  11. package/dist/errors/errors.d.ts.map +1 -0
  12. package/dist/index.d.ts +15 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +1110 -0
  15. package/dist/index.js.map +27 -0
  16. package/dist/integration/index.d.ts +9 -0
  17. package/dist/integration/index.d.ts.map +1 -0
  18. package/dist/integration/index.js +1051 -0
  19. package/dist/integration/index.js.map +25 -0
  20. package/dist/middleware/auth.d.ts +18 -0
  21. package/dist/middleware/auth.d.ts.map +1 -0
  22. package/dist/middleware/cache.d.ts +42 -0
  23. package/dist/middleware/cache.d.ts.map +1 -0
  24. package/dist/middleware/compose.d.ts +22 -0
  25. package/dist/middleware/compose.d.ts.map +1 -0
  26. package/dist/middleware/retry.d.ts +36 -0
  27. package/dist/middleware/retry.d.ts.map +1 -0
  28. package/dist/reply/media-type.d.ts +18 -0
  29. package/dist/reply/media-type.d.ts.map +1 -0
  30. package/dist/reply/read-reply.d.ts +25 -0
  31. package/dist/reply/read-reply.d.ts.map +1 -0
  32. package/dist/reply/types.d.ts +55 -0
  33. package/dist/reply/types.d.ts.map +1 -0
  34. package/dist/reply/unwrap.d.ts +31 -0
  35. package/dist/reply/unwrap.d.ts.map +1 -0
  36. package/dist/request/encode.d.ts +24 -0
  37. package/dist/request/encode.d.ts.map +1 -0
  38. package/dist/request/types.d.ts +57 -0
  39. package/dist/request/types.d.ts.map +1 -0
  40. package/dist/schema/standard-schema.d.ts +46 -0
  41. package/dist/schema/standard-schema.d.ts.map +1 -0
  42. package/dist/stream/connection.d.ts +45 -0
  43. package/dist/stream/connection.d.ts.map +1 -0
  44. package/dist/stream/event-stream.d.ts +15 -0
  45. package/dist/stream/event-stream.d.ts.map +1 -0
  46. package/dist/stream/line-parser.d.ts +13 -0
  47. package/dist/stream/line-parser.d.ts.map +1 -0
  48. package/dist/stream/line-stream.d.ts +10 -0
  49. package/dist/stream/line-stream.d.ts.map +1 -0
  50. package/dist/stream/sse-parser.d.ts +25 -0
  51. package/dist/stream/sse-parser.d.ts.map +1 -0
  52. package/dist/stream/types.d.ts +66 -0
  53. package/dist/stream/types.d.ts.map +1 -0
  54. package/package.json +54 -0
@@ -0,0 +1,46 @@
1
+ /**
2
+ * [Standard Schema](https://standardschema.dev), the part the client calls.
3
+ * Zod 4, Valibot and ArkType schemas all carry it, so the client imports
4
+ * none of them: it reads their `~standard`.
5
+ */
6
+ import type { ValidationIssue } from '../errors/errors';
7
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
8
+ readonly '~standard': {
9
+ readonly version: 1;
10
+ readonly vendor: string;
11
+ readonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;
12
+ readonly types?: {
13
+ readonly input: Input;
14
+ readonly output: Output;
15
+ } | undefined;
16
+ };
17
+ }
18
+ export type StandardResult<Output> = {
19
+ readonly value: Output;
20
+ readonly issues?: undefined;
21
+ } | {
22
+ readonly issues: readonly StandardIssue[];
23
+ };
24
+ export interface StandardIssue {
25
+ readonly message: string;
26
+ readonly path?: readonly (PropertyKey | {
27
+ readonly key: PropertyKey;
28
+ })[] | undefined;
29
+ }
30
+ /** What a schema accepts. */
31
+ export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
32
+ /** What a schema gives back. */
33
+ export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
34
+ export type Checked = {
35
+ readonly ok: true;
36
+ readonly value: unknown;
37
+ } | {
38
+ readonly ok: false;
39
+ readonly issues: ValidationIssue[];
40
+ };
41
+ /**
42
+ * `value` through `schema`: its output, or its issues as `/hono` reports
43
+ * them. Zod's `code` is kept; a vendor without one reads as `custom`.
44
+ */
45
+ export declare function check(schema: StandardSchemaV1, value: unknown, target: ValidationIssue['target']): Promise<Checked>;
46
+ //# sourceMappingURL=standard-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../../src/schema/standard-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;IAChE,QAAQ,CAAC,WAAW,EAAE;QACrB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,CAClB,KAAK,EAAE,OAAO,KACV,cAAc,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,QAAQ,CAAC,KAAK,CAAC,EACZ;YAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;YAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;SAAE,GAClD,SAAS,CAAC;KACb,CAAC;CACF;AAED,MAAM,MAAM,cAAc,CAAC,MAAM,IAC9B;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EACX,SAAS,CAAC,WAAW,GAAG;QAAE,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,EAAE,GACxD,SAAS,CAAC;CACb;AAED,6BAA6B;AAC7B,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,gBAAgB,IAAI,WAAW,CACpE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAC5B,CAAC,OAAO,CAAC,CAAC;AAEX,gCAAgC;AAChC,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,gBAAgB,IAAI,WAAW,CACrE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAC5B,CAAC,QAAQ,CAAC,CAAC;AAEZ,MAAM,MAAM,OAAO,GAChB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAE9D;;;GAGG;AACH,wBAAsB,KAAK,CAC1B,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAC/B,OAAO,CAAC,OAAO,CAAC,CAiBlB"}
@@ -0,0 +1,45 @@
1
+ /** What the two streams share: how a connection opens, and how its items are checked. */
2
+ import { type CallContext } from '../errors/errors';
3
+ import { type StandardSchemaV1 } from '../schema/standard-schema';
4
+ /**
5
+ * Opens one connection through the client's `retry`, `auth` and `use`, and
6
+ * resolves once the reply's headers have arrived. `lastEventId` is sent as
7
+ * `Last-Event-ID`.
8
+ */
9
+ export type Open = (signal: AbortSignal, lastEventId: string | undefined) => Promise<Response>;
10
+ export interface StreamSettings {
11
+ readonly context: CallContext;
12
+ readonly open: Open;
13
+ /** The caller's own signal: its abort comes through as it is. */
14
+ readonly signal: AbortSignal | undefined;
15
+ readonly validate: boolean;
16
+ readonly decode: boolean;
17
+ }
18
+ /**
19
+ * Whether the reply opened a stream: `false` for a 204, which ends it. Any
20
+ * other status but a 2xx throws, with its body unread, and a reply of
21
+ * another media type is refused.
22
+ */
23
+ export declare function opened(settings: StreamSettings, response: Response, types: readonly string[]): Promise<boolean>;
24
+ /** A JSON text, through its schema as a reply is checked. */
25
+ export declare function settle(settings: StreamSettings, status: number, text: string, schema: StandardSchemaV1 | undefined, what: string): Promise<unknown>;
26
+ /** Waits `ms`, or less, when a signal aborts. */
27
+ export declare function pause(ms: number, ...signals: (AbortSignal | undefined)[]): Promise<void>;
28
+ /**
29
+ * The reader of the connection a stream is on, and how it stops: `close()`
30
+ * or the caller's abort cancels the read in progress, since an aborted
31
+ * request does not always end its body.
32
+ */
33
+ export declare class Reading {
34
+ #private;
35
+ readonly closer: AbortController;
36
+ constructor(signal: AbortSignal | undefined);
37
+ /** Reads `response`'s body as text. */
38
+ read(response: Response): ReadableStreamDefaultReader<string>;
39
+ /** Whether the stream was closed; the caller's abort throws its reason. */
40
+ stopped(): boolean;
41
+ /** Lets the reader go, and stops listening to the caller's signal. */
42
+ release(): void;
43
+ close(): void;
44
+ }
45
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/stream/connection.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EACN,KAAK,WAAW,EAIhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAS,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEzE;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG,CAClB,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,MAAM,GAAG,SAAS,KAC3B,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CACzB;AAcD;;;;GAIG;AACH,wBAAsB,MAAM,CAC3B,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,OAAO,CAAC,CAoBlB;AAED,6DAA6D;AAC7D,wBAAsB,MAAM,CAC3B,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAkBlB;AAED,iDAAiD;AACjD,wBAAgB,KAAK,CACpB,EAAE,EAAE,MAAM,EACV,GAAG,OAAO,EAAE,CAAC,WAAW,GAAG,SAAS,CAAC,EAAE,GACrC,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;GAIG;AACH,qBAAa,OAAO;;IACnB,QAAQ,CAAC,MAAM,kBAAyB;gBAO5B,MAAM,EAAE,WAAW,GAAG,SAAS;IAM3C,uCAAuC;IACvC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,2BAA2B,CAAC,MAAM,CAAC;IAM7D,2EAA2E;IAC3E,OAAO,IAAI,OAAO;IAKlB,sEAAsE;IACtE,OAAO,IAAI,IAAI;IAMf,KAAK,IAAI,IAAI;CAGb"}
@@ -0,0 +1,15 @@
1
+ import { type StreamSettings } from './connection';
2
+ import { type ServerEvent } from './sse-parser';
3
+ import type { EventSchemas, EventStream } from './types';
4
+ export interface EventSettings extends StreamSettings {
5
+ readonly events: EventSchemas | undefined;
6
+ readonly onUnknownEvent: ((event: ServerEvent) => void) | undefined;
7
+ /** `false`, or how to reconnect. */
8
+ readonly reconnect: {
9
+ readonly attempts: number;
10
+ readonly delay: number;
11
+ } | false;
12
+ readonly lastEventId: string | undefined;
13
+ }
14
+ export declare function eventStream(settings: EventSettings): EventStream<unknown>;
15
+ //# sourceMappingURL=event-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-stream.d.ts","sourceRoot":"","sources":["../../src/stream/event-stream.ts"],"names":[],"mappings":"AAMA,OAAO,EAIN,KAAK,cAAc,EAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,aAAc,SAAQ,cAAc;IACpD,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACpE,oCAAoC;IACpC,QAAQ,CAAC,SAAS,EACf;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GACrD,KAAK,CAAC;IACT,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,CA2FzE"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * JSON Lines, NDJSON and JSON text sequences, split into their records: one
3
+ * JSON text a line, or after each record separator (`\x1E`). Blank lines
4
+ * separate nothing, and a last record needs no line end.
5
+ */
6
+ export interface LineParser {
7
+ /** Reads a chunk of text, and returns the records it completed. */
8
+ push(chunk: string): string[];
9
+ /** The record left when the stream ends, if any. */
10
+ end(): string[];
11
+ }
12
+ export declare function createLineParser(): LineParser;
13
+ //# sourceMappingURL=line-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-parser.d.ts","sourceRoot":"","sources":["../../src/stream/line-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,UAAU;IAC1B,mEAAmE;IACnE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,oDAAoD;IACpD,GAAG,IAAI,MAAM,EAAE,CAAC;CAChB;AAKD,wBAAgB,gBAAgB,IAAI,UAAU,CAgB7C"}
@@ -0,0 +1,10 @@
1
+ import type { StandardSchemaV1 } from '../schema/standard-schema';
2
+ import { type StreamSettings } from './connection';
3
+ import type { Stream } from './types';
4
+ /** The media types a stream of lines is served as. */
5
+ export declare const LINE_TYPES: readonly ["application/jsonl", "application/x-ndjson", "application/ndjson", "application/jsonlines", "application/x-jsonlines", "application/json-seq"];
6
+ export interface LineSettings extends StreamSettings {
7
+ readonly item: StandardSchemaV1 | undefined;
8
+ }
9
+ export declare function lineStream(settings: LineSettings): Stream<unknown>;
10
+ //# sourceMappingURL=line-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-stream.d.ts","sourceRoot":"","sources":["../../src/stream/line-stream.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAmB,KAAK,cAAc,EAAU,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,sDAAsD;AACtD,eAAO,MAAM,UAAU,0JAOb,CAAC;AAEX,MAAM,WAAW,YAAa,SAAQ,cAAc;IACnD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,CAAC;CAC5C;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAkDlE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The event stream format, parsed as `EventSource` parses it: text in,
3
+ * events out. It follows WHATWG's "interpreting an event stream":
4
+ * https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation
5
+ */
6
+ /** An event, as the stream sent it: its `data` is text. */
7
+ export interface ServerEvent {
8
+ /** Its `event:` field, or `message` when the stream names none. */
9
+ readonly event: string;
10
+ /** Its `data:` lines, joined with a line feed. */
11
+ readonly data: string;
12
+ /** The last `id:` the stream set, carried over to every later event. */
13
+ readonly id: string | undefined;
14
+ }
15
+ export interface SseParser {
16
+ /** Reads a chunk of text, and returns the events it completed. */
17
+ push(chunk: string): ServerEvent[];
18
+ /** The last `retry:` the stream set, in milliseconds. */
19
+ readonly retry: number | undefined;
20
+ /** The last event ID an event was dispatched with: what `Last-Event-ID` sends. */
21
+ readonly lastEventId: string | undefined;
22
+ }
23
+ /** A parser for one connection; `lastEventId` carries over from the last one. */
24
+ export declare function createSseParser(lastEventId?: string): SseParser;
25
+ //# sourceMappingURL=sse-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse-parser.d.ts","sourceRoot":"","sources":["../../src/stream/sse-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IAC3B,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACzB,kEAAkE;IAClE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;IACnC,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAID,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAsF/D"}
@@ -0,0 +1,66 @@
1
+ /** What `http.events()` and `http.lines()` take, and what they yield. */
2
+ import type { CallOptions, Method } from '../client/types';
3
+ import type { SchemaData } from '../reply/types';
4
+ import type { StandardSchemaV1 } from '../schema/standard-schema';
5
+ import type { ServerEvent } from './sse-parser';
6
+ /** The events a stream declares, by name: a schema for JSON data, `null` for text. */
7
+ export type EventSchemas = {
8
+ readonly [event: string]: StandardSchemaV1 | null;
9
+ };
10
+ /** A declared event, narrowed on `event`; any event, its data as text, when none is declared. */
11
+ export type StreamEvent<E extends EventSchemas | undefined, Decoded extends boolean = true> = E extends EventSchemas ? {
12
+ [Name in keyof E & string]: {
13
+ readonly event: Name;
14
+ readonly data: E[Name] extends StandardSchemaV1 ? SchemaData<E[Name], Decoded> : string;
15
+ readonly id: string | undefined;
16
+ };
17
+ }[keyof E & string] : ServerEvent;
18
+ /** A line, as its schema checks it; `unknown` without one. */
19
+ export type StreamItem<I extends StandardSchemaV1 | undefined, Decoded extends boolean = true> = I extends StandardSchemaV1 ? SchemaData<I, Decoded> : unknown;
20
+ export interface ReconnectOptions {
21
+ /** Reconnections in a row without an event before the stream gives up. Default: no limit. */
22
+ attempts?: number;
23
+ /** Milliseconds before reconnecting, until the stream sends a `retry:`. Default: 3000. */
24
+ delay?: number;
25
+ }
26
+ interface StreamOptions<Decoded extends boolean> extends CallOptions {
27
+ /** Default: `get`. */
28
+ method?: Method;
29
+ /** Checks each item with its schema, throwing a `ValidationError`. Default: `true`. */
30
+ validate?: boolean;
31
+ /** Yields what each schema outputs, rather than what it was given. Default: `true`. */
32
+ decode?: Decoded;
33
+ }
34
+ export interface EventsOptions<E extends EventSchemas | undefined, Decoded extends boolean> extends StreamOptions<Decoded> {
35
+ /**
36
+ * The events the stream sends, by name: `{ update: Item, ping: null }`.
37
+ * A schema checks the event's data as JSON; `null` keeps it as text.
38
+ * Without it, every event is yielded as it came, its data as text.
39
+ */
40
+ events?: E;
41
+ /** An event `events` does not declare, which is not yielded. */
42
+ onUnknownEvent?: (event: ServerEvent) => void;
43
+ /**
44
+ * Connects again when the connection drops or the stream ends, as
45
+ * `EventSource` does, sending the last event ID. Never after an error
46
+ * status or a 204. Default: on, but for POST and PATCH.
47
+ */
48
+ reconnect?: boolean | ReconnectOptions;
49
+ /** Sent as `Last-Event-ID` on the first connection: where to resume. */
50
+ lastEventId?: string;
51
+ }
52
+ export interface LinesOptions<I extends StandardSchemaV1 | undefined, Decoded extends boolean> extends StreamOptions<Decoded> {
53
+ /** Checks each line, as JSON. Without it, each line is yielded parsed, as `unknown`. */
54
+ item?: I;
55
+ }
56
+ /** Read once, with `for await`. It connects when read. */
57
+ export interface Stream<T> extends AsyncIterable<T> {
58
+ /** Ends it: the connection closes, and the loop reading it ends. */
59
+ close(): void;
60
+ }
61
+ export interface EventStream<T> extends Stream<T> {
62
+ /** The last event ID the stream set: what a reconnection sends. */
63
+ readonly lastEventId: string | undefined;
64
+ }
65
+ export {};
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/stream/types.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;CAClD,CAAC;AAEF,iGAAiG;AACjG,MAAM,MAAM,WAAW,CACtB,CAAC,SAAS,YAAY,GAAG,SAAS,EAClC,OAAO,SAAS,OAAO,GAAG,IAAI,IAC3B,CAAC,SAAS,YAAY,GACvB;KACC,IAAI,IAAI,MAAM,CAAC,GAAG,MAAM,GAAG;QAC3B,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;QACrB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,gBAAgB,GAC5C,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAC5B,MAAM,CAAC;QACV,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC;CACD,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAClB,WAAW,CAAC;AAEf,8DAA8D;AAC9D,MAAM,MAAM,UAAU,CACrB,CAAC,SAAS,gBAAgB,GAAG,SAAS,EACtC,OAAO,SAAS,OAAO,GAAG,IAAI,IAC3B,CAAC,SAAS,gBAAgB,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAChC,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,aAAa,CAAC,OAAO,SAAS,OAAO,CAAE,SAAQ,WAAW;IACnE,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uFAAuF;IACvF,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,aAAa,CAC7B,CAAC,SAAS,YAAY,GAAG,SAAS,EAClC,OAAO,SAAS,OAAO,CACtB,SAAQ,aAAa,CAAC,OAAO,CAAC;IAC/B;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,gEAAgE;IAChE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC9C;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IACvC,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY,CAC5B,CAAC,SAAS,gBAAgB,GAAG,SAAS,EACtC,OAAO,SAAS,OAAO,CACtB,SAAQ,aAAa,CAAC,OAAO,CAAC;IAC/B,wFAAwF;IACxF,IAAI,CAAC,EAAE,CAAC,CAAC;CACT;AAED,0DAA0D;AAC1D,MAAM,WAAW,MAAM,CAAC,CAAC,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAClD,oEAAoE;IACpE,KAAK,IAAI,IAAI,CAAC;CACd;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IAChD,mEAAmE;IACnE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@nxgt/httpyz",
3
+ "version": "0.1.0",
4
+ "license": "UNLICENSED",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "package.json"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./integration": {
20
+ "types": "./dist/integration/index.d.ts",
21
+ "import": "./dist/integration/index.js",
22
+ "default": "./dist/integration/index.js"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/softistx/nxgt-http.git",
29
+ "directory": "packages/httpyz"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org",
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "build": "bun run ../../build.ts",
37
+ "test": "bun test src",
38
+ "typecheck": "tsc --noEmit"
39
+ },
40
+ "nxgt": {
41
+ "entrypoints": [
42
+ "src/index.ts",
43
+ "src/integration/index.ts"
44
+ ]
45
+ },
46
+ "devDependencies": {
47
+ "@types/bun": "^1.4.0",
48
+ "hono": "^4.13.4",
49
+ "zod": "^4.5.4"
50
+ },
51
+ "peerDependencies": {
52
+ "typescript": "^6.0.3"
53
+ }
54
+ }