gingersnap 0.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/_virtual/_tslib.cjs +102 -0
- package/_virtual/_tslib.mjs +93 -0
- package/data/AtomicValue.d.ts +15 -0
- package/data/bus.cjs +179 -0
- package/data/bus.d.ts +72 -0
- package/data/bus.mjs +177 -0
- package/data/decoders/index.d.ts +4 -0
- package/data/decoders/json.cjs +12 -0
- package/data/decoders/json.d.ts +7 -0
- package/data/decoders/json.mjs +10 -0
- package/data/decoders/msgpack.cjs +14 -0
- package/data/decoders/msgpack.d.ts +7 -0
- package/data/decoders/msgpack.mjs +12 -0
- package/data/decoders/protobuf.d.ts +13 -0
- package/data/decoders/string.cjs +12 -0
- package/data/decoders/string.d.ts +7 -0
- package/data/decoders/string.mjs +10 -0
- package/data/decoders/type.d.ts +7 -0
- package/data/decoders.cjs +11 -0
- package/data/decoders.mjs +3 -0
- package/data/model/credentials.cjs +114 -0
- package/data/model/credentials.d.ts +61 -0
- package/data/model/credentials.mjs +109 -0
- package/data/model/extra.cjs +88 -0
- package/data/model/extra.d.ts +5 -0
- package/data/model/extra.mjs +66 -0
- package/data/model/index.d.ts +6 -0
- package/data/model/model.cjs +541 -0
- package/data/model/model.d.ts +207 -0
- package/data/model/model.mjs +518 -0
- package/data/model/plugin.cjs +96 -0
- package/data/model/plugin.d.ts +38 -0
- package/data/model/plugin.mjs +72 -0
- package/data/model/property.cjs +310 -0
- package/data/model/property.d.ts +83 -0
- package/data/model/property.mjs +278 -0
- package/data/model/types.cjs +32 -0
- package/data/model/types.d.ts +28 -0
- package/data/model/types.mjs +32 -0
- package/data/model.cjs +43 -0
- package/data/model.mjs +6 -0
- package/data/signal.cjs +47 -0
- package/data/signal.d.ts +17 -0
- package/data/signal.mjs +45 -0
- package/data/store/index.d.ts +4 -0
- package/data/store/json.cjs +58 -0
- package/data/store/json.d.ts +18 -0
- package/data/store/json.mjs +56 -0
- package/data/store/manager.cjs +206 -0
- package/data/store/manager.d.ts +44 -0
- package/data/store/manager.mjs +203 -0
- package/data/store/web.cjs +92 -0
- package/data/store/web.d.ts +25 -0
- package/data/store/web.mjs +89 -0
- package/data/value.cjs +66 -0
- package/data/value.mjs +64 -0
- package/data-structures/array/CyclicalList.cjs +57 -0
- package/data-structures/array/CyclicalList.d.ts +12 -0
- package/data-structures/array/CyclicalList.mjs +55 -0
- package/data-structures/array/Pair.cjs +30 -0
- package/data-structures/array/Pair.d.ts +17 -0
- package/data-structures/array/Pair.mjs +27 -0
- package/data-structures/array/Stack.cjs +96 -0
- package/data-structures/array/Stack.d.ts +41 -0
- package/data-structures/array/Stack.mjs +94 -0
- package/data-structures/array/Triple.cjs +34 -0
- package/data-structures/array/Triple.d.ts +19 -0
- package/data-structures/array/Triple.mjs +31 -0
- package/data-structures/array/Tuple.d.ts +8 -0
- package/data-structures/array/index.d.ts +5 -0
- package/data-structures/array.cjs +15 -0
- package/data-structures/array.mjs +4 -0
- package/data-structures/object/BufferQueue.cjs +98 -0
- package/data-structures/object/BufferQueue.d.ts +21 -0
- package/data-structures/object/BufferQueue.mjs +77 -0
- package/data-structures/object/CyclicalObject.cjs +155 -0
- package/data-structures/object/CyclicalObject.d.ts +74 -0
- package/data-structures/object/CyclicalObject.mjs +134 -0
- package/data-structures/object/Queue.cjs +178 -0
- package/data-structures/object/Queue.d.ts +31 -0
- package/data-structures/object/Queue.mjs +176 -0
- package/data-structures/object/SimpleQueue.cjs +53 -0
- package/data-structures/object/SimpleQueue.d.ts +13 -0
- package/data-structures/object/SimpleQueue.mjs +51 -0
- package/data-structures/object/TimeableObject.cjs +73 -0
- package/data-structures/object/TimeableObject.d.ts +30 -0
- package/data-structures/object/TimeableObject.mjs +71 -0
- package/data-structures/object/WaitableObject.cjs +61 -0
- package/data-structures/object/WaitableObject.d.ts +29 -0
- package/data-structures/object/WaitableObject.mjs +59 -0
- package/data-structures/object/WatchableObject.cjs +251 -0
- package/data-structures/object/WatchableObject.d.ts +88 -0
- package/data-structures/object/WatchableObject.mjs +230 -0
- package/data-structures/object/index.d.ts +7 -0
- package/data-structures/object.cjs +23 -0
- package/data-structures/object.mjs +7 -0
- package/errors/AbortError.cjs +9 -0
- package/errors/AbortError.d.ts +5 -0
- package/errors/AbortError.mjs +7 -0
- package/errors/CallExecutionError.cjs +13 -0
- package/errors/CallExecutionError.d.ts +7 -0
- package/errors/CallExecutionError.mjs +11 -0
- package/errors/FutureCancelled.cjs +11 -0
- package/errors/FutureCancelled.d.ts +6 -0
- package/errors/FutureCancelled.mjs +9 -0
- package/errors/FutureError.cjs +11 -0
- package/errors/FutureError.d.ts +6 -0
- package/errors/FutureError.mjs +9 -0
- package/errors/IllegalArgumentsError.cjs +13 -0
- package/errors/IllegalArgumentsError.d.ts +7 -0
- package/errors/IllegalArgumentsError.mjs +11 -0
- package/errors/IllegalOperationError.cjs +6 -0
- package/errors/IllegalOperationError.d.ts +2 -0
- package/errors/IllegalOperationError.mjs +4 -0
- package/errors/InvalidType.cjs +6 -0
- package/errors/InvalidType.d.ts +2 -0
- package/errors/InvalidType.mjs +4 -0
- package/errors/InvalidValue.cjs +11 -0
- package/errors/InvalidValue.d.ts +4 -0
- package/errors/InvalidValue.mjs +9 -0
- package/errors/MissingArgumentsError.cjs +13 -0
- package/errors/MissingArgumentsError.d.ts +7 -0
- package/errors/MissingArgumentsError.mjs +11 -0
- package/errors/NetworkError.cjs +13 -0
- package/errors/NetworkError.d.ts +8 -0
- package/errors/NetworkError.mjs +11 -0
- package/errors/NoSuchElement.cjs +6 -0
- package/errors/NoSuchElement.d.ts +2 -0
- package/errors/NoSuchElement.mjs +4 -0
- package/errors/NotImplemented.cjs +9 -0
- package/errors/NotImplemented.d.ts +5 -0
- package/errors/NotImplemented.mjs +7 -0
- package/errors/ParsingError.cjs +10 -0
- package/errors/ParsingError.d.ts +5 -0
- package/errors/ParsingError.mjs +8 -0
- package/errors/QueueEmptyError.cjs +6 -0
- package/errors/QueueEmptyError.d.ts +2 -0
- package/errors/QueueEmptyError.mjs +4 -0
- package/errors/QueueFullError.cjs +6 -0
- package/errors/QueueFullError.d.ts +2 -0
- package/errors/QueueFullError.mjs +4 -0
- package/errors/StackEmptyError.cjs +6 -0
- package/errors/StackEmptyError.d.ts +2 -0
- package/errors/StackEmptyError.mjs +4 -0
- package/errors/StackFullError.cjs +6 -0
- package/errors/StackFullError.d.ts +2 -0
- package/errors/StackFullError.mjs +4 -0
- package/errors/StreamEnded.cjs +6 -0
- package/errors/StreamEnded.d.ts +2 -0
- package/errors/StreamEnded.mjs +4 -0
- package/errors/TimeoutError.cjs +11 -0
- package/errors/TimeoutError.d.ts +6 -0
- package/errors/TimeoutError.mjs +9 -0
- package/errors/ValueDestroyedError.cjs +6 -0
- package/errors/ValueDestroyedError.d.ts +2 -0
- package/errors/ValueDestroyedError.mjs +4 -0
- package/errors/VerificationError.cjs +9 -0
- package/errors/VerificationError.d.ts +5 -0
- package/errors/VerificationError.mjs +7 -0
- package/errors/index.d.ts +18 -0
- package/errors.cjs +41 -0
- package/errors.mjs +18 -0
- package/files.cjs +201 -0
- package/files.d.ts +31 -0
- package/files.mjs +180 -0
- package/functools/index.d.ts +31 -0
- package/functools.cjs +371 -0
- package/functools.mjs +334 -0
- package/future/future.cjs +570 -0
- package/future/future.d.ts +208 -0
- package/future/future.mjs +548 -0
- package/future/group.cjs +180 -0
- package/future/group.d.ts +82 -0
- package/future/group.mjs +159 -0
- package/future/index.d.ts +3 -0
- package/future/result.cjs +19 -0
- package/future/result.d.ts +18 -0
- package/future/result.mjs +17 -0
- package/future.cjs +11 -0
- package/future.mjs +3 -0
- package/managers/context.d.ts +8 -0
- package/managers/index.d.ts +1 -0
- package/managers.cjs +2 -0
- package/managers.mjs +1 -0
- package/mocks.cjs +301 -0
- package/mocks.d.ts +125 -0
- package/mocks.mjs +293 -0
- package/networking/EventSourceService.cjs +104 -0
- package/networking/EventSourceService.d.ts +11 -0
- package/networking/EventSourceService.mjs +83 -0
- package/networking/NetworkService.cjs +394 -0
- package/networking/NetworkService.d.ts +97 -0
- package/networking/NetworkService.mjs +373 -0
- package/networking/SocketService.cjs +218 -0
- package/networking/SocketService.d.ts +23 -0
- package/networking/SocketService.mjs +197 -0
- package/networking/decorators/index.d.ts +4 -0
- package/networking/decorators/options.cjs +289 -0
- package/networking/decorators/options.d.ts +148 -0
- package/networking/decorators/options.mjs +242 -0
- package/networking/decorators/requests.cjs +80 -0
- package/networking/decorators/requests.d.ts +34 -0
- package/networking/decorators/requests.mjs +52 -0
- package/networking/decorators/socket.cjs +81 -0
- package/networking/decorators/socket.d.ts +13 -0
- package/networking/decorators/socket.mjs +51 -0
- package/networking/http.cjs +69 -0
- package/networking/http.d.ts +66 -0
- package/networking/http.mjs +69 -0
- package/networking/index.d.ts +39 -0
- package/networking/request.cjs +18 -0
- package/networking/request.d.ts +9 -0
- package/networking/request.mjs +16 -0
- package/networking/types.cjs +37 -0
- package/networking/types.d.ts +132 -0
- package/networking/types.mjs +35 -0
- package/networking.cjs +91 -0
- package/networking.mjs +33 -0
- package/package.json +1 -0
- package/reflection/injector.cjs +43 -0
- package/reflection/injector.d.ts +3 -0
- package/reflection/injector.mjs +40 -0
- package/socket.cjs +239 -0
- package/socket.d.ts +65 -0
- package/socket.mjs +237 -0
- package/store.cjs +12 -0
- package/store.mjs +3 -0
- package/stream/call.cjs +157 -0
- package/stream/call.d.ts +66 -0
- package/stream/call.mjs +154 -0
- package/stream/collector.cjs +217 -0
- package/stream/collector.d.ts +14 -0
- package/stream/collector.mjs +215 -0
- package/stream/index.d.ts +257 -0
- package/stream/observable.cjs +110 -0
- package/stream/observable.d.ts +65 -0
- package/stream/observable.mjs +106 -0
- package/stream/state.cjs +10 -0
- package/stream/state.d.ts +5 -0
- package/stream/state.mjs +8 -0
- package/stream.cjs +1153 -0
- package/stream.mjs +1132 -0
- package/synchronize.cjs +106 -0
- package/synchronize.d.ts +54 -0
- package/synchronize.mjs +103 -0
- package/typing/types.d.ts +24 -0
- package/typing.cjs +2 -0
- package/typing.mjs +1 -0
- package/utils/parser.cjs +37 -0
- package/utils/parser.d.ts +7 -0
- package/utils/parser.mjs +16 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var msgpack = require('@msgpack/msgpack');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts Blob to JSON object that was packaged using msgpack
|
|
7
|
+
*/
|
|
8
|
+
class MsgpackDecoder {
|
|
9
|
+
decode(data) {
|
|
10
|
+
return msgpack.decode(new Uint8Array(data));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.MsgpackDecoder = MsgpackDecoder;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Decoder } from "./type";
|
|
2
|
+
import { Message, Root, Type } from "protobufjs";
|
|
3
|
+
/**
|
|
4
|
+
* Converts Blob to data that was encoded using protobuf
|
|
5
|
+
*/
|
|
6
|
+
export declare class ProtobufDecoder<T extends Message> implements Decoder<T> {
|
|
7
|
+
private readonly proto;
|
|
8
|
+
private readonly typePath;
|
|
9
|
+
private type;
|
|
10
|
+
constructor(proto: object | Root | Type, typePath: string);
|
|
11
|
+
decode(data: ArrayBuffer): T;
|
|
12
|
+
load(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var string = require('./decoders/string.cjs');
|
|
4
|
+
var json = require('./decoders/json.cjs');
|
|
5
|
+
var msgpack = require('./decoders/msgpack.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.StringDecoder = string.StringDecoder;
|
|
10
|
+
exports.JSONDecoder = json.JSONDecoder;
|
|
11
|
+
exports.MsgpackDecoder = msgpack.MsgpackDecoder;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
4
|
+
var model = require('./model.cjs');
|
|
5
|
+
var property = require('./property.cjs');
|
|
6
|
+
var browserOrNode = require('browser-or-node');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Class that represents credentials used for sending authorized requests
|
|
10
|
+
*/
|
|
11
|
+
class Credentials extends model.Model {
|
|
12
|
+
/**
|
|
13
|
+
* Method for constructing the refresh headers used in a request to retrieve new credentials
|
|
14
|
+
*/
|
|
15
|
+
buildRefreshHeaders() {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Credentials that support JWT
|
|
21
|
+
*/
|
|
22
|
+
class BearerCredentials extends Credentials {
|
|
23
|
+
constructor(accessToken, refreshToken, expirationDate) {
|
|
24
|
+
super();
|
|
25
|
+
this.accessToken = accessToken;
|
|
26
|
+
this.refreshToken = refreshToken;
|
|
27
|
+
this.expirationDate = expirationDate;
|
|
28
|
+
}
|
|
29
|
+
buildAuthHeaders() {
|
|
30
|
+
return {
|
|
31
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
buildRefreshHeaders() {
|
|
35
|
+
var _a;
|
|
36
|
+
return {
|
|
37
|
+
access_token: this.accessToken,
|
|
38
|
+
refresh_token: (_a = this.refreshToken) !== null && _a !== void 0 ? _a : "",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
_tslib.__decorate([
|
|
43
|
+
property.Alias("access_token"),
|
|
44
|
+
property.Field("accessToken"),
|
|
45
|
+
_tslib.__metadata("design:type", String)
|
|
46
|
+
], BearerCredentials.prototype, "accessToken", void 0);
|
|
47
|
+
_tslib.__decorate([
|
|
48
|
+
property.Alias("refresh_token"),
|
|
49
|
+
property.Field("refreshToken"),
|
|
50
|
+
_tslib.__metadata("design:type", String)
|
|
51
|
+
], BearerCredentials.prototype, "refreshToken", void 0);
|
|
52
|
+
_tslib.__decorate([
|
|
53
|
+
property.Ignore(),
|
|
54
|
+
property.Alias("expirationDate"),
|
|
55
|
+
property.Alias("expiration_date"),
|
|
56
|
+
property.Alias("expiryDate"),
|
|
57
|
+
property.Alias("exp"),
|
|
58
|
+
property.Field("expiry_date"),
|
|
59
|
+
_tslib.__metadata("design:type", Date)
|
|
60
|
+
], BearerCredentials.prototype, "expirationDate", void 0);
|
|
61
|
+
/**
|
|
62
|
+
* Credentials for using API service
|
|
63
|
+
*/
|
|
64
|
+
class APIKeyCredentials extends Credentials {
|
|
65
|
+
constructor(apiKey) {
|
|
66
|
+
super();
|
|
67
|
+
this.apiKey = apiKey;
|
|
68
|
+
}
|
|
69
|
+
buildAuthHeaders() {
|
|
70
|
+
return {
|
|
71
|
+
"X-API-Key": this.apiKey,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
_tslib.__decorate([
|
|
76
|
+
property.Alias("api_key"),
|
|
77
|
+
property.Field("apiKey"),
|
|
78
|
+
_tslib.__metadata("design:type", String)
|
|
79
|
+
], APIKeyCredentials.prototype, "apiKey", void 0);
|
|
80
|
+
/**
|
|
81
|
+
* Credentials that is used for username and password authenticated requests
|
|
82
|
+
*/
|
|
83
|
+
class BasicCredentials extends Credentials {
|
|
84
|
+
constructor(username, password) {
|
|
85
|
+
super();
|
|
86
|
+
this.username = username;
|
|
87
|
+
this.password = password;
|
|
88
|
+
}
|
|
89
|
+
buildAuthHeaders() {
|
|
90
|
+
let token;
|
|
91
|
+
if (browserOrNode.isNode) {
|
|
92
|
+
token = Buffer.from(`${this.username}:${this.password}`).toString("base64");
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
token = btoa(`${this.username}:${this.password}`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
Authorization: `Basic ${token}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_tslib.__decorate([
|
|
103
|
+
property.Field("username"),
|
|
104
|
+
_tslib.__metadata("design:type", String)
|
|
105
|
+
], BasicCredentials.prototype, "username", void 0);
|
|
106
|
+
_tslib.__decorate([
|
|
107
|
+
property.Field("password"),
|
|
108
|
+
_tslib.__metadata("design:type", String)
|
|
109
|
+
], BasicCredentials.prototype, "password", void 0);
|
|
110
|
+
|
|
111
|
+
exports.APIKeyCredentials = APIKeyCredentials;
|
|
112
|
+
exports.BasicCredentials = BasicCredentials;
|
|
113
|
+
exports.BearerCredentials = BearerCredentials;
|
|
114
|
+
exports.Credentials = Credentials;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Model } from "./model";
|
|
2
|
+
import { MapOfHeaders } from "../../networking/types";
|
|
3
|
+
/**
|
|
4
|
+
* Class that represents credentials used for sending authorized requests
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class Credentials extends Model {
|
|
7
|
+
/**
|
|
8
|
+
* Abstract method for constructing the authentication headers used in a request
|
|
9
|
+
*/
|
|
10
|
+
abstract buildAuthHeaders(): MapOfHeaders;
|
|
11
|
+
/**
|
|
12
|
+
* Method for constructing the refresh headers used in a request to retrieve new credentials
|
|
13
|
+
*/
|
|
14
|
+
buildRefreshHeaders(): MapOfHeaders;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Credentials that support JWT
|
|
18
|
+
*/
|
|
19
|
+
export declare class BearerCredentials extends Credentials {
|
|
20
|
+
/**
|
|
21
|
+
* JWT access token use for authenticated requests
|
|
22
|
+
*/
|
|
23
|
+
accessToken: string;
|
|
24
|
+
/**
|
|
25
|
+
* JWT refresh token used to retrieve new access token
|
|
26
|
+
*/
|
|
27
|
+
refreshToken?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Expiration date
|
|
30
|
+
*/
|
|
31
|
+
expirationDate?: Date;
|
|
32
|
+
constructor(accessToken: string, refreshToken?: string, expirationDate?: Date);
|
|
33
|
+
buildAuthHeaders(): MapOfHeaders;
|
|
34
|
+
buildRefreshHeaders(): MapOfHeaders;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Credentials for using API service
|
|
38
|
+
*/
|
|
39
|
+
export declare class APIKeyCredentials extends Credentials {
|
|
40
|
+
/**
|
|
41
|
+
* API Key used for authenticated requests
|
|
42
|
+
*/
|
|
43
|
+
apiKey: string;
|
|
44
|
+
constructor(apiKey: string);
|
|
45
|
+
buildAuthHeaders(): MapOfHeaders;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Credentials that is used for username and password authenticated requests
|
|
49
|
+
*/
|
|
50
|
+
export declare class BasicCredentials extends Credentials {
|
|
51
|
+
/**
|
|
52
|
+
* Username for the authenticated user
|
|
53
|
+
*/
|
|
54
|
+
username: string;
|
|
55
|
+
/**
|
|
56
|
+
* Password for the authenticated user
|
|
57
|
+
*/
|
|
58
|
+
password: string;
|
|
59
|
+
constructor(username: string, password: string);
|
|
60
|
+
buildAuthHeaders(): MapOfHeaders;
|
|
61
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { __decorate, __metadata } from '../../_virtual/_tslib.mjs';
|
|
2
|
+
import { Model } from './model.mjs';
|
|
3
|
+
import { Alias, Field, Ignore } from './property.mjs';
|
|
4
|
+
import { isNode } from 'browser-or-node';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class that represents credentials used for sending authorized requests
|
|
8
|
+
*/
|
|
9
|
+
class Credentials extends Model {
|
|
10
|
+
/**
|
|
11
|
+
* Method for constructing the refresh headers used in a request to retrieve new credentials
|
|
12
|
+
*/
|
|
13
|
+
buildRefreshHeaders() {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Credentials that support JWT
|
|
19
|
+
*/
|
|
20
|
+
class BearerCredentials extends Credentials {
|
|
21
|
+
constructor(accessToken, refreshToken, expirationDate) {
|
|
22
|
+
super();
|
|
23
|
+
this.accessToken = accessToken;
|
|
24
|
+
this.refreshToken = refreshToken;
|
|
25
|
+
this.expirationDate = expirationDate;
|
|
26
|
+
}
|
|
27
|
+
buildAuthHeaders() {
|
|
28
|
+
return {
|
|
29
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
buildRefreshHeaders() {
|
|
33
|
+
var _a;
|
|
34
|
+
return {
|
|
35
|
+
access_token: this.accessToken,
|
|
36
|
+
refresh_token: (_a = this.refreshToken) !== null && _a !== void 0 ? _a : "",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
__decorate([
|
|
41
|
+
Alias("access_token"),
|
|
42
|
+
Field("accessToken"),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], BearerCredentials.prototype, "accessToken", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
Alias("refresh_token"),
|
|
47
|
+
Field("refreshToken"),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], BearerCredentials.prototype, "refreshToken", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
Ignore(),
|
|
52
|
+
Alias("expirationDate"),
|
|
53
|
+
Alias("expiration_date"),
|
|
54
|
+
Alias("expiryDate"),
|
|
55
|
+
Alias("exp"),
|
|
56
|
+
Field("expiry_date"),
|
|
57
|
+
__metadata("design:type", Date)
|
|
58
|
+
], BearerCredentials.prototype, "expirationDate", void 0);
|
|
59
|
+
/**
|
|
60
|
+
* Credentials for using API service
|
|
61
|
+
*/
|
|
62
|
+
class APIKeyCredentials extends Credentials {
|
|
63
|
+
constructor(apiKey) {
|
|
64
|
+
super();
|
|
65
|
+
this.apiKey = apiKey;
|
|
66
|
+
}
|
|
67
|
+
buildAuthHeaders() {
|
|
68
|
+
return {
|
|
69
|
+
"X-API-Key": this.apiKey,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
__decorate([
|
|
74
|
+
Alias("api_key"),
|
|
75
|
+
Field("apiKey"),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], APIKeyCredentials.prototype, "apiKey", void 0);
|
|
78
|
+
/**
|
|
79
|
+
* Credentials that is used for username and password authenticated requests
|
|
80
|
+
*/
|
|
81
|
+
class BasicCredentials extends Credentials {
|
|
82
|
+
constructor(username, password) {
|
|
83
|
+
super();
|
|
84
|
+
this.username = username;
|
|
85
|
+
this.password = password;
|
|
86
|
+
}
|
|
87
|
+
buildAuthHeaders() {
|
|
88
|
+
let token;
|
|
89
|
+
if (isNode) {
|
|
90
|
+
token = Buffer.from(`${this.username}:${this.password}`).toString("base64");
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
token = btoa(`${this.username}:${this.password}`);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
Authorization: `Basic ${token}`,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
__decorate([
|
|
101
|
+
Field("username"),
|
|
102
|
+
__metadata("design:type", String)
|
|
103
|
+
], BasicCredentials.prototype, "username", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
Field("password"),
|
|
106
|
+
__metadata("design:type", String)
|
|
107
|
+
], BasicCredentials.prototype, "password", void 0);
|
|
108
|
+
|
|
109
|
+
export { APIKeyCredentials, BasicCredentials, BearerCredentials, Credentials };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var IllegalArgumentsError = require('../../errors/IllegalArgumentsError.cjs');
|
|
4
|
+
var ParsingError = require('../../errors/ParsingError.cjs');
|
|
5
|
+
var R = require('ramda');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
|
|
25
|
+
|
|
26
|
+
const View = (modelClass, path, option) => (data, ...otherArgs) => {
|
|
27
|
+
switch (option) {
|
|
28
|
+
case "json": {
|
|
29
|
+
const result = modelClass.fromJSON(data);
|
|
30
|
+
return R__namespace.view(R__namespace.lensPath(path), result);
|
|
31
|
+
}
|
|
32
|
+
case "string": {
|
|
33
|
+
const result = modelClass.fromString(data, ...otherArgs);
|
|
34
|
+
return R__namespace.view(R__namespace.lensPath(path), result);
|
|
35
|
+
}
|
|
36
|
+
case "blob": {
|
|
37
|
+
const result = modelClass.fromBlob(data, ...otherArgs);
|
|
38
|
+
return R__namespace.view(R__namespace.lensPath(path), result);
|
|
39
|
+
}
|
|
40
|
+
case "buffer": {
|
|
41
|
+
const result = modelClass.fromBuffer(data, ...otherArgs);
|
|
42
|
+
return R__namespace.view(R__namespace.lensPath(path), result);
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
throw new IllegalArgumentsError.IllegalArgumentsError([option]);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const Union = (modelClasses, option) => (data, ...otherArgs) => {
|
|
49
|
+
switch (option) {
|
|
50
|
+
case "json":
|
|
51
|
+
for (const ModelClass of modelClasses) {
|
|
52
|
+
try {
|
|
53
|
+
return ModelClass.fromJSON(data);
|
|
54
|
+
}
|
|
55
|
+
catch (err) { }
|
|
56
|
+
}
|
|
57
|
+
throw new ParsingError.ParsingError([], "Cannot find suitable model");
|
|
58
|
+
case "string":
|
|
59
|
+
for (const ModelClass of modelClasses) {
|
|
60
|
+
try {
|
|
61
|
+
return ModelClass.fromString(data, ...otherArgs);
|
|
62
|
+
}
|
|
63
|
+
catch (err) { }
|
|
64
|
+
}
|
|
65
|
+
throw new ParsingError.ParsingError([], "Cannot find suitable model");
|
|
66
|
+
case "blob":
|
|
67
|
+
for (const ModelClass of modelClasses) {
|
|
68
|
+
try {
|
|
69
|
+
return ModelClass.fromBlob(data, ...otherArgs);
|
|
70
|
+
}
|
|
71
|
+
catch (err) { }
|
|
72
|
+
}
|
|
73
|
+
throw new ParsingError.ParsingError([], "Cannot find suitable model");
|
|
74
|
+
case "buffer":
|
|
75
|
+
for (const ModelClass of modelClasses) {
|
|
76
|
+
try {
|
|
77
|
+
return ModelClass.fromBuffer(data, ...otherArgs);
|
|
78
|
+
}
|
|
79
|
+
catch (err) { }
|
|
80
|
+
}
|
|
81
|
+
throw new ParsingError.ParsingError([], "Cannot find suitable model");
|
|
82
|
+
default:
|
|
83
|
+
throw new IllegalArgumentsError.IllegalArgumentsError([option]);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
exports.Union = Union;
|
|
88
|
+
exports.View = View;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Model } from "./model";
|
|
2
|
+
type UnionParserOptions = "json" | "string" | "blob" | "buffer";
|
|
3
|
+
export declare const View: (modelClass: typeof Model, path: Array<string | number>, option: UnionParserOptions) => (data: any, ...otherArgs: any[]) => any;
|
|
4
|
+
export declare const Union: (modelClasses: Array<typeof Model>, option: UnionParserOptions) => (data: any, ...otherArgs: any[]) => Model | Model[] | Promise<Model | Model[]>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { IllegalArgumentsError } from '../../errors/IllegalArgumentsError.mjs';
|
|
2
|
+
import { ParsingError } from '../../errors/ParsingError.mjs';
|
|
3
|
+
import * as R from 'ramda';
|
|
4
|
+
|
|
5
|
+
const View = (modelClass, path, option) => (data, ...otherArgs) => {
|
|
6
|
+
switch (option) {
|
|
7
|
+
case "json": {
|
|
8
|
+
const result = modelClass.fromJSON(data);
|
|
9
|
+
return R.view(R.lensPath(path), result);
|
|
10
|
+
}
|
|
11
|
+
case "string": {
|
|
12
|
+
const result = modelClass.fromString(data, ...otherArgs);
|
|
13
|
+
return R.view(R.lensPath(path), result);
|
|
14
|
+
}
|
|
15
|
+
case "blob": {
|
|
16
|
+
const result = modelClass.fromBlob(data, ...otherArgs);
|
|
17
|
+
return R.view(R.lensPath(path), result);
|
|
18
|
+
}
|
|
19
|
+
case "buffer": {
|
|
20
|
+
const result = modelClass.fromBuffer(data, ...otherArgs);
|
|
21
|
+
return R.view(R.lensPath(path), result);
|
|
22
|
+
}
|
|
23
|
+
default:
|
|
24
|
+
throw new IllegalArgumentsError([option]);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const Union = (modelClasses, option) => (data, ...otherArgs) => {
|
|
28
|
+
switch (option) {
|
|
29
|
+
case "json":
|
|
30
|
+
for (const ModelClass of modelClasses) {
|
|
31
|
+
try {
|
|
32
|
+
return ModelClass.fromJSON(data);
|
|
33
|
+
}
|
|
34
|
+
catch (err) { }
|
|
35
|
+
}
|
|
36
|
+
throw new ParsingError([], "Cannot find suitable model");
|
|
37
|
+
case "string":
|
|
38
|
+
for (const ModelClass of modelClasses) {
|
|
39
|
+
try {
|
|
40
|
+
return ModelClass.fromString(data, ...otherArgs);
|
|
41
|
+
}
|
|
42
|
+
catch (err) { }
|
|
43
|
+
}
|
|
44
|
+
throw new ParsingError([], "Cannot find suitable model");
|
|
45
|
+
case "blob":
|
|
46
|
+
for (const ModelClass of modelClasses) {
|
|
47
|
+
try {
|
|
48
|
+
return ModelClass.fromBlob(data, ...otherArgs);
|
|
49
|
+
}
|
|
50
|
+
catch (err) { }
|
|
51
|
+
}
|
|
52
|
+
throw new ParsingError([], "Cannot find suitable model");
|
|
53
|
+
case "buffer":
|
|
54
|
+
for (const ModelClass of modelClasses) {
|
|
55
|
+
try {
|
|
56
|
+
return ModelClass.fromBuffer(data, ...otherArgs);
|
|
57
|
+
}
|
|
58
|
+
catch (err) { }
|
|
59
|
+
}
|
|
60
|
+
throw new ParsingError([], "Cannot find suitable model");
|
|
61
|
+
default:
|
|
62
|
+
throw new IllegalArgumentsError([option]);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { Union, View };
|