@oino-ts/types 0.17.5 → 0.19.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.
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { Buffer } from "node:buffer";
2
4
  import { OINOContentType, OINOHeaders, OINOHeadersInit } from ".";
3
5
  export interface OINORequestInit {
@@ -19,11 +21,12 @@ export declare class OINORequest {
19
21
  */
20
22
  constructor(init?: OINORequestInit);
21
23
  }
24
+ export type OINOHttpData = string | Buffer | Uint8Array | null;
22
25
  export interface OINOHttpRequestInit extends OINORequestInit {
23
- url?: URL;
26
+ url?: URL | string;
24
27
  method?: string;
25
28
  headers?: OINOHeadersInit;
26
- data?: string | Buffer | Uint8Array | object | null;
29
+ body?: OINOHttpData;
27
30
  requestType?: OINOContentType;
28
31
  responseType?: OINOContentType;
29
32
  multipartBoundary?: string;
@@ -33,15 +36,15 @@ export interface OINOHttpRequestInit extends OINORequestInit {
33
36
  * Specialized result for HTTP responses.
34
37
  */
35
38
  export declare class OINOHttpRequest extends OINORequest {
36
- readonly url?: URL;
37
- readonly method: string;
38
- readonly headers: OINOHeaders;
39
- readonly data: string | Buffer | Uint8Array | object | null;
40
- readonly requestType: OINOContentType;
41
- readonly responseType: OINOContentType;
42
- readonly multipartBoundary?: string;
43
- readonly lastModified?: number;
44
- readonly etags?: string[];
39
+ url?: URL;
40
+ method: string;
41
+ headers: OINOHeaders;
42
+ body: OINOHttpData;
43
+ requestType: OINOContentType;
44
+ responseType: OINOContentType;
45
+ multipartBoundary?: string;
46
+ lastModified?: number;
47
+ etags?: string[];
45
48
  /**
46
49
  * Constructor for a `OINOHttpRequest`
47
50
  *
@@ -49,9 +52,31 @@ export declare class OINOHttpRequest extends OINORequest {
49
52
  *
50
53
  */
51
54
  constructor(init: OINOHttpRequestInit);
55
+ /**
56
+ * Creates a `OINOHttpRequest` from a Fetch API `Request` object.
57
+ *
58
+ * @param request Fetch request
59
+ *
60
+ */
52
61
  static fromFetchRequest(request: Request): Promise<OINOHttpRequest>;
53
- dataAsText(): string;
54
- dataAsParsedJson(): any;
55
- dataAsFormData(): URLSearchParams;
56
- dataAsBuffer(): Buffer;
62
+ /**
63
+ * Returns the request data as a text string.
64
+ *
65
+ */
66
+ bodyAsText(): string;
67
+ /**
68
+ * Returns the request data parsed as JSON object.
69
+ *
70
+ */
71
+ bodyAsParsedJson(): any;
72
+ /**
73
+ * Returns the request data as URLSearchParams (form data).
74
+ *
75
+ */
76
+ bodyAsFormData(): URLSearchParams;
77
+ /**
78
+ * Returns the request data as Buffer.
79
+ *
80
+ */
81
+ bodyAsBuffer(): Buffer;
57
82
  }
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { Buffer } from "node:buffer";
2
4
  import { OINOHeaders, OINOHeadersInit } from ".";
3
5
  export interface OINOResultInit {
@@ -127,4 +129,31 @@ export declare class OINOHttpResult extends OINOResult {
127
129
  * @param headers HTTP headers (overrides existing values)
128
130
  */
129
131
  getFetchResponse(headers?: OINOHeadersInit): Response;
132
+ /**
133
+ * Create from a Response object from the result values.
134
+ *
135
+ * @param response fetch Response object
136
+ *
137
+ */
138
+ static fromFetchResponse(response: Response): Promise<OINOHttpResult>;
139
+ /**
140
+ * Returns the request body as a text string.
141
+ *
142
+ */
143
+ bodyAsText(): string;
144
+ /**
145
+ * Returns the request body parsed as JSON object.
146
+ *
147
+ */
148
+ bodyAsParsedJson(): any;
149
+ /**
150
+ * Returns the request body as URLSearchParams (form body).
151
+ *
152
+ */
153
+ bodyAsFormData(): URLSearchParams;
154
+ /**
155
+ * Returns the request body as Buffer.
156
+ *
157
+ */
158
+ bodyAsBuffer(): Buffer;
130
159
  }
@@ -1,7 +1,7 @@
1
1
  export { OINOBenchmark, OINOMemoryBenchmark } from "./OINOBenchmark.js";
2
2
  export { OINOLog, OINOLogLevel, OINOConsoleLog } from "./OINOLog.js";
3
3
  export { OINOResult, OINOHttpResult, type OINOResultInit, type OINOHttpResultInit } from "./OINOResult.js";
4
- export { OINORequest, OINOHttpRequest, type OINORequestInit, type OINOHttpRequestInit } from "./OINORequest.js";
4
+ export { OINORequest, OINOHttpRequest, type OINOHttpData, type OINORequestInit, type OINOHttpRequestInit } from "./OINORequest.js";
5
5
  export { OINOStr } from "./OINOStr.js";
6
6
  export { OINOHtmlTemplate } from "./OINOHtmlTemplate.js";
7
7
  export { OINOFormatter, OINO_EMPTY_FORMATTER } from "./OINOFormatter.js";
package/index.d.ts CHANGED
@@ -1,23 +1,7 @@
1
1
  /// <reference path="db/src/index.d.ts
2
- /// <reference path="db/src/OINODb.d.ts
3
- /// <reference path="db/src/OINODbApi.d.ts
4
- /// <reference path="db/src/OINODbConfig.d.ts
5
- /// <reference path="db/src/OINODbDataField.d.ts
6
- /// <reference path="db/src/OINODbDataModel.d.ts
7
- /// <reference path="db/src/OINODbFactory.d.ts
8
- /// <reference path="db/src/OINODbModelSet.d.ts
9
- /// <reference path="db/src/OINODbRequestParams.d.ts
10
- /// <reference path="db/src/OINODbSqlParams.d.ts
11
- /// <reference path="db/src/OINODbSwagger.d.ts
12
- /// <reference path="db/src/OINODbParser.d.ts
13
- /// <reference path="db-bunsqlite/src/OINODbBunSqlite.d.ts
14
- /// <reference path="db-mariadb/src/OINODbMariadb.d.ts
15
- /// <reference path="db-mssql/src/OINODbMsSql.d.ts
16
- /// <reference path="db-postgresql/src/OINODbPostgresql.d.ts
2
+ /// <reference path="db-bunsqlite/src/index.d.ts
3
+ /// <reference path="db-mariadb/src/index.d.ts
4
+ /// <reference path="db-mssql/src/index.d.ts
5
+ /// <reference path="db-postgresql/src/index.d.ts
17
6
  /// <reference path="hashid/src/OINOHashid.d.ts
18
7
  /// <reference path="common/src/index.d.ts
19
- /// <reference path="common/src/OINOBenchmark.d.ts
20
- /// <reference path="common/src/OINOHtmlTemplate.d.ts
21
- /// <reference path="common/src/OINOLog.d.ts
22
- /// <reference path="common/src/OINOResult.d.ts
23
- /// <reference path="common/src/OINOStr.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/types",
3
- "version": "0.17.5",
3
+ "version": "0.19.0",
4
4
  "description": "OINO TS package for types.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",