@oino-ts/types 0.17.3 → 0.17.4

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.
@@ -0,0 +1,13 @@
1
+ export type OINOHeadersInit = OINOHeaders | Record<string, string> | [string, string][] | Map<string, string>;
2
+ /**
3
+ * Type for HTTP style headers that just guarantees keys are normalized to lowercase.
4
+ *
5
+ */
6
+ export declare class OINOHeaders {
7
+ [key: string]: any;
8
+ constructor(init?: OINOHeadersInit);
9
+ get(key: string): string | undefined;
10
+ set(key: string, value: string): void;
11
+ setHeaders(init?: OINOHeadersInit): void;
12
+ clear(): void;
13
+ }
@@ -1,4 +1,5 @@
1
- import { OINOContentType } from ".";
1
+ import { Buffer } from "node:buffer";
2
+ import { OINOContentType, OINOHeaders, OINOHeadersInit } from ".";
2
3
  export interface OINORequestInit {
3
4
  params?: Record<string, string>;
4
5
  }
@@ -18,15 +19,10 @@ export declare class OINORequest {
18
19
  */
19
20
  constructor(init?: OINORequestInit);
20
21
  }
21
- /**
22
- * Type for HTTP headers that just guarantees keys are normalized to lowercase.
23
- *
24
- */
25
- export type OINOHttpHeaders = Record<string, string>;
26
22
  export interface OINOHttpRequestInit extends OINORequestInit {
27
23
  url?: URL;
28
24
  method?: string;
29
- headers?: OINOHttpHeaders | Record<string, string>;
25
+ headers?: OINOHeadersInit;
30
26
  data?: string | Buffer | Uint8Array | object | null;
31
27
  requestType?: OINOContentType;
32
28
  responseType?: OINOContentType;
@@ -39,7 +35,7 @@ export interface OINOHttpRequestInit extends OINORequestInit {
39
35
  export declare class OINOHttpRequest extends OINORequest {
40
36
  readonly url?: URL;
41
37
  readonly method: string;
42
- readonly headers: OINOHttpHeaders;
38
+ readonly headers: OINOHeaders;
43
39
  readonly data: string | Buffer | Uint8Array | object | null;
44
40
  readonly requestType: OINOContentType;
45
41
  readonly responseType: OINOContentType;
@@ -1,3 +1,4 @@
1
+ import { OINOHeaders, OINOHeadersInit } from ".";
1
2
  export interface OINOResultInit {
2
3
  success?: boolean;
3
4
  status?: number;
@@ -79,7 +80,7 @@ export declare class OINOResult {
79
80
  * @param copyDebug wether debug messages should be copied (default false)
80
81
  *
81
82
  */
82
- copyMessagesToHeaders(headers: Headers, copyErrors?: boolean, copyWarnings?: boolean, copyInfos?: boolean, copyDebug?: boolean): void;
83
+ copyMessagesToHeaders(headers: OINOHeaders, copyErrors?: boolean, copyWarnings?: boolean, copyInfos?: boolean, copyDebug?: boolean): void;
83
84
  /**
84
85
  * Print result for logging.
85
86
  *
@@ -88,7 +89,7 @@ export declare class OINOResult {
88
89
  }
89
90
  export interface OINOHttpResultInit extends OINOResultInit {
90
91
  body?: string;
91
- headers?: Record<string, string>;
92
+ headers?: OINOHeadersInit;
92
93
  expires?: number;
93
94
  lastModified?: number;
94
95
  }
@@ -100,7 +101,7 @@ export declare class OINOHttpResult extends OINOResult {
100
101
  /** HTTP body data */
101
102
  readonly body: string;
102
103
  /** HTTP headers */
103
- readonly headers?: Record<string, string>;
104
+ readonly headers: OINOHeaders;
104
105
  /** HTTP cache expiration value
105
106
  * Note: default 0 means no expiration and 'Pragma: no-cache' is set.
106
107
  */
@@ -124,5 +125,5 @@ export declare class OINOHttpResult extends OINOResult {
124
125
  *
125
126
  * @param headers HTTP headers (overrides existing values)
126
127
  */
127
- getFetchResponse(headers?: Record<string, string>): Response;
128
+ getFetchResponse(headers?: OINOHeadersInit): Response;
128
129
  }
@@ -5,6 +5,7 @@ export { OINORequest, OINOHttpRequest, type OINORequestInit, type OINOHttpReques
5
5
  export { OINOStr } from "./OINOStr.js";
6
6
  export { OINOHtmlTemplate } from "./OINOHtmlTemplate.js";
7
7
  export { OINOFormatter, OINO_EMPTY_FORMATTER } from "./OINOFormatter.js";
8
+ export { OINOHeaders, type OINOHeadersInit } from "./OINOHeaders.js";
8
9
  /** OINO error message prefix */
9
10
  export declare const OINO_ERROR_PREFIX = "OINO ERROR";
10
11
  /** OINO warning message prefix */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/types",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "description": "OINO TS package for types.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",