@opra/client 0.18.4 → 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.
- package/browser.js +44 -28
- package/cjs/http/http-client.js +16 -16
- package/esm/http/http-client.js +16 -16
- package/package.json +3 -3
- package/types/http/http-client.d.ts +2 -2
- package/types/http/http-types.d.ts +2 -2
package/browser.js
CHANGED
|
@@ -8,6 +8,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
8
8
|
|
|
9
9
|
// ../../build/client/esm/client-error.js
|
|
10
10
|
var ClientError = class extends Error {
|
|
11
|
+
static {
|
|
12
|
+
__name(this, "ClientError");
|
|
13
|
+
}
|
|
11
14
|
constructor(init, cause) {
|
|
12
15
|
super(init.message);
|
|
13
16
|
this.cause = cause;
|
|
@@ -20,7 +23,6 @@ var ClientError = class extends Error {
|
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
};
|
|
23
|
-
__name(ClientError, "ClientError");
|
|
24
26
|
|
|
25
27
|
// ../../build/client/esm/http/http-client.js
|
|
26
28
|
import { lastValueFrom as lastValueFrom2, Observable as Observable2 } from "rxjs";
|
|
@@ -51,7 +53,10 @@ var directCopyProperties = [
|
|
|
51
53
|
"referrer",
|
|
52
54
|
"referrerPolicy"
|
|
53
55
|
];
|
|
54
|
-
var HttpRequest = class {
|
|
56
|
+
var HttpRequest = class _HttpRequest {
|
|
57
|
+
static {
|
|
58
|
+
__name(this, "HttpRequest");
|
|
59
|
+
}
|
|
55
60
|
constructor(init) {
|
|
56
61
|
this.cache = init?.cache || "default";
|
|
57
62
|
this.credentials = init?.credentials || "same-origin";
|
|
@@ -87,7 +92,7 @@ var HttpRequest = class {
|
|
|
87
92
|
return this.urlInstance.path;
|
|
88
93
|
}
|
|
89
94
|
clone(...update) {
|
|
90
|
-
const out = new
|
|
95
|
+
const out = new _HttpRequest();
|
|
91
96
|
out.merge(this);
|
|
92
97
|
for (const upd of update) {
|
|
93
98
|
out.merge(upd);
|
|
@@ -125,11 +130,13 @@ var HttpRequest = class {
|
|
|
125
130
|
}
|
|
126
131
|
}
|
|
127
132
|
};
|
|
128
|
-
__name(HttpRequest, "HttpRequest");
|
|
129
133
|
|
|
130
134
|
// ../../build/client/esm/http/http-request-observable.js
|
|
131
135
|
var kRequest = Symbol("kRequest");
|
|
132
136
|
var HttpRequestObservable = class extends Observable {
|
|
137
|
+
static {
|
|
138
|
+
__name(this, "HttpRequestObservable");
|
|
139
|
+
}
|
|
133
140
|
constructor(context, options) {
|
|
134
141
|
super((subscriber) => {
|
|
135
142
|
context.send(options?.observe || "body", this[kRequest]).subscribe(subscriber);
|
|
@@ -154,12 +161,14 @@ var HttpRequestObservable = class extends Observable {
|
|
|
154
161
|
return this;
|
|
155
162
|
}
|
|
156
163
|
};
|
|
157
|
-
__name(HttpRequestObservable, "HttpRequestObservable");
|
|
158
164
|
HttpRequestObservable.kContext = kHttpClientContext;
|
|
159
165
|
HttpRequestObservable.kRequest = kRequest;
|
|
160
166
|
|
|
161
167
|
// ../../build/client/esm/http/http-collection-node.js
|
|
162
168
|
var HttpCollectionNode = class {
|
|
169
|
+
static {
|
|
170
|
+
__name(this, "HttpCollectionNode");
|
|
171
|
+
}
|
|
163
172
|
constructor(context) {
|
|
164
173
|
this[kHttpClientContext] = context;
|
|
165
174
|
}
|
|
@@ -263,11 +272,13 @@ var HttpCollectionNode = class {
|
|
|
263
272
|
return requestHost;
|
|
264
273
|
}
|
|
265
274
|
};
|
|
266
|
-
__name(HttpCollectionNode, "HttpCollectionNode");
|
|
267
275
|
|
|
268
276
|
// ../../build/client/esm/http/http-response.js
|
|
269
277
|
import { HttpHeaders as HttpHeaders2 } from "@opra/common";
|
|
270
|
-
var HttpResponse = class {
|
|
278
|
+
var HttpResponse = class _HttpResponse {
|
|
279
|
+
static {
|
|
280
|
+
__name(this, "HttpResponse");
|
|
281
|
+
}
|
|
271
282
|
constructor(init) {
|
|
272
283
|
this.hasBody = false;
|
|
273
284
|
this.headers = new HttpHeaders2(init?.headers);
|
|
@@ -280,13 +291,15 @@ var HttpResponse = class {
|
|
|
280
291
|
this.totalMatches = init?.totalMatches;
|
|
281
292
|
}
|
|
282
293
|
clone(update) {
|
|
283
|
-
return new
|
|
294
|
+
return new _HttpResponse({ ...this, ...update });
|
|
284
295
|
}
|
|
285
296
|
};
|
|
286
|
-
__name(HttpResponse, "HttpResponse");
|
|
287
297
|
|
|
288
298
|
// ../../build/client/esm/http/http-singleton-node.js
|
|
289
299
|
var HttpSingletonNode = class {
|
|
300
|
+
static {
|
|
301
|
+
__name(this, "HttpSingletonNode");
|
|
302
|
+
}
|
|
290
303
|
constructor(context) {
|
|
291
304
|
this[kHttpClientContext] = context;
|
|
292
305
|
}
|
|
@@ -343,11 +356,13 @@ var HttpSingletonNode = class {
|
|
|
343
356
|
return requestHost;
|
|
344
357
|
}
|
|
345
358
|
};
|
|
346
|
-
__name(HttpSingletonNode, "HttpSingletonNode");
|
|
347
359
|
|
|
348
360
|
// ../../build/client/esm/http/http-client.js
|
|
349
361
|
var kAssets = Symbol("kAssets");
|
|
350
362
|
var OpraHttpClient = class {
|
|
363
|
+
static {
|
|
364
|
+
__name(this, "OpraHttpClient");
|
|
365
|
+
}
|
|
351
366
|
constructor(serviceUrl, options) {
|
|
352
367
|
Object.defineProperty(this, kAssets, {
|
|
353
368
|
enumerable: false,
|
|
@@ -399,13 +414,13 @@ var OpraHttpClient = class {
|
|
|
399
414
|
client: this,
|
|
400
415
|
resourceName,
|
|
401
416
|
send: (observe, request) => this._sendRequest(observe, request, ctx),
|
|
402
|
-
requestInterceptors: [
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
],
|
|
417
|
+
// requestInterceptors: [
|
|
418
|
+
// // Validate resource exists and is a collection resource
|
|
419
|
+
// async () => {
|
|
420
|
+
// const metadata = await this.getMetadata();
|
|
421
|
+
// metadata.getCollection(ctx.resourceName);
|
|
422
|
+
// }
|
|
423
|
+
// ],
|
|
409
424
|
responseInterceptors: []
|
|
410
425
|
};
|
|
411
426
|
return new HttpCollectionNode(ctx);
|
|
@@ -417,13 +432,13 @@ var OpraHttpClient = class {
|
|
|
417
432
|
client: this,
|
|
418
433
|
resourceName,
|
|
419
434
|
send: (observe, request) => this._sendRequest(observe, request, ctx),
|
|
420
|
-
requestInterceptors: [
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
],
|
|
435
|
+
// requestInterceptors: [
|
|
436
|
+
// // Validate resource exists and is a singleton resource
|
|
437
|
+
// async () => {
|
|
438
|
+
// const metadata = await this.getMetadata();
|
|
439
|
+
// metadata.getSingleton(ctx.resourceName);
|
|
440
|
+
// }
|
|
441
|
+
// ],
|
|
427
442
|
responseInterceptors: []
|
|
428
443
|
};
|
|
429
444
|
return new HttpSingletonNode(ctx);
|
|
@@ -468,7 +483,7 @@ var OpraHttpClient = class {
|
|
|
468
483
|
if (ctx) {
|
|
469
484
|
const requestInterceptors = [
|
|
470
485
|
...this[kAssets].requestInterceptors,
|
|
471
|
-
...ctx.requestInterceptors
|
|
486
|
+
...ctx.requestInterceptors || []
|
|
472
487
|
];
|
|
473
488
|
for (const interceptor of requestInterceptors) {
|
|
474
489
|
await interceptor(ctx, request);
|
|
@@ -537,7 +552,7 @@ var OpraHttpClient = class {
|
|
|
537
552
|
if (ctx) {
|
|
538
553
|
const responseInterceptors = [
|
|
539
554
|
...this[kAssets].responseInterceptors,
|
|
540
|
-
...ctx.responseInterceptors
|
|
555
|
+
...ctx.responseInterceptors || []
|
|
541
556
|
];
|
|
542
557
|
for (const interceptor of responseInterceptors) {
|
|
543
558
|
await interceptor(ctx, observe, request);
|
|
@@ -554,16 +569,17 @@ var OpraHttpClient = class {
|
|
|
554
569
|
subscriber.complete();
|
|
555
570
|
}
|
|
556
571
|
};
|
|
557
|
-
__name(OpraHttpClient, "OpraHttpClient");
|
|
558
572
|
OpraHttpClient.kAssets = kAssets;
|
|
559
573
|
|
|
560
574
|
// ../../build/client/esm/http/http-service-base.js
|
|
561
575
|
var HttpServiceBase = class {
|
|
576
|
+
static {
|
|
577
|
+
__name(this, "HttpServiceBase");
|
|
578
|
+
}
|
|
562
579
|
constructor($client) {
|
|
563
580
|
this.$client = $client;
|
|
564
581
|
}
|
|
565
582
|
};
|
|
566
|
-
__name(HttpServiceBase, "HttpServiceBase");
|
|
567
583
|
export {
|
|
568
584
|
ClientError,
|
|
569
585
|
HttpCollectionNode,
|
package/cjs/http/http-client.js
CHANGED
|
@@ -69,13 +69,13 @@ class OpraHttpClient {
|
|
|
69
69
|
client: this,
|
|
70
70
|
resourceName,
|
|
71
71
|
send: (observe, request) => this._sendRequest(observe, request, ctx),
|
|
72
|
-
requestInterceptors: [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
],
|
|
72
|
+
// requestInterceptors: [
|
|
73
|
+
// // Validate resource exists and is a collection resource
|
|
74
|
+
// async () => {
|
|
75
|
+
// const metadata = await this.getMetadata();
|
|
76
|
+
// metadata.getCollection(ctx.resourceName);
|
|
77
|
+
// }
|
|
78
|
+
// ],
|
|
79
79
|
responseInterceptors: []
|
|
80
80
|
};
|
|
81
81
|
return new http_collection_node_js_1.HttpCollectionNode(ctx);
|
|
@@ -88,13 +88,13 @@ class OpraHttpClient {
|
|
|
88
88
|
client: this,
|
|
89
89
|
resourceName,
|
|
90
90
|
send: (observe, request) => this._sendRequest(observe, request, ctx),
|
|
91
|
-
requestInterceptors: [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
],
|
|
91
|
+
// requestInterceptors: [
|
|
92
|
+
// // Validate resource exists and is a singleton resource
|
|
93
|
+
// async () => {
|
|
94
|
+
// const metadata = await this.getMetadata();
|
|
95
|
+
// metadata.getSingleton(ctx.resourceName);
|
|
96
|
+
// }
|
|
97
|
+
// ],
|
|
98
98
|
responseInterceptors: []
|
|
99
99
|
};
|
|
100
100
|
return new http_singleton_node_js_1.HttpSingletonNode(ctx);
|
|
@@ -143,7 +143,7 @@ class OpraHttpClient {
|
|
|
143
143
|
if (ctx) {
|
|
144
144
|
const requestInterceptors = [
|
|
145
145
|
...this[kAssets].requestInterceptors,
|
|
146
|
-
...ctx.requestInterceptors
|
|
146
|
+
...(ctx.requestInterceptors || [])
|
|
147
147
|
];
|
|
148
148
|
for (const interceptor of requestInterceptors) {
|
|
149
149
|
await interceptor(ctx, request);
|
|
@@ -213,7 +213,7 @@ class OpraHttpClient {
|
|
|
213
213
|
if (ctx) {
|
|
214
214
|
const responseInterceptors = [
|
|
215
215
|
...this[kAssets].responseInterceptors,
|
|
216
|
-
...ctx.responseInterceptors
|
|
216
|
+
...(ctx.responseInterceptors || [])
|
|
217
217
|
];
|
|
218
218
|
for (const interceptor of responseInterceptors) {
|
|
219
219
|
await interceptor(ctx, observe, request);
|
package/esm/http/http-client.js
CHANGED
|
@@ -66,13 +66,13 @@ export class OpraHttpClient {
|
|
|
66
66
|
client: this,
|
|
67
67
|
resourceName,
|
|
68
68
|
send: (observe, request) => this._sendRequest(observe, request, ctx),
|
|
69
|
-
requestInterceptors: [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
],
|
|
69
|
+
// requestInterceptors: [
|
|
70
|
+
// // Validate resource exists and is a collection resource
|
|
71
|
+
// async () => {
|
|
72
|
+
// const metadata = await this.getMetadata();
|
|
73
|
+
// metadata.getCollection(ctx.resourceName);
|
|
74
|
+
// }
|
|
75
|
+
// ],
|
|
76
76
|
responseInterceptors: []
|
|
77
77
|
};
|
|
78
78
|
return new HttpCollectionNode(ctx);
|
|
@@ -85,13 +85,13 @@ export class OpraHttpClient {
|
|
|
85
85
|
client: this,
|
|
86
86
|
resourceName,
|
|
87
87
|
send: (observe, request) => this._sendRequest(observe, request, ctx),
|
|
88
|
-
requestInterceptors: [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
],
|
|
88
|
+
// requestInterceptors: [
|
|
89
|
+
// // Validate resource exists and is a singleton resource
|
|
90
|
+
// async () => {
|
|
91
|
+
// const metadata = await this.getMetadata();
|
|
92
|
+
// metadata.getSingleton(ctx.resourceName);
|
|
93
|
+
// }
|
|
94
|
+
// ],
|
|
95
95
|
responseInterceptors: []
|
|
96
96
|
};
|
|
97
97
|
return new HttpSingletonNode(ctx);
|
|
@@ -140,7 +140,7 @@ export class OpraHttpClient {
|
|
|
140
140
|
if (ctx) {
|
|
141
141
|
const requestInterceptors = [
|
|
142
142
|
...this[kAssets].requestInterceptors,
|
|
143
|
-
...ctx.requestInterceptors
|
|
143
|
+
...(ctx.requestInterceptors || [])
|
|
144
144
|
];
|
|
145
145
|
for (const interceptor of requestInterceptors) {
|
|
146
146
|
await interceptor(ctx, request);
|
|
@@ -210,7 +210,7 @@ export class OpraHttpClient {
|
|
|
210
210
|
if (ctx) {
|
|
211
211
|
const responseInterceptors = [
|
|
212
212
|
...this[kAssets].responseInterceptors,
|
|
213
|
-
...ctx.responseInterceptors
|
|
213
|
+
...(ctx.responseInterceptors || [])
|
|
214
214
|
];
|
|
215
215
|
for (const interceptor of responseInterceptors) {
|
|
216
216
|
await interceptor(ctx, observe, request);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Opra Client package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"@browsery/i18next": "^0.5.0",
|
|
47
47
|
"@browsery/stream": "^0.4.0",
|
|
48
48
|
"@browsery/util": "^0.4.0",
|
|
49
|
-
"@opra/common": "^0.
|
|
49
|
+
"@opra/common": "^0.19.0",
|
|
50
50
|
"accepts": "^1.3.8",
|
|
51
51
|
"buffer": "^6.0.3",
|
|
52
52
|
"cookie": "^0.5.0",
|
|
53
53
|
"crypto-browserify": "^3.12.0",
|
|
54
|
-
"dayjs": "^1.11.
|
|
54
|
+
"dayjs": "^1.11.8",
|
|
55
55
|
"encodeurl": "^1.0.2",
|
|
56
56
|
"events": "^3.3.0",
|
|
57
57
|
"fast-tokenizer": "^1.2.2",
|
|
@@ -8,8 +8,8 @@ import { HttpSingletonNode } from './http-singleton-node.js';
|
|
|
8
8
|
import { HttpClientContext, HttpEvent, HttpRequestDefaults, ObserveType, RequestInterceptor, ResponseInterceptor } from './http-types.js';
|
|
9
9
|
export interface OpraHttpClientOptions {
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Opra Service Metadata Document
|
|
12
|
+
*/
|
|
13
13
|
api?: ApiDocument;
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
@@ -12,8 +12,8 @@ export interface HttpClientContext {
|
|
|
12
12
|
readonly client: OpraHttpClient;
|
|
13
13
|
readonly resourceName: string;
|
|
14
14
|
send: HttpRequestHandler;
|
|
15
|
-
requestInterceptors
|
|
16
|
-
responseInterceptors
|
|
15
|
+
requestInterceptors?: RequestInterceptor[];
|
|
16
|
+
responseInterceptors?: ResponseInterceptor[];
|
|
17
17
|
}
|
|
18
18
|
export type HttpRequestDefaults = Partial<Pick<HttpRequest, 'cache' | 'credentials' | 'destination' | 'integrity' | 'keepalive' | 'mode' | 'redirect' | 'referrer' | 'referrerPolicy'>> & {
|
|
19
19
|
headers?: HttpHeaders.Initiator;
|