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,242 @@
|
|
|
1
|
+
import { ResponseType, BodyType } from '../types.mjs';
|
|
2
|
+
import * as R from 'ramda';
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
|
|
5
|
+
/// //// Constants ///////
|
|
6
|
+
const THROTTLE_DEFAULT_MS = 3000;
|
|
7
|
+
const SUPPORTED_HEADER_VALUES = ["String", "Number", "Boolean"];
|
|
8
|
+
/// // // Helpers ///////
|
|
9
|
+
const createProps = (constructor) => {
|
|
10
|
+
const proto = constructor.prototype;
|
|
11
|
+
if (proto.__internal__ === undefined) {
|
|
12
|
+
proto.__internal__ = { classConfig: {}, methodConfig: {} };
|
|
13
|
+
}
|
|
14
|
+
return proto;
|
|
15
|
+
};
|
|
16
|
+
const createResponseDecorator = (type) => ({ modelType, format, isArray, modelTypeMapping, modelTypeKeyPath } = {
|
|
17
|
+
modelType: String,
|
|
18
|
+
isArray: false,
|
|
19
|
+
}) => (target, propertyKey) => {
|
|
20
|
+
const proto = createProps(target.constructor);
|
|
21
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "responseType"]);
|
|
22
|
+
const formatLens = R.lensPath(["methodConfig", propertyKey, "dataFormat"]);
|
|
23
|
+
const typeLens = R.lensPath(["methodConfig", propertyKey, "responseClass"]);
|
|
24
|
+
const isArrayLens = R.lensPath(["methodConfig", propertyKey, "responseArray"]);
|
|
25
|
+
proto.__internal__ = R.set(lens, type, proto.__internal__);
|
|
26
|
+
proto.__internal__ = R.set(typeLens, modelType, proto.__internal__);
|
|
27
|
+
proto.__internal__ = R.set(isArrayLens, isArray, proto.__internal__);
|
|
28
|
+
proto.__internal__ = R.set(formatLens, format, proto.__internal__);
|
|
29
|
+
};
|
|
30
|
+
const createRequestBodyDecorator = (type) => (target, propertyKey, parameterIndex) => {
|
|
31
|
+
const proto = createProps(target.constructor);
|
|
32
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "parameters", "body"]);
|
|
33
|
+
proto.__internal__ = R.set(lens, { type, parameterIndex }, proto.__internal__);
|
|
34
|
+
};
|
|
35
|
+
const createRequestMultiBodyDecorator = (type) => (target, propertyKey) => {
|
|
36
|
+
const proto = createProps(target.constructor);
|
|
37
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "parameters", "body"]);
|
|
38
|
+
const changer = R.compose(R.mergeDeepLeft({ type }), R.or(R.__, {}));
|
|
39
|
+
proto.__internal__ = R.over(lens, changer, proto.__internal__);
|
|
40
|
+
};
|
|
41
|
+
const createRequestMultiBodyParameterDecorator = (key) => (value) => (target, propertyKey, parameterIndex) => {
|
|
42
|
+
const proto = createProps(target.constructor);
|
|
43
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "parameters", "body", key]);
|
|
44
|
+
const changer = R.compose(R.mergeDeepLeft({ [value]: parameterIndex }), R.or(R.__, {}));
|
|
45
|
+
proto.__internal__ = R.over(lens, changer, proto.__internal__);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Sets the host for the Snap Service
|
|
49
|
+
* @param value host
|
|
50
|
+
* @constructor
|
|
51
|
+
*/
|
|
52
|
+
const BaseUrl = (value) => (constructor) => {
|
|
53
|
+
const proto = createProps(constructor);
|
|
54
|
+
proto.__internal__.classConfig.baseUrl = value;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Marks the SnapService method as on that returns a JSON Response of a specific Model type
|
|
58
|
+
*/
|
|
59
|
+
const JSONResponse = createResponseDecorator(ResponseType.JSON);
|
|
60
|
+
/**
|
|
61
|
+
* Marks the SnapService method as on that returns a XML Response of a specific Model type
|
|
62
|
+
*/
|
|
63
|
+
const XMLResponse = createResponseDecorator(ResponseType.XML);
|
|
64
|
+
/**
|
|
65
|
+
* Marks the SnapService method as on that returns a String Response
|
|
66
|
+
*/
|
|
67
|
+
const StringResponse = createResponseDecorator(ResponseType.STRING)({ modelType: String });
|
|
68
|
+
/**
|
|
69
|
+
* Marks the SnapService method as on that returns a Blob
|
|
70
|
+
*/
|
|
71
|
+
const BinaryResponse = createResponseDecorator(ResponseType.BINARY)({ modelType: Blob });
|
|
72
|
+
/**
|
|
73
|
+
* Marks the SnapService method as on that has no return value
|
|
74
|
+
*/
|
|
75
|
+
const NoResponse = createResponseDecorator(ResponseType.NONE)();
|
|
76
|
+
/**
|
|
77
|
+
* Marks the SnapService method that it should use multipart/form-data when submitting the request
|
|
78
|
+
*/
|
|
79
|
+
const Multipart = createRequestMultiBodyDecorator(BodyType.MULTIPART);
|
|
80
|
+
/**
|
|
81
|
+
* Marks the SnapService method that it should use application/x-www-form-urlencoded when submitting the request
|
|
82
|
+
*/
|
|
83
|
+
const FormUrlEncoded = createRequestMultiBodyDecorator(BodyType.FORMURLENCODED);
|
|
84
|
+
/**
|
|
85
|
+
* Sets the headers for the request
|
|
86
|
+
* @param value MapOfHeaders
|
|
87
|
+
* @constructor
|
|
88
|
+
*/
|
|
89
|
+
const Headers = (value) => (target, propertyKey) => {
|
|
90
|
+
const proto = createProps(target.constructor);
|
|
91
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "headers"]);
|
|
92
|
+
const changer = R.compose(R.mergeDeepLeft(value), R.or(R.__, {}));
|
|
93
|
+
proto.__internal__ = R.over(lens, changer, proto.__internal__);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Throttles the request by 3 seconds
|
|
97
|
+
* @param target
|
|
98
|
+
* @param propertyKey
|
|
99
|
+
* @constructor
|
|
100
|
+
*/
|
|
101
|
+
const Throttle = (target, propertyKey) => {
|
|
102
|
+
const proto = createProps(target.constructor);
|
|
103
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "throttle"]);
|
|
104
|
+
proto.__internal__ = R.set(lens, { waitPeriodInMs: THROTTLE_DEFAULT_MS }, proto.__internal__);
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Throttles the request by the value provided
|
|
108
|
+
* @param value ThrottleByProps - An object that contains the waitPeriodInMs
|
|
109
|
+
* @constructor
|
|
110
|
+
*/
|
|
111
|
+
const ThrottleBy = (value) => (target, propertyKey) => {
|
|
112
|
+
const proto = createProps(target.constructor);
|
|
113
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "throttle"]);
|
|
114
|
+
proto.__internal__ = R.set(lens, value, proto.__internal__);
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Marks this method as an authenticator. When requests receive 401 status code, this method will be called to retrieve
|
|
118
|
+
* the credentials
|
|
119
|
+
* @param type Credentials - Type of credentials that this authenticator should return
|
|
120
|
+
* (BasicCredentials | BearerCredentials | APIKeyCredentials | define one of your own by subclassing Credentials)
|
|
121
|
+
* @param global Whether this authenticator should be used across all services
|
|
122
|
+
* @param socketField
|
|
123
|
+
* @constructor
|
|
124
|
+
*/
|
|
125
|
+
const Authenticator = (type, global = false, socketField = "accessToken") => (target, propertyKey) => {
|
|
126
|
+
const proto = createProps(target.constructor);
|
|
127
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "authenticator"]);
|
|
128
|
+
proto.__internal__ = R.over(lens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { type, global })), proto.__internal__);
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Marks this method as an auth refresher. Whenever a request receives a 401 status code for invalid credentials, this
|
|
132
|
+
* method will be called with the old Credentials, and should produce new credentials
|
|
133
|
+
* @param type Credentials - Type of credentials that this authenticator should return
|
|
134
|
+
* (BasicCredentials | BearerCredentials | APIKeyCredentials | define one of your own by subclassing Credentials)
|
|
135
|
+
* @param global Whether this auth refresher should be used across all services
|
|
136
|
+
* @constructor
|
|
137
|
+
*/
|
|
138
|
+
const AuthRefresher = (type, global = false) => (target, propertyKey) => {
|
|
139
|
+
const proto = createProps(target.constructor);
|
|
140
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "authRefresher"]);
|
|
141
|
+
proto.__internal__ = R.over(lens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { type, global })), proto.__internal__);
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Marks argument as a property in the MultiPart form
|
|
145
|
+
*/
|
|
146
|
+
const Part = createRequestMultiBodyParameterDecorator("parts");
|
|
147
|
+
/**
|
|
148
|
+
* Marks argument as a property in the FormUrlEncoded form or a JSON payload
|
|
149
|
+
*/
|
|
150
|
+
const Field = createRequestMultiBodyParameterDecorator("fields");
|
|
151
|
+
/**
|
|
152
|
+
* Marks argument as a property in the FormUrlEncoded form or JSON payload, but it can be missing
|
|
153
|
+
*/
|
|
154
|
+
const OptionalField = createRequestMultiBodyParameterDecorator("OptionalFields");
|
|
155
|
+
/**
|
|
156
|
+
* Marks argument that should be deserialized to a JSON string and attached as the body of the request
|
|
157
|
+
*/
|
|
158
|
+
const JSONBody = createRequestBodyDecorator(BodyType.JSON);
|
|
159
|
+
/**
|
|
160
|
+
* Marks argument that should be deserialized to XML string and attached as the body of the request
|
|
161
|
+
*/
|
|
162
|
+
const XMLBody = createRequestBodyDecorator(BodyType.XML);
|
|
163
|
+
/**
|
|
164
|
+
* Marks argument that should be the body of the request, and is a string
|
|
165
|
+
*/
|
|
166
|
+
const StringBody = createRequestBodyDecorator(BodyType.STRING);
|
|
167
|
+
/**
|
|
168
|
+
* Marks argument that should contain a Map of the queries used in the request. Argument should be an object with each
|
|
169
|
+
* key value pair being the query name and value
|
|
170
|
+
* @constructor
|
|
171
|
+
*/
|
|
172
|
+
const QueryMap = (target, propertyKey, parameterIndex) => {
|
|
173
|
+
const proto = createProps(target.constructor);
|
|
174
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "parameters", "queries"]);
|
|
175
|
+
proto.__internal__ = R.over(lens, R.compose(R.mergeLeft({ [Symbol(propertyKey)]: parameterIndex }, R.__), R.or(R.__, {})), proto.__internal__);
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Marks argument as a path variable in the request url
|
|
179
|
+
* @param value Name of the path variable
|
|
180
|
+
* @constructor
|
|
181
|
+
*/
|
|
182
|
+
const Path = (value) => {
|
|
183
|
+
return (target, propertyKey, parameterIndex) => {
|
|
184
|
+
const type = R.path([parameterIndex, "name"], Reflect.getMetadata("design:paramtypes", target, propertyKey));
|
|
185
|
+
if (!["String", "Number"].includes(type)) {
|
|
186
|
+
throw Error("Invalid type given for @Query. Should be of type string or number");
|
|
187
|
+
}
|
|
188
|
+
const proto = createProps(target.constructor);
|
|
189
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "parameters", "pathVariables"]);
|
|
190
|
+
proto.__internal__ = R.over(lens, R.compose(R.mergeDeepWith(R.concat, { [value]: parameterIndex }), R.or(R.__, {})), proto.__internal__);
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Marks argument as a query to be attached to the request url
|
|
195
|
+
* @param value Name of the query
|
|
196
|
+
* @constructor
|
|
197
|
+
*/
|
|
198
|
+
const Query = (value) => {
|
|
199
|
+
return (target, propertyKey, parameterIndex) => {
|
|
200
|
+
const proto = createProps(target.constructor);
|
|
201
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "parameters", "queries"]);
|
|
202
|
+
proto.__internal__ = R.over(lens, R.compose(R.mergeDeepWith(R.concat, { [value]: parameterIndex }), R.or(R.__, {})), proto.__internal__);
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Marks argument as a header to be attached to the request
|
|
207
|
+
* @param value Name of the header
|
|
208
|
+
* @constructor
|
|
209
|
+
*/
|
|
210
|
+
const Header = (value) => {
|
|
211
|
+
return (target, propertyKey, parameterIndex) => {
|
|
212
|
+
const type = R.path([parameterIndex, "name"], Reflect.getMetadata("design:paramtypes", target, propertyKey));
|
|
213
|
+
if (!SUPPORTED_HEADER_VALUES.includes(type)) {
|
|
214
|
+
throw Error("Invalid type given for @HeaderMap. Should be of type string, number or boolean");
|
|
215
|
+
}
|
|
216
|
+
const proto = createProps(target.constructor);
|
|
217
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "parameters", "headers"]);
|
|
218
|
+
proto.__internal__ = R.over(lens, R.compose(R.mergeDeepWith(R.concat, { [value]: parameterIndex }), R.or(R.__, {})), proto.__internal__);
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Marks argument that should contain a Map of the headers used in the request. Argument should be an object with each
|
|
223
|
+
* key value pair being the header name and value
|
|
224
|
+
* @constructor
|
|
225
|
+
*/
|
|
226
|
+
const HeaderMap = (target, propertyKey, parameterIndex) => {
|
|
227
|
+
const proto = createProps(target.constructor);
|
|
228
|
+
const lens = R.lensPath(["methodConfig", propertyKey, "parameters", "headers"]);
|
|
229
|
+
const key = Symbol(propertyKey);
|
|
230
|
+
proto.__internal__ = R.over(lens, R.compose(R.mergeLeft({ [key]: parameterIndex }, R.__), R.or(R.__, {})), proto.__internal__);
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Disables any authenticator that should be applied to this method
|
|
234
|
+
* @constructor
|
|
235
|
+
*/
|
|
236
|
+
const NoAuth = (target, propertyKey) => {
|
|
237
|
+
const proto = createProps(target.constructor);
|
|
238
|
+
const lens = R.lensPath(["methodConfig", propertyKey]);
|
|
239
|
+
proto.__internal__ = R.set(lens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { noAuth: true })), proto.__internal__);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export { AuthRefresher, Authenticator, BaseUrl, BinaryResponse, Field, FormUrlEncoded, Header, HeaderMap, Headers, JSONBody, JSONResponse, Multipart, NoAuth, NoResponse, OptionalField, Part, Path, Query, QueryMap, StringBody, StringResponse, THROTTLE_DEFAULT_MS, Throttle, ThrottleBy, XMLBody, XMLResponse, createProps };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var R = require('ramda');
|
|
4
|
+
var options = require('./options.cjs');
|
|
5
|
+
var types = require('../types.cjs');
|
|
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
|
+
/// //// Helpers ///////
|
|
27
|
+
const createRequestDecorator = (type) => (path) => (target, propertyKey) => {
|
|
28
|
+
const proto = options.createProps(target.constructor);
|
|
29
|
+
const typeLens = R__namespace.lensPath(["methodConfig", propertyKey, "requestType"]);
|
|
30
|
+
const pathLens = R__namespace.lensPath(["methodConfig", propertyKey, "apiPath"]);
|
|
31
|
+
proto.__internal__ = R__namespace.set(typeLens, type, proto.__internal__);
|
|
32
|
+
proto.__internal__ = R__namespace.set(pathLens, path, proto.__internal__);
|
|
33
|
+
};
|
|
34
|
+
exports.CachingMethod = void 0;
|
|
35
|
+
(function (CachingMethod) {
|
|
36
|
+
CachingMethod["FALLBACK_ON_MISSING"] = "FALLBACK_ON_MISSING";
|
|
37
|
+
CachingMethod["HIT_FIRST"] = "HIT_FIRST";
|
|
38
|
+
})(exports.CachingMethod || (exports.CachingMethod = {}));
|
|
39
|
+
/**
|
|
40
|
+
* Marks method as a GET request
|
|
41
|
+
*/
|
|
42
|
+
const GET = createRequestDecorator(types.RequestType.GET);
|
|
43
|
+
/**
|
|
44
|
+
* Marks method as a PUT request
|
|
45
|
+
*/
|
|
46
|
+
const PUT = createRequestDecorator(types.RequestType.PUT);
|
|
47
|
+
/**
|
|
48
|
+
* Marks method as a POST request
|
|
49
|
+
*/
|
|
50
|
+
const POST = createRequestDecorator(types.RequestType.POST);
|
|
51
|
+
/**
|
|
52
|
+
* Marks method as a DELETE request
|
|
53
|
+
*/
|
|
54
|
+
const DELETE = createRequestDecorator(types.RequestType.DELETE);
|
|
55
|
+
/**
|
|
56
|
+
* Marks method as a PATCH request
|
|
57
|
+
*/
|
|
58
|
+
const PATCH = createRequestDecorator(types.RequestType.PATCH);
|
|
59
|
+
/**
|
|
60
|
+
* Marks method as a OPTIONS request
|
|
61
|
+
*/
|
|
62
|
+
const OPTIONS = createRequestDecorator(types.RequestType.OPTIONS);
|
|
63
|
+
/**
|
|
64
|
+
* Marks method as a HEAD request
|
|
65
|
+
*/
|
|
66
|
+
const HEAD = createRequestDecorator(types.RequestType.HEAD);
|
|
67
|
+
const Cached = (duration, persist = false, method = exports.CachingMethod.HIT_FIRST) => (target, propertyKey) => {
|
|
68
|
+
const proto = options.createProps(target.constructor);
|
|
69
|
+
const cacheLens = R__namespace.lensPath(["methodConfig", propertyKey, "cache"]);
|
|
70
|
+
proto.__internal__ = R__namespace.set(cacheLens, { duration, persist, method }, proto.__internal__);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.Cached = Cached;
|
|
74
|
+
exports.DELETE = DELETE;
|
|
75
|
+
exports.GET = GET;
|
|
76
|
+
exports.HEAD = HEAD;
|
|
77
|
+
exports.OPTIONS = OPTIONS;
|
|
78
|
+
exports.PATCH = PATCH;
|
|
79
|
+
exports.POST = POST;
|
|
80
|
+
exports.PUT = PUT;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WaitPeriod } from "../../future";
|
|
2
|
+
export declare enum CachingMethod {
|
|
3
|
+
FALLBACK_ON_MISSING = "FALLBACK_ON_MISSING",
|
|
4
|
+
HIT_FIRST = "HIT_FIRST"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Marks method as a GET request
|
|
8
|
+
*/
|
|
9
|
+
export declare const GET: (path: string) => (target: any, propertyKey: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Marks method as a PUT request
|
|
12
|
+
*/
|
|
13
|
+
export declare const PUT: (path: string) => (target: any, propertyKey: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Marks method as a POST request
|
|
16
|
+
*/
|
|
17
|
+
export declare const POST: (path: string) => (target: any, propertyKey: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Marks method as a DELETE request
|
|
20
|
+
*/
|
|
21
|
+
export declare const DELETE: (path: string) => (target: any, propertyKey: string) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Marks method as a PATCH request
|
|
24
|
+
*/
|
|
25
|
+
export declare const PATCH: (path: string) => (target: any, propertyKey: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Marks method as a OPTIONS request
|
|
28
|
+
*/
|
|
29
|
+
export declare const OPTIONS: (path: string) => (target: any, propertyKey: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Marks method as a HEAD request
|
|
32
|
+
*/
|
|
33
|
+
export declare const HEAD: (path: string) => (target: any, propertyKey: string) => void;
|
|
34
|
+
export declare const Cached: (duration: WaitPeriod, persist?: boolean, method?: CachingMethod) => (target: any, propertyKey: string) => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
import { createProps } from './options.mjs';
|
|
3
|
+
import { RequestType } from '../types.mjs';
|
|
4
|
+
|
|
5
|
+
/// //// Helpers ///////
|
|
6
|
+
const createRequestDecorator = (type) => (path) => (target, propertyKey) => {
|
|
7
|
+
const proto = createProps(target.constructor);
|
|
8
|
+
const typeLens = R.lensPath(["methodConfig", propertyKey, "requestType"]);
|
|
9
|
+
const pathLens = R.lensPath(["methodConfig", propertyKey, "apiPath"]);
|
|
10
|
+
proto.__internal__ = R.set(typeLens, type, proto.__internal__);
|
|
11
|
+
proto.__internal__ = R.set(pathLens, path, proto.__internal__);
|
|
12
|
+
};
|
|
13
|
+
var CachingMethod;
|
|
14
|
+
(function (CachingMethod) {
|
|
15
|
+
CachingMethod["FALLBACK_ON_MISSING"] = "FALLBACK_ON_MISSING";
|
|
16
|
+
CachingMethod["HIT_FIRST"] = "HIT_FIRST";
|
|
17
|
+
})(CachingMethod || (CachingMethod = {}));
|
|
18
|
+
/**
|
|
19
|
+
* Marks method as a GET request
|
|
20
|
+
*/
|
|
21
|
+
const GET = createRequestDecorator(RequestType.GET);
|
|
22
|
+
/**
|
|
23
|
+
* Marks method as a PUT request
|
|
24
|
+
*/
|
|
25
|
+
const PUT = createRequestDecorator(RequestType.PUT);
|
|
26
|
+
/**
|
|
27
|
+
* Marks method as a POST request
|
|
28
|
+
*/
|
|
29
|
+
const POST = createRequestDecorator(RequestType.POST);
|
|
30
|
+
/**
|
|
31
|
+
* Marks method as a DELETE request
|
|
32
|
+
*/
|
|
33
|
+
const DELETE = createRequestDecorator(RequestType.DELETE);
|
|
34
|
+
/**
|
|
35
|
+
* Marks method as a PATCH request
|
|
36
|
+
*/
|
|
37
|
+
const PATCH = createRequestDecorator(RequestType.PATCH);
|
|
38
|
+
/**
|
|
39
|
+
* Marks method as a OPTIONS request
|
|
40
|
+
*/
|
|
41
|
+
const OPTIONS = createRequestDecorator(RequestType.OPTIONS);
|
|
42
|
+
/**
|
|
43
|
+
* Marks method as a HEAD request
|
|
44
|
+
*/
|
|
45
|
+
const HEAD = createRequestDecorator(RequestType.HEAD);
|
|
46
|
+
const Cached = (duration, persist = false, method = CachingMethod.HIT_FIRST) => (target, propertyKey) => {
|
|
47
|
+
const proto = createProps(target.constructor);
|
|
48
|
+
const cacheLens = R.lensPath(["methodConfig", propertyKey, "cache"]);
|
|
49
|
+
proto.__internal__ = R.set(cacheLens, { duration, persist, method }, proto.__internal__);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { Cached, CachingMethod, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var options = require('./options.cjs');
|
|
4
|
+
var R = require('ramda');
|
|
5
|
+
var uuid = require('uuid');
|
|
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 ReadStream = (keyPath, value) => (target, propertyKey) => {
|
|
27
|
+
if (keyPath !== "*" && (value === undefined || value === null))
|
|
28
|
+
throw new Error("KeyPath requires a value, unless keyPath is *");
|
|
29
|
+
const proto = options.createProps(target.constructor);
|
|
30
|
+
const typeLens = R__namespace.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
31
|
+
proto.__internal__ = R__namespace.over(typeLens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { keyPath,
|
|
32
|
+
value, array: false })), proto.__internal__);
|
|
33
|
+
};
|
|
34
|
+
const MatcherKey = (name) => (target, propertyKey, parameterIndex) => { };
|
|
35
|
+
const MatcherValue = (name) => (target, propertyKey, parameterIndex) => { };
|
|
36
|
+
const WriteStream = (target, propertyKey) => {
|
|
37
|
+
const proto = options.createProps(target.constructor);
|
|
38
|
+
const typeLens = R__namespace.lensPath(["methodConfig", propertyKey, "socketWriteStream"]);
|
|
39
|
+
proto.__internal__ = R__namespace.set(typeLens, true, proto.__internal__);
|
|
40
|
+
};
|
|
41
|
+
const RequestReply = (guidPath, guidGen = () => uuid.v4(), objectMaxSize, expiryPeriod) => (target, propertyKey) => {
|
|
42
|
+
const proto = options.createProps(target.constructor);
|
|
43
|
+
const typeLens = R__namespace.lensPath(["methodConfig", propertyKey, "socketRequestReply"]);
|
|
44
|
+
proto.__internal__ = R__namespace.set(typeLens, { guidPath, guidGen, objectMaxSize, expiryPeriod }, proto.__internal__);
|
|
45
|
+
};
|
|
46
|
+
const ReplyableStream = (keyPath, responseKeyPath) => (target, propertyKey) => {
|
|
47
|
+
options.createProps(target.constructor);
|
|
48
|
+
R__namespace.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
49
|
+
};
|
|
50
|
+
const IgnoreCache = (target, propertyKey) => {
|
|
51
|
+
const proto = options.createProps(target.constructor);
|
|
52
|
+
const typeLens = R__namespace.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
53
|
+
proto.__internal__ = R__namespace.over(typeLens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { ignoreCache: true })), proto.__internal__);
|
|
54
|
+
};
|
|
55
|
+
const Skip = (amount) => (target, propertyKey) => {
|
|
56
|
+
const proto = options.createProps(target.constructor);
|
|
57
|
+
const typeLens = R__namespace.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
58
|
+
proto.__internal__ = R__namespace.over(typeLens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { skip: amount })), proto.__internal__);
|
|
59
|
+
};
|
|
60
|
+
const Take = (amount) => (target, propertyKey) => {
|
|
61
|
+
const proto = options.createProps(target.constructor);
|
|
62
|
+
const typeLens = R__namespace.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
63
|
+
proto.__internal__ = R__namespace.over(typeLens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { take: amount })), proto.__internal__);
|
|
64
|
+
};
|
|
65
|
+
// Decoder must return an object
|
|
66
|
+
const DataDecoder = (Decoder) => (constructor) => {
|
|
67
|
+
const proto = options.createProps(constructor);
|
|
68
|
+
const typeLens = R__namespace.lensPath(["classConfig", "Decoder"]);
|
|
69
|
+
proto.__internal__ = R__namespace.set(typeLens, Decoder, proto.__internal__);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.DataDecoder = DataDecoder;
|
|
73
|
+
exports.IgnoreCache = IgnoreCache;
|
|
74
|
+
exports.MatcherKey = MatcherKey;
|
|
75
|
+
exports.MatcherValue = MatcherValue;
|
|
76
|
+
exports.ReadStream = ReadStream;
|
|
77
|
+
exports.ReplyableStream = ReplyableStream;
|
|
78
|
+
exports.RequestReply = RequestReply;
|
|
79
|
+
exports.Skip = Skip;
|
|
80
|
+
exports.Take = Take;
|
|
81
|
+
exports.WriteStream = WriteStream;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WaitPeriod } from "../../future";
|
|
2
|
+
export declare const ReadStream: (keyPath: string | (string | number)[] | {
|
|
3
|
+
[string: string]: string;
|
|
4
|
+
}, value?: string | number | boolean | RegExp) => (target: any, propertyKey: string) => void;
|
|
5
|
+
export declare const MatcherKey: (name: string) => (target: any, propertyKey: string, parameterIndex: number) => void;
|
|
6
|
+
export declare const MatcherValue: (name: string) => (target: any, propertyKey: string, parameterIndex: number) => void;
|
|
7
|
+
export declare const WriteStream: (target: any, propertyKey: string) => void;
|
|
8
|
+
export declare const RequestReply: (guidPath: Array<string | number>, guidGen?: () => any, objectMaxSize?: number, expiryPeriod?: WaitPeriod) => (target: any, propertyKey: string) => void;
|
|
9
|
+
export declare const ReplyableStream: (keyPath: string | Array<string | number>, responseKeyPath?: string | Array<string | number>) => (target: any, propertyKey: string) => void;
|
|
10
|
+
export declare const IgnoreCache: (target: any, propertyKey: string) => void;
|
|
11
|
+
export declare const Skip: (amount: number) => (target: any, propertyKey: string) => void;
|
|
12
|
+
export declare const Take: (amount: number) => (target: any, propertyKey: string) => void;
|
|
13
|
+
export declare const DataDecoder: (Decoder: any) => (constructor: any) => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createProps } from './options.mjs';
|
|
2
|
+
import * as R from 'ramda';
|
|
3
|
+
import { v4 } from 'uuid';
|
|
4
|
+
|
|
5
|
+
const ReadStream = (keyPath, value) => (target, propertyKey) => {
|
|
6
|
+
if (keyPath !== "*" && (value === undefined || value === null))
|
|
7
|
+
throw new Error("KeyPath requires a value, unless keyPath is *");
|
|
8
|
+
const proto = createProps(target.constructor);
|
|
9
|
+
const typeLens = R.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
10
|
+
proto.__internal__ = R.over(typeLens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { keyPath,
|
|
11
|
+
value, array: false })), proto.__internal__);
|
|
12
|
+
};
|
|
13
|
+
const MatcherKey = (name) => (target, propertyKey, parameterIndex) => { };
|
|
14
|
+
const MatcherValue = (name) => (target, propertyKey, parameterIndex) => { };
|
|
15
|
+
const WriteStream = (target, propertyKey) => {
|
|
16
|
+
const proto = createProps(target.constructor);
|
|
17
|
+
const typeLens = R.lensPath(["methodConfig", propertyKey, "socketWriteStream"]);
|
|
18
|
+
proto.__internal__ = R.set(typeLens, true, proto.__internal__);
|
|
19
|
+
};
|
|
20
|
+
const RequestReply = (guidPath, guidGen = () => v4(), objectMaxSize, expiryPeriod) => (target, propertyKey) => {
|
|
21
|
+
const proto = createProps(target.constructor);
|
|
22
|
+
const typeLens = R.lensPath(["methodConfig", propertyKey, "socketRequestReply"]);
|
|
23
|
+
proto.__internal__ = R.set(typeLens, { guidPath, guidGen, objectMaxSize, expiryPeriod }, proto.__internal__);
|
|
24
|
+
};
|
|
25
|
+
const ReplyableStream = (keyPath, responseKeyPath) => (target, propertyKey) => {
|
|
26
|
+
createProps(target.constructor);
|
|
27
|
+
R.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
28
|
+
};
|
|
29
|
+
const IgnoreCache = (target, propertyKey) => {
|
|
30
|
+
const proto = createProps(target.constructor);
|
|
31
|
+
const typeLens = R.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
32
|
+
proto.__internal__ = R.over(typeLens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { ignoreCache: true })), proto.__internal__);
|
|
33
|
+
};
|
|
34
|
+
const Skip = (amount) => (target, propertyKey) => {
|
|
35
|
+
const proto = createProps(target.constructor);
|
|
36
|
+
const typeLens = R.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
37
|
+
proto.__internal__ = R.over(typeLens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { skip: amount })), proto.__internal__);
|
|
38
|
+
};
|
|
39
|
+
const Take = (amount) => (target, propertyKey) => {
|
|
40
|
+
const proto = createProps(target.constructor);
|
|
41
|
+
const typeLens = R.lensPath(["methodConfig", propertyKey, "socketReadStream"]);
|
|
42
|
+
proto.__internal__ = R.over(typeLens, (v) => (Object.assign(Object.assign({}, (v !== null && v !== void 0 ? v : {})), { take: amount })), proto.__internal__);
|
|
43
|
+
};
|
|
44
|
+
// Decoder must return an object
|
|
45
|
+
const DataDecoder = (Decoder) => (constructor) => {
|
|
46
|
+
const proto = createProps(constructor);
|
|
47
|
+
const typeLens = R.lensPath(["classConfig", "Decoder"]);
|
|
48
|
+
proto.__internal__ = R.set(typeLens, Decoder, proto.__internal__);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { DataDecoder, IgnoreCache, MatcherKey, MatcherValue, ReadStream, ReplyableStream, RequestReply, Skip, Take, WriteStream };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HTTP Status codes as ENUM values
|
|
5
|
+
*/
|
|
6
|
+
exports.HTTPStatus = void 0;
|
|
7
|
+
(function (HTTPStatus) {
|
|
8
|
+
HTTPStatus[HTTPStatus["OFFLINE"] = 0] = "OFFLINE";
|
|
9
|
+
HTTPStatus[HTTPStatus["CONTINUE"] = 100] = "CONTINUE";
|
|
10
|
+
HTTPStatus[HTTPStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
11
|
+
HTTPStatus[HTTPStatus["PROCESSING"] = 102] = "PROCESSING";
|
|
12
|
+
HTTPStatus[HTTPStatus["EARLY_HINTS"] = 103] = "EARLY_HINTS";
|
|
13
|
+
HTTPStatus[HTTPStatus["OK"] = 200] = "OK";
|
|
14
|
+
HTTPStatus[HTTPStatus["CREATED"] = 201] = "CREATED";
|
|
15
|
+
HTTPStatus[HTTPStatus["ACCEPTED"] = 202] = "ACCEPTED";
|
|
16
|
+
HTTPStatus[HTTPStatus["NON_AUTHORITATIVE_INFO"] = 203] = "NON_AUTHORITATIVE_INFO";
|
|
17
|
+
HTTPStatus[HTTPStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
18
|
+
HTTPStatus[HTTPStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
19
|
+
HTTPStatus[HTTPStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
20
|
+
HTTPStatus[HTTPStatus["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
21
|
+
HTTPStatus[HTTPStatus["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
22
|
+
HTTPStatus[HTTPStatus["IM_USED"] = 209] = "IM_USED";
|
|
23
|
+
HTTPStatus[HTTPStatus["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
24
|
+
HTTPStatus[HTTPStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
25
|
+
HTTPStatus[HTTPStatus["FOUND"] = 302] = "FOUND";
|
|
26
|
+
HTTPStatus[HTTPStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
27
|
+
HTTPStatus[HTTPStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
28
|
+
HTTPStatus[HTTPStatus["USE_PROXY"] = 305] = "USE_PROXY";
|
|
29
|
+
HTTPStatus[HTTPStatus["SWITCH_PROXY"] = 306] = "SWITCH_PROXY";
|
|
30
|
+
HTTPStatus[HTTPStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
31
|
+
HTTPStatus[HTTPStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
32
|
+
HTTPStatus[HTTPStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
33
|
+
HTTPStatus[HTTPStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
34
|
+
HTTPStatus[HTTPStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
35
|
+
HTTPStatus[HTTPStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
36
|
+
HTTPStatus[HTTPStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
37
|
+
HTTPStatus[HTTPStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
38
|
+
HTTPStatus[HTTPStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
39
|
+
HTTPStatus[HTTPStatus["PROXY_AUTH_REQUIRED"] = 407] = "PROXY_AUTH_REQUIRED";
|
|
40
|
+
HTTPStatus[HTTPStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
41
|
+
HTTPStatus[HTTPStatus["CONFLICT"] = 409] = "CONFLICT";
|
|
42
|
+
HTTPStatus[HTTPStatus["GONE"] = 410] = "GONE";
|
|
43
|
+
HTTPStatus[HTTPStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
44
|
+
HTTPStatus[HTTPStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
45
|
+
HTTPStatus[HTTPStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
46
|
+
HTTPStatus[HTTPStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
47
|
+
HTTPStatus[HTTPStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
48
|
+
HTTPStatus[HTTPStatus["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
49
|
+
HTTPStatus[HTTPStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
50
|
+
HTTPStatus[HTTPStatus["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
51
|
+
HTTPStatus[HTTPStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
52
|
+
HTTPStatus[HTTPStatus["LOCKED"] = 423] = "LOCKED";
|
|
53
|
+
HTTPStatus[HTTPStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
54
|
+
HTTPStatus[HTTPStatus["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
55
|
+
HTTPStatus[HTTPStatus["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
56
|
+
HTTPStatus[HTTPStatus["PRECONDITION_FAILURE"] = 428] = "PRECONDITION_FAILURE";
|
|
57
|
+
HTTPStatus[HTTPStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
58
|
+
HTTPStatus[HTTPStatus["REQUEST_HEADER_FIELD_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELD_TOO_LARGE";
|
|
59
|
+
HTTPStatus[HTTPStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
60
|
+
HTTPStatus[HTTPStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
61
|
+
HTTPStatus[HTTPStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
62
|
+
HTTPStatus[HTTPStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
63
|
+
HTTPStatus[HTTPStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
64
|
+
HTTPStatus[HTTPStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
65
|
+
HTTPStatus[HTTPStatus["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
66
|
+
HTTPStatus[HTTPStatus["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
67
|
+
HTTPStatus[HTTPStatus["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
68
|
+
HTTPStatus[HTTPStatus["NETWORK_AUTH_REQUIRED"] = 511] = "NETWORK_AUTH_REQUIRED";
|
|
69
|
+
})(exports.HTTPStatus || (exports.HTTPStatus = {}));
|