@opra/client 1.20.0 → 1.22.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.
- package/browser.js +21 -0
- package/{esm/core → core}/backend.js +1 -0
- package/{esm/core → core}/client-error.js +3 -0
- package/{esm/http → http}/fetch-backend.js +2 -0
- package/{esm/http → http}/http-backend.js +2 -0
- package/{esm/http → http}/http-interceptor-handler.js +2 -0
- package/http/http-response.js +51 -0
- package/package.json +15 -31
- package/browser/index.cjs +0 -21
- package/browser/index.mjs +0 -21
- package/cjs/constants.js +0 -6
- package/cjs/core/backend.js +0 -9
- package/cjs/core/client-error.js +0 -17
- package/cjs/http/enums/http-observable-type.enum.js +0 -10
- package/cjs/http/fetch-backend.js +0 -233
- package/cjs/http/http-backend.js +0 -18
- package/cjs/http/http-client-base.js +0 -104
- package/cjs/http/http-client.js +0 -19
- package/cjs/http/http-fetch-client.js +0 -19
- package/cjs/http/http-interceptor-handler.js +0 -18
- package/cjs/http/http-request-observable.js +0 -137
- package/cjs/http/http-response.js +0 -27
- package/cjs/http/http-utils.js +0 -11
- package/cjs/http/interfaces/http-event.js +0 -34
- package/cjs/http/interfaces/http-handler.js +0 -2
- package/cjs/http/interfaces/http-interceptor.js +0 -2
- package/cjs/index.js +0 -21
- package/cjs/package.json +0 -3
- package/esm/batch-request.js +0 -90
- package/esm/http/http-response.js +0 -23
- package/esm/package.json +0 -3
- package/types/index.d.cts +0 -14
- /package/{types/batch-request.d.ts → batch-request.d.ts} +0 -0
- /package/{cjs/batch-request.js → batch-request.js} +0 -0
- /package/{types/constants.d.ts → constants.d.ts} +0 -0
- /package/{esm/constants.js → constants.js} +0 -0
- /package/{types/core → core}/backend.d.ts +0 -0
- /package/{types/core → core}/client-error.d.ts +0 -0
- /package/{types/http → http}/enums/http-observable-type.enum.d.ts +0 -0
- /package/{esm/http → http}/enums/http-observable-type.enum.js +0 -0
- /package/{types/http → http}/fetch-backend.d.ts +0 -0
- /package/{types/http → http}/http-backend.d.ts +0 -0
- /package/{types/http → http}/http-client-base.d.ts +0 -0
- /package/{esm/http → http}/http-client-base.js +0 -0
- /package/{types/http → http}/http-client.d.ts +0 -0
- /package/{esm/http → http}/http-client.js +0 -0
- /package/{types/http → http}/http-fetch-client.d.ts +0 -0
- /package/{esm/http → http}/http-fetch-client.js +0 -0
- /package/{types/http → http}/http-interceptor-handler.d.ts +0 -0
- /package/{types/http → http}/http-request-observable.d.ts +0 -0
- /package/{esm/http → http}/http-request-observable.js +0 -0
- /package/{types/http → http}/http-response.d.ts +0 -0
- /package/{types/http → http}/http-utils.d.ts +0 -0
- /package/{esm/http → http}/http-utils.js +0 -0
- /package/{types/http → http}/interfaces/http-event.d.ts +0 -0
- /package/{esm/http → http}/interfaces/http-event.js +0 -0
- /package/{types/http → http}/interfaces/http-handler.d.ts +0 -0
- /package/{esm/http → http}/interfaces/http-handler.js +0 -0
- /package/{types/http → http}/interfaces/http-interceptor.d.ts +0 -0
- /package/{esm/http → http}/interfaces/http-interceptor.js +0 -0
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
package/esm/batch-request.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { BatchMultipart } from '@opra/common';
|
|
3
|
-
// import { HttpRequestHost } from '../http-request-host.js';
|
|
4
|
-
// import { HttpResponse } from '../http-response.js';
|
|
5
|
-
// import { CommonHttpRequestOptions, HttpRequestHandler, RawHttpRequest } from '../http-types.js';
|
|
6
|
-
//
|
|
7
|
-
// export class BatchRequest extends HttpRequestHost {
|
|
8
|
-
//
|
|
9
|
-
// protected _results = new WeakMap<HttpRequestHost, { error?: Error, response?: HttpResponse }>();
|
|
10
|
-
// protected _listeners = new Set<((error: Error | undefined, response?: HttpResponse) => void)>();
|
|
11
|
-
//
|
|
12
|
-
// constructor(
|
|
13
|
-
// protected _handler: HttpRequestHandler,
|
|
14
|
-
// readonly requests: HttpRequestHost[],
|
|
15
|
-
// public options: CommonHttpRequestOptions = {}
|
|
16
|
-
// ) {
|
|
17
|
-
// super(_handler, options);
|
|
18
|
-
//
|
|
19
|
-
// requests.forEach(request => {
|
|
20
|
-
// // Overwrite the _execute method
|
|
21
|
-
// Object.defineProperty(request, '_execute', {
|
|
22
|
-
// writable: true,
|
|
23
|
-
// enumerable: false,
|
|
24
|
-
// configurable: true,
|
|
25
|
-
// value: () => {
|
|
26
|
-
// return new Promise((resolve, reject) => {
|
|
27
|
-
// const x = this._results.get(request);
|
|
28
|
-
// if (x) {
|
|
29
|
-
// if (x.error)
|
|
30
|
-
// return reject(x.error);
|
|
31
|
-
// return resolve(x.response);
|
|
32
|
-
// }
|
|
33
|
-
// const callback = (error, response) => {
|
|
34
|
-
// this._listeners.delete(callback);
|
|
35
|
-
// if (error)
|
|
36
|
-
// return reject(error);
|
|
37
|
-
// resolve(response);
|
|
38
|
-
// };
|
|
39
|
-
// this._listeners.add(callback);
|
|
40
|
-
// })
|
|
41
|
-
// }
|
|
42
|
-
// })
|
|
43
|
-
// });
|
|
44
|
-
// }
|
|
45
|
-
//
|
|
46
|
-
// prepare(): RawHttpRequest {
|
|
47
|
-
// const batch = this._buildBatchMultipart(this);
|
|
48
|
-
// const headers = {
|
|
49
|
-
// 'content-type': 'multipart/mixed;boundary=' + batch.boundary
|
|
50
|
-
// }
|
|
51
|
-
// return mergeRawHttpRequests({
|
|
52
|
-
// method: 'POST',
|
|
53
|
-
// path: '/$batch',
|
|
54
|
-
// headers,
|
|
55
|
-
// body: batch.stream()
|
|
56
|
-
// },
|
|
57
|
-
// this.options.http
|
|
58
|
-
// );
|
|
59
|
-
// }
|
|
60
|
-
//
|
|
61
|
-
// protected _buildBatchMultipart(batch: BatchRequest): BatchMultipart {
|
|
62
|
-
// const multipart = new BatchMultipart();
|
|
63
|
-
//
|
|
64
|
-
// for (const req of batch.requests) {
|
|
65
|
-
// const prepared = req.prepare();
|
|
66
|
-
//
|
|
67
|
-
// if (req instanceof BatchRequest) {
|
|
68
|
-
// const subMultipart = this._buildBatchMultipart(req);
|
|
69
|
-
// multipart.addBatch(subMultipart);
|
|
70
|
-
// continue;
|
|
71
|
-
// }
|
|
72
|
-
//
|
|
73
|
-
// multipart.addRequestPart({
|
|
74
|
-
// method: prepared.method,
|
|
75
|
-
// url: prepared.path,
|
|
76
|
-
// headers: prepared.headers,
|
|
77
|
-
// data: prepared.body
|
|
78
|
-
// });
|
|
79
|
-
// }
|
|
80
|
-
//
|
|
81
|
-
// return multipart;
|
|
82
|
-
// }
|
|
83
|
-
//
|
|
84
|
-
// protected async _execute(): Promise<HttpResponse> {
|
|
85
|
-
// const req = this.prepare();
|
|
86
|
-
// const resp = await this._handler(req) as HttpResponse;
|
|
87
|
-
// return resp;
|
|
88
|
-
// }
|
|
89
|
-
//
|
|
90
|
-
// }
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
|
-
export class HttpResponse {
|
|
3
|
-
constructor(init) {
|
|
4
|
-
/**
|
|
5
|
-
* Returns true if response has body to be received
|
|
6
|
-
*/
|
|
7
|
-
this.hasBody = false;
|
|
8
|
-
this.headers =
|
|
9
|
-
init?.headers instanceof Headers
|
|
10
|
-
? init?.headers
|
|
11
|
-
: new Headers(init?.headers);
|
|
12
|
-
this.status = init?.status || 200;
|
|
13
|
-
this.statusText = init?.statusText || 'OK';
|
|
14
|
-
this.url = init?.url || null;
|
|
15
|
-
this.ok = this.status >= 200 && this.status < 300;
|
|
16
|
-
this.body = init?.body;
|
|
17
|
-
this.hasBody = init?.body != null || !!init?.hasBody;
|
|
18
|
-
this.contentType = (this.headers.get('content-type') || '').split(';')[0];
|
|
19
|
-
}
|
|
20
|
-
clone(update) {
|
|
21
|
-
return new HttpResponse({ ...this, ...update });
|
|
22
|
-
}
|
|
23
|
-
}
|
package/esm/package.json
DELETED
package/types/index.d.cts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { kBackend, kClient, kContext } from './constants.js';
|
|
2
|
-
export * from './core/backend.js';
|
|
3
|
-
export * from './core/client-error.js';
|
|
4
|
-
export * from './http/enums/http-observable-type.enum.js';
|
|
5
|
-
export * from './http/fetch-backend.js';
|
|
6
|
-
export * from './http/http-backend.js';
|
|
7
|
-
export * from './http/http-client.js';
|
|
8
|
-
export * from './http/http-client-base.js';
|
|
9
|
-
export * from './http/http-request-observable.js';
|
|
10
|
-
export * from './http/http-response.js';
|
|
11
|
-
export * from './http/http-utils.js';
|
|
12
|
-
export * from './http/interfaces/http-event.js';
|
|
13
|
-
export * from './http/interfaces/http-handler.js';
|
|
14
|
-
export * from './http/interfaces/http-interceptor.js';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|