@based/server 3.4.5 → 4.0.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/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +173 -0
- package/dist/api/index.js.map +1 -0
- package/dist/auth/dummyAuth.d.ts +1 -1
- package/dist/auth/dummyAuth.js +3 -2
- package/dist/auth/dummyAuth.js.map +1 -1
- package/dist/auth/index.d.ts +8 -4
- package/dist/auth/index.js +28 -23
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/parseAuthState.d.ts +2 -0
- package/dist/auth/parseAuthState.js +16 -0
- package/dist/auth/parseAuthState.js.map +1 -0
- package/dist/auth/types.d.ts +10 -0
- package/dist/{handlers/rest/file → auth}/types.js +0 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/compress.d.ts +5 -0
- package/dist/{network/http/compress.js → compress.js} +2 -6
- package/dist/compress.js.map +1 -0
- package/dist/context.d.ts +54 -0
- package/dist/context.js +18 -0
- package/dist/context.js.map +1 -0
- package/dist/error/errorTypeHandlers.d.ts +6 -0
- package/dist/error/errorTypeHandlers.js +130 -0
- package/dist/error/errorTypeHandlers.js.map +1 -0
- package/dist/error/index.d.ts +5 -0
- package/dist/error/index.js +61 -0
- package/dist/error/index.js.map +1 -0
- package/dist/error/types.d.ts +105 -0
- package/dist/error/types.js +30 -0
- package/dist/error/types.js.map +1 -0
- package/dist/functions/index.d.ts +10 -24
- package/dist/functions/index.js +98 -287
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/timeout.d.ts +1 -1
- package/dist/functions/types.d.ts +69 -0
- package/dist/functions/types.js +15 -0
- package/dist/functions/types.js.map +1 -0
- package/dist/incoming/http/authorize.d.ts +4 -0
- package/dist/incoming/http/authorize.js +37 -0
- package/dist/incoming/http/authorize.js.map +1 -0
- package/dist/incoming/http/function.d.ts +4 -0
- package/dist/{network → incoming}/http/function.js +13 -13
- package/dist/incoming/http/function.js.map +1 -0
- package/dist/incoming/http/get.d.ts +4 -0
- package/dist/incoming/http/get.js +155 -0
- package/dist/incoming/http/get.js.map +1 -0
- package/dist/{network → incoming}/http/index.d.ts +0 -0
- package/dist/incoming/http/index.js +134 -0
- package/dist/incoming/http/index.js.map +1 -0
- package/dist/incoming/http/parseQuery.d.ts +4 -0
- package/dist/incoming/http/parseQuery.js +25 -0
- package/dist/incoming/http/parseQuery.js.map +1 -0
- package/dist/incoming/http/readBody.d.ts +4 -0
- package/dist/{network → incoming}/http/readBody.js +27 -32
- package/dist/incoming/http/readBody.js.map +1 -0
- package/dist/{handlers/rest/file → incoming/http/streamFunction}/DataStream.d.ts +0 -0
- package/dist/{network → incoming}/http/streamFunction/DataStream.js +0 -0
- package/dist/incoming/http/streamFunction/DataStream.js.map +1 -0
- package/dist/{network → incoming}/http/streamFunction/getExtension.d.ts +0 -0
- package/dist/{network → incoming}/http/streamFunction/getExtension.js +0 -0
- package/dist/incoming/http/streamFunction/getExtension.js.map +1 -0
- package/dist/incoming/http/streamFunction/index.d.ts +4 -0
- package/dist/incoming/http/streamFunction/index.js +106 -0
- package/dist/incoming/http/streamFunction/index.js.map +1 -0
- package/dist/incoming/http/streamFunction/multipartStream.d.ts +13 -0
- package/dist/{network → incoming}/http/streamFunction/multipartStream.js +12 -12
- package/dist/incoming/http/streamFunction/multipartStream.js.map +1 -0
- package/dist/{network → incoming}/http/streamFunction/stream.d.ts +3 -2
- package/dist/{network → incoming}/http/streamFunction/stream.js +16 -11
- package/dist/incoming/http/streamFunction/stream.js.map +1 -0
- package/dist/incoming/index.d.ts +3 -0
- package/dist/{network → incoming}/index.js +28 -28
- package/dist/incoming/index.js.map +1 -0
- package/dist/incoming/upgrade.d.ts +4 -0
- package/dist/{network → incoming}/upgrade.js +24 -9
- package/dist/incoming/upgrade.js.map +1 -0
- package/dist/incoming/ws/auth.d.ts +5 -0
- package/dist/incoming/ws/auth.js +40 -0
- package/dist/incoming/ws/auth.js.map +1 -0
- package/dist/incoming/ws/function.d.ts +3 -0
- package/dist/incoming/ws/function.js +107 -0
- package/dist/incoming/ws/function.js.map +1 -0
- package/dist/incoming/ws/get.d.ts +3 -0
- package/dist/incoming/ws/get.js +136 -0
- package/dist/incoming/ws/get.js.map +1 -0
- package/dist/incoming/ws/index.d.ts +3 -0
- package/dist/{network/message → incoming/ws}/index.js +17 -18
- package/dist/incoming/ws/index.js.map +1 -0
- package/dist/incoming/ws/observable.d.ts +6 -0
- package/dist/incoming/ws/observable.js +112 -0
- package/dist/incoming/ws/observable.js.map +1 -0
- package/dist/index.d.ts +10 -35
- package/dist/index.js +17 -196
- package/dist/index.js.map +1 -1
- package/dist/ip.d.ts +2 -0
- package/dist/ip.js +8 -0
- package/dist/ip.js.map +1 -0
- package/dist/observable/create.d.ts +3 -0
- package/dist/observable/create.js +30 -0
- package/dist/observable/create.js.map +1 -0
- package/dist/observable/destroy.d.ts +2 -0
- package/dist/observable/destroy.js +51 -0
- package/dist/observable/destroy.js.map +1 -0
- package/dist/observable/error.d.ts +4 -0
- package/dist/observable/error.js +17 -0
- package/dist/observable/error.js.map +1 -0
- package/dist/observable/extendCache.d.ts +2 -0
- package/dist/observable/extendCache.js +11 -0
- package/dist/observable/extendCache.js.map +1 -0
- package/dist/observable/genObservableId.d.ts +1 -0
- package/dist/observable/genObservableId.js +9 -0
- package/dist/observable/genObservableId.js.map +1 -0
- package/dist/observable/get.d.ts +4 -0
- package/dist/observable/get.js +15 -0
- package/dist/observable/get.js.map +1 -0
- package/dist/observable/index.d.ts +11 -8
- package/dist/observable/index.js +25 -151
- package/dist/observable/index.js.map +1 -1
- package/dist/observable/send.d.ts +6 -0
- package/dist/observable/send.js +32 -0
- package/dist/observable/send.js.map +1 -0
- package/dist/observable/start/error.d.ts +3 -0
- package/dist/observable/start/error.js +36 -0
- package/dist/observable/start/error.js.map +1 -0
- package/dist/observable/start/index.d.ts +2 -0
- package/dist/observable/start/index.js +46 -0
- package/dist/observable/start/index.js.map +1 -0
- package/dist/observable/start/update.d.ts +6 -0
- package/dist/observable/start/update.js +104 -0
- package/dist/observable/start/update.js.map +1 -0
- package/dist/observable/subscribe.d.ts +7 -0
- package/dist/observable/subscribe.js +54 -0
- package/dist/observable/subscribe.js.map +1 -0
- package/dist/observable/types.d.ts +26 -0
- package/dist/observable/types.js +3 -0
- package/dist/observable/types.js.map +1 -0
- package/dist/observable/unsub.d.ts +6 -0
- package/dist/observable/unsub.js +43 -0
- package/dist/observable/unsub.js.map +1 -0
- package/dist/observable/verify.d.ts +4 -0
- package/dist/observable/verify.js +18 -0
- package/dist/observable/verify.js.map +1 -0
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.js +32 -11
- package/dist/protocol.js.map +1 -1
- package/dist/security.d.ts +6 -0
- package/dist/security.js +95 -0
- package/dist/security.js.map +1 -0
- package/dist/sendError.d.ts +5 -0
- package/dist/sendError.js +42 -0
- package/dist/sendError.js.map +1 -0
- package/dist/sendHttpResponse.d.ts +4 -0
- package/dist/sendHttpResponse.js +53 -0
- package/dist/sendHttpResponse.js.map +1 -0
- package/dist/server.d.ts +42 -8
- package/dist/server.js +26 -12
- package/dist/server.js.map +1 -1
- package/package.json +16 -14
- package/.turbo/turbo-build.log +0 -4
- package/dist/BasedServerClient.d.ts +0 -71
- package/dist/BasedServerClient.js +0 -390
- package/dist/BasedServerClient.js.map +0 -1
- package/dist/Client.d.ts +0 -75
- package/dist/Client.js +0 -277
- package/dist/Client.js.map +0 -1
- package/dist/Params.d.ts +0 -20
- package/dist/Params.js +0 -48
- package/dist/Params.js.map +0 -1
- package/dist/auth/authorize.d.ts +0 -2
- package/dist/auth/authorize.js +0 -8
- package/dist/auth/authorize.js.map +0 -1
- package/dist/clientContext.d.ts +0 -0
- package/dist/clientContext.js +0 -83
- package/dist/clientContext.js.map +0 -1
- package/dist/closeListener.d.ts +0 -4
- package/dist/closeListener.js +0 -13
- package/dist/closeListener.js.map +0 -1
- package/dist/error.d.ts +0 -66
- package/dist/error.js +0 -149
- package/dist/error.js.map +0 -1
- package/dist/findPrefix.d.ts +0 -3
- package/dist/findPrefix.js +0 -20
- package/dist/findPrefix.js.map +0 -1
- package/dist/functions/workerPool.d.ts +0 -0
- package/dist/functions/workerPool.js +0 -5
- package/dist/functions/workerPool.js.map +0 -1
- package/dist/getFromConfig.d.ts +0 -3
- package/dist/getFromConfig.js +0 -50
- package/dist/getFromConfig.js.map +0 -1
- package/dist/handlers/authorize.d.ts +0 -5
- package/dist/handlers/authorize.js +0 -196
- package/dist/handlers/authorize.js.map +0 -1
- package/dist/handlers/bulkUpdate/index.d.ts +0 -5
- package/dist/handlers/bulkUpdate/index.js +0 -26
- package/dist/handlers/bulkUpdate/index.js.map +0 -1
- package/dist/handlers/configuration/index.d.ts +0 -10
- package/dist/handlers/configuration/index.js +0 -74
- package/dist/handlers/configuration/index.js.map +0 -1
- package/dist/handlers/configuration/observable/index.d.ts +0 -46
- package/dist/handlers/configuration/observable/index.js +0 -277
- package/dist/handlers/configuration/observable/index.js.map +0 -1
- package/dist/handlers/configure/index.d.ts +0 -5
- package/dist/handlers/configure/index.js +0 -44
- package/dist/handlers/configure/index.js.map +0 -1
- package/dist/handlers/copy/index.d.ts +0 -8
- package/dist/handlers/copy/index.js +0 -135
- package/dist/handlers/copy/index.js.map +0 -1
- package/dist/handlers/delete/index.d.ts +0 -5
- package/dist/handlers/delete/index.js +0 -34
- package/dist/handlers/delete/index.js.map +0 -1
- package/dist/handlers/digest/index.d.ts +0 -5
- package/dist/handlers/digest/index.js +0 -23
- package/dist/handlers/digest/index.js.map +0 -1
- package/dist/handlers/functions/call.d.ts +0 -6
- package/dist/handlers/functions/call.js +0 -54
- package/dist/handlers/functions/call.js.map +0 -1
- package/dist/handlers/functions/observable/Observable.d.ts +0 -49
- package/dist/handlers/functions/observable/Observable.js +0 -290
- package/dist/handlers/functions/observable/Observable.js.map +0 -1
- package/dist/handlers/functions/observable/SharedObservable.d.ts +0 -45
- package/dist/handlers/functions/observable/SharedObservable.js +0 -291
- package/dist/handlers/functions/observable/SharedObservable.js.map +0 -1
- package/dist/handlers/functions/observable/index.d.ts +0 -14
- package/dist/handlers/functions/observable/index.js +0 -130
- package/dist/handlers/functions/observable/index.js.map +0 -1
- package/dist/handlers/get/index.d.ts +0 -5
- package/dist/handlers/get/index.js +0 -23
- package/dist/handlers/get/index.js.map +0 -1
- package/dist/handlers/getConfig/index.d.ts +0 -5
- package/dist/handlers/getConfig/index.js +0 -38
- package/dist/handlers/getConfig/index.js.map +0 -1
- package/dist/handlers/handleRequests.d.ts +0 -5
- package/dist/handlers/handleRequests.js +0 -78
- package/dist/handlers/handleRequests.js.map +0 -1
- package/dist/handlers/index.d.ts +0 -4
- package/dist/handlers/index.js +0 -49
- package/dist/handlers/index.js.map +0 -1
- package/dist/handlers/messageParser.d.ts +0 -5
- package/dist/handlers/messageParser.js +0 -122
- package/dist/handlers/messageParser.js.map +0 -1
- package/dist/handlers/removeField/index.d.ts +0 -5
- package/dist/handlers/removeField/index.js +0 -42
- package/dist/handlers/removeField/index.js.map +0 -1
- package/dist/handlers/removeType/index.d.ts +0 -5
- package/dist/handlers/removeType/index.js +0 -30
- package/dist/handlers/removeType/index.js.map +0 -1
- package/dist/handlers/rest/file/DataStream.js +0 -17
- package/dist/handlers/rest/file/DataStream.js.map +0 -1
- package/dist/handlers/rest/file/formStream.d.ts +0 -4
- package/dist/handlers/rest/file/formStream.js +0 -188
- package/dist/handlers/rest/file/formStream.js.map +0 -1
- package/dist/handlers/rest/file/getExtenstion.d.ts +0 -2
- package/dist/handlers/rest/file/getExtenstion.js +0 -22
- package/dist/handlers/rest/file/getExtenstion.js.map +0 -1
- package/dist/handlers/rest/file/index.d.ts +0 -4
- package/dist/handlers/rest/file/index.js +0 -53
- package/dist/handlers/rest/file/index.js.map +0 -1
- package/dist/handlers/rest/file/storeFile.d.ts +0 -6
- package/dist/handlers/rest/file/storeFile.js +0 -44
- package/dist/handlers/rest/file/storeFile.js.map +0 -1
- package/dist/handlers/rest/file/stream.d.ts +0 -5
- package/dist/handlers/rest/file/stream.js +0 -105
- package/dist/handlers/rest/file/stream.js.map +0 -1
- package/dist/handlers/rest/file/types.d.ts +0 -9
- package/dist/handlers/rest/file/types.js.map +0 -1
- package/dist/handlers/rest/getReqMessage.d.ts +0 -3
- package/dist/handlers/rest/getReqMessage.js +0 -92
- package/dist/handlers/rest/getReqMessage.js.map +0 -1
- package/dist/handlers/rest/index.d.ts +0 -4
- package/dist/handlers/rest/index.js +0 -121
- package/dist/handlers/rest/index.js.map +0 -1
- package/dist/handlers/rest/invalidReq.d.ts +0 -4
- package/dist/handlers/rest/invalidReq.js +0 -20
- package/dist/handlers/rest/invalidReq.js.map +0 -1
- package/dist/handlers/rest/parseResponse.d.ts +0 -6
- package/dist/handlers/rest/parseResponse.js +0 -230
- package/dist/handlers/rest/parseResponse.js.map +0 -1
- package/dist/handlers/rest/playground/index.d.ts +0 -5
- package/dist/handlers/rest/playground/index.js +0 -308
- package/dist/handlers/rest/playground/index.js.map +0 -1
- package/dist/handlers/rest/readBody.d.ts +0 -3
- package/dist/handlers/rest/readBody.js +0 -45
- package/dist/handlers/rest/readBody.js.map +0 -1
- package/dist/handlers/set/index.d.ts +0 -5
- package/dist/handlers/set/index.js +0 -20
- package/dist/handlers/set/index.js.map +0 -1
- package/dist/handlers/subscription/index.d.ts +0 -32
- package/dist/handlers/subscription/index.js +0 -223
- package/dist/handlers/subscription/index.js.map +0 -1
- package/dist/handlers/token.d.ts +0 -5
- package/dist/handlers/token.js +0 -122
- package/dist/handlers/token.js.map +0 -1
- package/dist/handlers/track/index.d.ts +0 -7
- package/dist/handlers/track/index.js +0 -102
- package/dist/handlers/track/index.js.map +0 -1
- package/dist/handlers/userAuth/index.d.ts +0 -5
- package/dist/handlers/userAuth/index.js +0 -78
- package/dist/handlers/userAuth/index.js.map +0 -1
- package/dist/network/http/authorize.d.ts +0 -3
- package/dist/network/http/authorize.js +0 -28
- package/dist/network/http/authorize.js.map +0 -1
- package/dist/network/http/compress.d.ts +0 -6
- package/dist/network/http/compress.js.map +0 -1
- package/dist/network/http/end.d.ts +0 -4
- package/dist/network/http/end.js +0 -19
- package/dist/network/http/end.js.map +0 -1
- package/dist/network/http/function.d.ts +0 -3
- package/dist/network/http/function.js.map +0 -1
- package/dist/network/http/get.d.ts +0 -3
- package/dist/network/http/get.js +0 -129
- package/dist/network/http/get.js.map +0 -1
- package/dist/network/http/index.js +0 -122
- package/dist/network/http/index.js.map +0 -1
- package/dist/network/http/readBody.d.ts +0 -3
- package/dist/network/http/readBody.js.map +0 -1
- package/dist/network/http/send.d.ts +0 -5
- package/dist/network/http/send.js +0 -60
- package/dist/network/http/send.js.map +0 -1
- package/dist/network/http/streamFunction/DataStream.d.ts +0 -7
- package/dist/network/http/streamFunction/DataStream.js.map +0 -1
- package/dist/network/http/streamFunction/getExtension.js.map +0 -1
- package/dist/network/http/streamFunction/index.d.ts +0 -3
- package/dist/network/http/streamFunction/index.js +0 -81
- package/dist/network/http/streamFunction/index.js.map +0 -1
- package/dist/network/http/streamFunction/multipartStream.d.ts +0 -12
- package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
- package/dist/network/http/streamFunction/stream.js.map +0 -1
- package/dist/network/index.d.ts +0 -4
- package/dist/network/index.js.map +0 -1
- package/dist/network/message/auth.d.ts +0 -4
- package/dist/network/message/auth.js +0 -32
- package/dist/network/message/auth.js.map +0 -1
- package/dist/network/message/function.d.ts +0 -3
- package/dist/network/message/function.js +0 -67
- package/dist/network/message/function.js.map +0 -1
- package/dist/network/message/get.d.ts +0 -3
- package/dist/network/message/get.js +0 -109
- package/dist/network/message/get.js.map +0 -1
- package/dist/network/message/index.d.ts +0 -3
- package/dist/network/message/index.js.map +0 -1
- package/dist/network/message/observable.d.ts +0 -5
- package/dist/network/message/observable.js +0 -103
- package/dist/network/message/observable.js.map +0 -1
- package/dist/network/message/send.d.ts +0 -4
- package/dist/network/message/send.js +0 -11
- package/dist/network/message/send.js.map +0 -1
- package/dist/network/upgrade.d.ts +0 -4
- package/dist/network/upgrade.js.map +0 -1
- package/dist/network/worker/get.d.ts +0 -0
- package/dist/network/worker/get.js +0 -122
- package/dist/network/worker/get.js.map +0 -1
- package/dist/network/worker/observable.d.ts +0 -0
- package/dist/network/worker/observable.js +0 -120
- package/dist/network/worker/observable.js.map +0 -1
- package/dist/openListener.d.ts +0 -4
- package/dist/openListener.js +0 -13
- package/dist/openListener.js.map +0 -1
- package/dist/secrets.d.ts +0 -9
- package/dist/secrets.js +0 -150
- package/dist/secrets.js.map +0 -1
- package/dist/security/index.d.ts +0 -2
- package/dist/security/index.js +0 -57
- package/dist/security/index.js.map +0 -1
- package/dist/types.d.ts +0 -129
- package/dist/types.js +0 -17
- package/dist/types.js.map +0 -1
- package/dist/upgradeListener.d.ts +0 -4
- package/dist/upgradeListener.js +0 -47
- package/dist/upgradeListener.js.map +0 -1
- package/dist/worker/authorize.d.ts +0 -5
- package/dist/worker/authorize.js +0 -15
- package/dist/worker/authorize.js.map +0 -1
- package/dist/worker/fnMap.d.ts +0 -2
- package/dist/worker/fnMap.js +0 -5
- package/dist/worker/fnMap.js.map +0 -1
- package/dist/worker/functions.d.ts +0 -3
- package/dist/worker/functions.js +0 -8
- package/dist/worker/functions.js.map +0 -1
- package/dist/worker/http/function.d.ts +0 -4
- package/dist/worker/http/function.js +0 -75
- package/dist/worker/http/function.js.map +0 -1
- package/dist/worker/index.d.ts +0 -1
- package/dist/worker/index.js +0 -101
- package/dist/worker/index.js.map +0 -1
- package/dist/worker/observable.d.ts +0 -15
- package/dist/worker/observable.js +0 -110
- package/dist/worker/observable.js.map +0 -1
- package/dist/worker/ws/function.d.ts +0 -3
- package/dist/worker/ws/function.js +0 -42
- package/dist/worker/ws/function.js.map +0 -1
- package/dist/workers/index.d.ts +0 -0
- package/dist/workers/index.js +0 -20
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/workerCode.d.ts +0 -12
- package/dist/workers/workerCode.js +0 -46
- package/dist/workers/workerCode.js.map +0 -1
package/dist/functions/index.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BasedFunctions =
|
|
4
|
-
const types_1 = require("
|
|
5
|
-
Object.defineProperty(exports, "isObservableFunctionSpec", { enumerable: true, get: function () { return types_1.isObservableFunctionSpec; } });
|
|
17
|
+
exports.BasedFunctions = void 0;
|
|
18
|
+
const types_1 = require("./types");
|
|
6
19
|
const utils_1 = require("@saulx/utils");
|
|
7
20
|
const timeout_1 = require("./timeout");
|
|
8
21
|
const observable_1 = require("../observable");
|
|
9
|
-
|
|
10
|
-
const path_1 = require("path");
|
|
11
|
-
let reqId = 0;
|
|
12
|
-
const WORKER_PATH = (0, path_1.join)(__dirname, '../worker');
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
13
23
|
class BasedFunctions {
|
|
14
24
|
constructor(server, config) {
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
25
|
+
this.reqId = 0;
|
|
26
|
+
this.installsInProgress = {};
|
|
17
27
|
this.paths = {};
|
|
18
|
-
this.
|
|
19
|
-
this.functions = {};
|
|
28
|
+
this.specs = {};
|
|
20
29
|
this.beingUninstalled = {};
|
|
21
30
|
this.server = server;
|
|
22
31
|
if (config) {
|
|
23
32
|
this.updateConfig(config);
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
|
-
workerSortLoop() {
|
|
27
|
-
// or something else?
|
|
28
|
-
// this.workerSortTimeout
|
|
29
|
-
}
|
|
30
35
|
uninstallLoop() {
|
|
31
36
|
this.unregisterTimeout = setTimeout(async () => {
|
|
32
37
|
const q = [];
|
|
33
|
-
for (const name in this.
|
|
34
|
-
const spec = this.
|
|
35
|
-
if (
|
|
36
|
-
q.push(this.uninstall(name, spec));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
for (const name in this.observables) {
|
|
40
|
-
const spec = this.observables[name];
|
|
41
|
-
if (this.server.activeObservables[name]) {
|
|
38
|
+
for (const name in this.specs) {
|
|
39
|
+
const spec = this.specs[name];
|
|
40
|
+
if (spec.observable && this.server.activeObservables[name]) {
|
|
42
41
|
(0, timeout_1.updateTimeoutCounter)(spec);
|
|
43
42
|
}
|
|
44
43
|
else if ((0, timeout_1.fnIsTimedOut)(spec)) {
|
|
@@ -65,101 +64,51 @@ class BasedFunctions {
|
|
|
65
64
|
if (this.config.maxWorkers === undefined) {
|
|
66
65
|
this.config.maxWorkers = 1;
|
|
67
66
|
}
|
|
68
|
-
if (this.config.log === undefined) {
|
|
69
|
-
this.config.log = (opts) => {
|
|
70
|
-
console.info(opts);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
67
|
if (this.unregisterTimeout) {
|
|
74
68
|
clearTimeout(this.unregisterTimeout);
|
|
75
69
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
this.uninstallLoop();
|
|
71
|
+
}
|
|
72
|
+
async updateFunction(spec) {
|
|
73
|
+
const { name } = spec;
|
|
74
|
+
const prevSpec = this.specs[name];
|
|
75
|
+
if (prevSpec) {
|
|
76
|
+
if (prevSpec.function !== spec.function) {
|
|
77
|
+
if (this.beingUninstalled[name]) {
|
|
78
|
+
delete this.beingUninstalled[name];
|
|
84
79
|
}
|
|
80
|
+
(0, timeout_1.updateTimeoutCounter)(spec);
|
|
81
|
+
await this.installGaurdedFromConfig(name);
|
|
82
|
+
await this.config.uninstall({
|
|
83
|
+
server: this.server,
|
|
84
|
+
function: prevSpec,
|
|
85
|
+
name,
|
|
86
|
+
});
|
|
87
|
+
this.update(spec);
|
|
85
88
|
}
|
|
86
89
|
else {
|
|
87
|
-
|
|
88
|
-
const worker = new node_worker_threads_1.Worker(WORKER_PATH, {});
|
|
89
|
-
this.workers.push({
|
|
90
|
-
worker,
|
|
91
|
-
index: this.workers.length,
|
|
92
|
-
activeObservables: 0,
|
|
93
|
-
activeFunctions: 0,
|
|
94
|
-
});
|
|
95
|
-
if (this.server.auth) {
|
|
96
|
-
// allways install authorize
|
|
97
|
-
worker.postMessage({
|
|
98
|
-
type: 5,
|
|
99
|
-
name: 'authorize',
|
|
100
|
-
path: this.server.auth.config.authorizePath,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
worker.on('message', (data) => {
|
|
104
|
-
// type 0 is just install fn
|
|
105
|
-
// subscribe and close will just go the normal way
|
|
106
|
-
if (data.type === 0) {
|
|
107
|
-
this.install(data.name)
|
|
108
|
-
.then((spec) => {
|
|
109
|
-
if (spec) {
|
|
110
|
-
worker.postMessage({
|
|
111
|
-
type: 5,
|
|
112
|
-
name: spec.name,
|
|
113
|
-
path: spec.functionPath,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
worker.postMessage({
|
|
118
|
-
type: 7,
|
|
119
|
-
name: data.name,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
.catch(() => {
|
|
124
|
-
worker.postMessage({
|
|
125
|
-
type: 7,
|
|
126
|
-
name: data.name,
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
else if (data.id) {
|
|
131
|
-
const listener = this.workerResponseListeners.get(data.id);
|
|
132
|
-
// prob need more here
|
|
133
|
-
if (listener) {
|
|
134
|
-
listener(data.err, data.payload);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
90
|
+
this.update(spec);
|
|
139
91
|
}
|
|
140
92
|
}
|
|
141
|
-
|
|
142
|
-
|
|
93
|
+
}
|
|
94
|
+
async installGaurdedFromConfig(name) {
|
|
95
|
+
if (this.installsInProgress[name]) {
|
|
96
|
+
return this.installsInProgress[name];
|
|
143
97
|
}
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
})[0];
|
|
152
|
-
this.uninstallLoop();
|
|
98
|
+
this.installsInProgress[name] = this.config.install({
|
|
99
|
+
server: this.server,
|
|
100
|
+
name,
|
|
101
|
+
});
|
|
102
|
+
const s = await this.installsInProgress[name];
|
|
103
|
+
delete this.installsInProgress[name];
|
|
104
|
+
return s;
|
|
153
105
|
}
|
|
154
106
|
async install(name) {
|
|
155
107
|
let spec = this.getFromStore(name);
|
|
156
108
|
if (spec) {
|
|
157
109
|
return spec;
|
|
158
110
|
}
|
|
159
|
-
spec = await this.
|
|
160
|
-
server: this.server,
|
|
161
|
-
name,
|
|
162
|
-
});
|
|
111
|
+
spec = await this.installGaurdedFromConfig(name);
|
|
163
112
|
if (spec) {
|
|
164
113
|
this.update(spec);
|
|
165
114
|
return this.getFromStore(name);
|
|
@@ -170,28 +119,12 @@ class BasedFunctions {
|
|
|
170
119
|
return this.paths[path];
|
|
171
120
|
}
|
|
172
121
|
route(name, path) {
|
|
173
|
-
|
|
174
|
-
if (result && !result.maxPayloadSize) {
|
|
175
|
-
if (result.observable) {
|
|
176
|
-
// 50kb
|
|
177
|
-
result.maxPayloadSize = 50000;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
if (result.stream) {
|
|
181
|
-
result.maxPayloadSize = -1;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
result.maxPayloadSize = 250000;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return result;
|
|
122
|
+
return this.config.route({ server: this.server, name, path });
|
|
189
123
|
}
|
|
190
124
|
getFromStore(name) {
|
|
191
|
-
const spec = this.
|
|
125
|
+
const spec = this.specs[name];
|
|
192
126
|
if (spec) {
|
|
193
127
|
if (this.beingUninstalled[name]) {
|
|
194
|
-
console.info('getFromStore is being uninstalled', name);
|
|
195
128
|
delete this.beingUninstalled[name];
|
|
196
129
|
}
|
|
197
130
|
(0, timeout_1.updateTimeoutCounter)(spec);
|
|
@@ -200,199 +133,77 @@ class BasedFunctions {
|
|
|
200
133
|
return false;
|
|
201
134
|
}
|
|
202
135
|
update(spec) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
else if (this.observables[spec.name]) {
|
|
221
|
-
for (const w of this.workers) {
|
|
222
|
-
w.worker.postMessage({
|
|
223
|
-
type: 6,
|
|
224
|
-
name: spec.name,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
this.observables[spec.name] = spec;
|
|
229
|
-
if (this.server.activeObservables[spec.name]) {
|
|
230
|
-
for (const [id] of this.server.activeObservables[spec.name]) {
|
|
231
|
-
(0, observable_1.initFunction)(this.server, id);
|
|
232
|
-
}
|
|
136
|
+
if (!spec) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
if (!spec.idleTimeout) {
|
|
140
|
+
spec.idleTimeout = this.config.idleTimeout;
|
|
141
|
+
}
|
|
142
|
+
if (spec.timeoutCounter === undefined) {
|
|
143
|
+
spec.timeoutCounter =
|
|
144
|
+
spec.idleTimeout === 0 ? -1 : Math.ceil(spec.idleTimeout / 1e3);
|
|
145
|
+
}
|
|
146
|
+
if (spec.path) {
|
|
147
|
+
this.paths[spec.path] = spec.name;
|
|
148
|
+
}
|
|
149
|
+
if (this.specs[spec.name] && this.server.activeObservables[spec.name]) {
|
|
150
|
+
if (!(0, types_1.isObservableFunctionSpec)(spec)) {
|
|
151
|
+
for (const [id] of this.server.activeObservables[spec.name]) {
|
|
152
|
+
(0, observable_1.destroyObs)(this.server, id);
|
|
233
153
|
}
|
|
234
154
|
}
|
|
235
155
|
else {
|
|
236
|
-
|
|
237
|
-
|
|
156
|
+
for (const [id] of this.server.activeObservables[spec.name]) {
|
|
157
|
+
(0, observable_1.start)(this.server, id);
|
|
238
158
|
}
|
|
239
|
-
else if (this.functions[spec.name]) {
|
|
240
|
-
for (const w of this.workers) {
|
|
241
|
-
w.worker.postMessage({
|
|
242
|
-
type: 6,
|
|
243
|
-
name: spec.name,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
this.functions[spec.name] = spec;
|
|
248
159
|
}
|
|
249
160
|
}
|
|
161
|
+
this.specs[spec.name] = spec;
|
|
250
162
|
return false;
|
|
251
163
|
}
|
|
252
164
|
remove(name) {
|
|
253
165
|
// Does not call unregister!
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
166
|
+
const spec = this.specs[name];
|
|
167
|
+
if (!spec) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if ((0, types_1.isObservableFunctionSpec)(spec)) {
|
|
259
171
|
const activeObs = this.server.activeObservables[name];
|
|
260
172
|
if (activeObs) {
|
|
261
173
|
for (const [id] of activeObs) {
|
|
262
|
-
(0, observable_1.
|
|
174
|
+
(0, observable_1.destroyObs)(this.server, id);
|
|
263
175
|
}
|
|
264
176
|
delete this.server.activeObservables[name];
|
|
265
177
|
}
|
|
266
|
-
// this is a bit harder... not allways relevant
|
|
267
|
-
for (const w of this.workers) {
|
|
268
|
-
w.worker.postMessage({
|
|
269
|
-
type: 6,
|
|
270
|
-
name,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
return true;
|
|
274
178
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
delete this.paths[this.functions[name].path];
|
|
278
|
-
}
|
|
279
|
-
delete this.functions[name];
|
|
280
|
-
for (const w of this.workers) {
|
|
281
|
-
w.worker.postMessage({
|
|
282
|
-
type: 6,
|
|
283
|
-
name,
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
return false;
|
|
179
|
+
delete this.specs[name];
|
|
180
|
+
return true;
|
|
289
181
|
}
|
|
290
182
|
async uninstall(name, spec) {
|
|
291
183
|
if (this.beingUninstalled[name]) {
|
|
292
184
|
console.error('Allready being unregistered...', name);
|
|
293
185
|
}
|
|
294
186
|
if (!spec && spec !== false) {
|
|
295
|
-
spec = this.
|
|
187
|
+
spec = this.specs[name];
|
|
296
188
|
}
|
|
297
|
-
if (spec) {
|
|
298
|
-
|
|
299
|
-
if (await this.config.uninstall({
|
|
300
|
-
server: this.server,
|
|
301
|
-
function: spec,
|
|
302
|
-
name,
|
|
303
|
-
})) {
|
|
304
|
-
if (this.beingUninstalled[name]) {
|
|
305
|
-
delete this.beingUninstalled[name];
|
|
306
|
-
return this.remove(name);
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
console.info('got requested while being unregistered', name);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
189
|
+
if (!spec) {
|
|
190
|
+
return false;
|
|
312
191
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
192
|
+
this.beingUninstalled[name] = true;
|
|
193
|
+
if (await this.config.uninstall({
|
|
194
|
+
server: this.server,
|
|
195
|
+
function: spec,
|
|
196
|
+
name,
|
|
197
|
+
})) {
|
|
198
|
+
if (this.beingUninstalled[name]) {
|
|
199
|
+
delete this.beingUninstalled[name];
|
|
200
|
+
return this.remove(name);
|
|
322
201
|
}
|
|
323
202
|
else {
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
selectedWorker.worker.postMessage({
|
|
328
|
-
type: 1,
|
|
329
|
-
id,
|
|
330
|
-
name: spec.name,
|
|
331
|
-
path: spec.functionPath,
|
|
332
|
-
payload,
|
|
333
|
-
});
|
|
334
|
-
return () => {
|
|
335
|
-
this.workerResponseListeners.delete(id);
|
|
336
|
-
selectedWorker.worker.postMessage({
|
|
337
|
-
id,
|
|
338
|
-
type: 2,
|
|
339
|
-
});
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
async runFunction(type,
|
|
343
|
-
// 0 is normal function WS
|
|
344
|
-
// 3 is POST payload
|
|
345
|
-
// 4 is GET payload
|
|
346
|
-
spec, context, // make this specific
|
|
347
|
-
payload) {
|
|
348
|
-
// TODO: move selection criteria etc to other file
|
|
349
|
-
return new Promise((resolve, reject) => {
|
|
350
|
-
const listenerId = ++reqId;
|
|
351
|
-
// max concurrent execution is 1 mil...
|
|
352
|
-
if (this.workerResponseListeners.size >= 1e6) {
|
|
353
|
-
throw new Error('MAX CONCURRENT SERVER FUNCTION EXECUTION REACHED (1 MIL)');
|
|
203
|
+
console.info('got requested while being unregistered', name);
|
|
354
204
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
const selectedWorker = this.lowestWorker;
|
|
359
|
-
this.workerResponseListeners.set(listenerId, (err, p) => {
|
|
360
|
-
this.workerResponseListeners.delete(listenerId);
|
|
361
|
-
// include observables
|
|
362
|
-
selectedWorker.activeFunctions--;
|
|
363
|
-
if (selectedWorker.activeFunctions < this.lowestWorker.activeFunctions) {
|
|
364
|
-
this.lowestWorker = selectedWorker;
|
|
365
|
-
}
|
|
366
|
-
if (err) {
|
|
367
|
-
reject(err);
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
// prob shared array buffer...
|
|
371
|
-
resolve(p);
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
selectedWorker.activeFunctions++;
|
|
375
|
-
let next = selectedWorker.index + 1;
|
|
376
|
-
if (next >= this.workers.length) {
|
|
377
|
-
next = 0;
|
|
378
|
-
}
|
|
379
|
-
if (selectedWorker.activeFunctions > this.workers[next].activeFunctions) {
|
|
380
|
-
this.lowestWorker = this.workers[next];
|
|
381
|
-
}
|
|
382
|
-
selectedWorker.worker.postMessage({
|
|
383
|
-
type,
|
|
384
|
-
path: spec.functionPath,
|
|
385
|
-
name: spec.name,
|
|
386
|
-
payload,
|
|
387
|
-
context,
|
|
388
|
-
id: listenerId,
|
|
389
|
-
});
|
|
390
|
-
// console.info(
|
|
391
|
-
// 'SPEED',
|
|
392
|
-
// selectedWorker.worker.threadId,
|
|
393
|
-
// selectedWorker.worker.performance.eventLoopUtilization()
|
|
394
|
-
// )
|
|
395
|
-
});
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
396
207
|
}
|
|
397
208
|
}
|
|
398
209
|
exports.BasedFunctions = BasedFunctions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;AACA,oCAMiB;AAiBR,yGAlBP,gCAAwB,OAkBO;AAhBjC,wCAAwC;AACxC,uCAA8D;AAC9D,8CAAqD;AACrD,6DAA4C;AAC5C,+BAA2B;AAc3B,IAAI,KAAK,GAAG,CAAC,CAAA;AAEb,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAEhD,MAAa,cAAc;IA6BzB,YAAY,MAAmB,EAAE,MAAuB;QAtBxD,YAAO,GAAkB,EAAE,CAAA;QAE3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Spec, BasedObservableFunctionSpec } from './types';
|
|
2
2
|
export declare const fnIsTimedOut: (spec: BasedObservableFunctionSpec | BasedFunctionSpec) => boolean;
|
|
3
3
|
export declare const updateTimeoutCounter: (spec: BasedObservableFunctionSpec | BasedFunctionSpec) => void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Context, HttpSession } from '../context';
|
|
2
|
+
import { ObservableUpdateFunction } from '../observable';
|
|
3
|
+
import { BasedServer } from '../server';
|
|
4
|
+
export declare type CustomHttpResponse = (result: any, payload: any, client: Context<HttpSession>) => Promise<boolean>;
|
|
5
|
+
export declare type BasedFunctionRoute = {
|
|
6
|
+
name: string;
|
|
7
|
+
observable?: boolean;
|
|
8
|
+
headers?: string[];
|
|
9
|
+
path?: string;
|
|
10
|
+
stream?: boolean;
|
|
11
|
+
maxPayloadSize?: number;
|
|
12
|
+
rateLimitTokens?: number;
|
|
13
|
+
public?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare type BasedObservableFunction = (payload: any, update: ObservableUpdateFunction) => Promise<() => void>;
|
|
16
|
+
export declare type BasedObservableFunctionSpec = BasedFunctionRoute & {
|
|
17
|
+
name: string;
|
|
18
|
+
checksum: number;
|
|
19
|
+
observable: true;
|
|
20
|
+
function: BasedObservableFunction;
|
|
21
|
+
stickyWorker?: string;
|
|
22
|
+
customHttpResponse?: CustomHttpResponse;
|
|
23
|
+
memCacheTimeout?: number;
|
|
24
|
+
idleTimeout?: number;
|
|
25
|
+
timeoutCounter?: number;
|
|
26
|
+
};
|
|
27
|
+
export declare type BasedFunction = (payload: any, client: Context) => Promise<any>;
|
|
28
|
+
export declare type BasedFunctionSpec = BasedFunctionRoute & {
|
|
29
|
+
name: string;
|
|
30
|
+
observable?: false;
|
|
31
|
+
customHttpResponse?: CustomHttpResponse;
|
|
32
|
+
checksum: number;
|
|
33
|
+
stickyWorker?: string;
|
|
34
|
+
function: BasedFunction;
|
|
35
|
+
maxExecTime?: number;
|
|
36
|
+
idleTimeout?: number;
|
|
37
|
+
timeoutCounter?: number;
|
|
38
|
+
};
|
|
39
|
+
export declare type FunctionConfig = {
|
|
40
|
+
memCacheTimeout?: number;
|
|
41
|
+
idleTimeout?: number;
|
|
42
|
+
maxWorkers?: number;
|
|
43
|
+
importWrapperPath?: string;
|
|
44
|
+
route: (opts: {
|
|
45
|
+
server: BasedServer;
|
|
46
|
+
name?: string;
|
|
47
|
+
path?: string;
|
|
48
|
+
}) => false | (BasedFunctionRoute & {
|
|
49
|
+
maxPayloadSize: number;
|
|
50
|
+
rateLimitTokens: number;
|
|
51
|
+
});
|
|
52
|
+
install: (opts: {
|
|
53
|
+
server: BasedServer;
|
|
54
|
+
name: string;
|
|
55
|
+
function?: BasedFunctionSpec | BasedObservableFunctionSpec;
|
|
56
|
+
}) => Promise<false | BasedObservableFunctionSpec | BasedFunctionSpec>;
|
|
57
|
+
uninstall: (opts: {
|
|
58
|
+
server: BasedServer;
|
|
59
|
+
name: string;
|
|
60
|
+
function: BasedObservableFunctionSpec | BasedFunctionSpec;
|
|
61
|
+
}) => Promise<boolean>;
|
|
62
|
+
};
|
|
63
|
+
export declare enum FunctionType {
|
|
64
|
+
authorize = 0,
|
|
65
|
+
observe = 1,
|
|
66
|
+
function = 2,
|
|
67
|
+
streamFunction = 3
|
|
68
|
+
}
|
|
69
|
+
export declare function isObservableFunctionSpec(fn: BasedObservableFunctionSpec | BasedFunctionSpec): fn is BasedObservableFunctionSpec;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObservableFunctionSpec = exports.FunctionType = void 0;
|
|
4
|
+
var FunctionType;
|
|
5
|
+
(function (FunctionType) {
|
|
6
|
+
FunctionType[FunctionType["authorize"] = 0] = "authorize";
|
|
7
|
+
FunctionType[FunctionType["observe"] = 1] = "observe";
|
|
8
|
+
FunctionType[FunctionType["function"] = 2] = "function";
|
|
9
|
+
FunctionType[FunctionType["streamFunction"] = 3] = "streamFunction";
|
|
10
|
+
})(FunctionType = exports.FunctionType || (exports.FunctionType = {}));
|
|
11
|
+
function isObservableFunctionSpec(fn) {
|
|
12
|
+
return fn.observable;
|
|
13
|
+
}
|
|
14
|
+
exports.isObservableFunctionSpec = isObservableFunctionSpec;
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/functions/types.ts"],"names":[],"mappings":";;;AA6EA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,yDAAS,CAAA;IACT,qDAAO,CAAA;IACP,uDAAQ,CAAA;IACR,mEAAc,CAAA;AAChB,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB;AAED,SAAgB,wBAAwB,CACtC,EAAmD;IAEnD,OAAQ,EAAkC,CAAC,UAAU,CAAA;AACvD,CAAC;AAJD,4DAIC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BasedServer } from '../../server';
|
|
2
|
+
import { BasedFunctionRoute } from '../../functions';
|
|
3
|
+
import { HttpSession, Context } from '../../context';
|
|
4
|
+
export declare const authorizeRequest: (server: BasedServer, ctx: Context<HttpSession>, payload: any, route: BasedFunctionRoute, authorized: (payload: any) => void, notAuth?: () => void) => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authorizeRequest = void 0;
|
|
4
|
+
const sendError_1 = require("../../sendError");
|
|
5
|
+
const error_1 = require("../../error");
|
|
6
|
+
const authorizeRequest = (server, ctx, payload, route, authorized, notAuth = () => undefined) => {
|
|
7
|
+
if (route.public === true) {
|
|
8
|
+
authorized(payload);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
server.auth
|
|
12
|
+
.authorize(ctx, route.name, payload)
|
|
13
|
+
.then((ok) => {
|
|
14
|
+
if (!ctx.session) {
|
|
15
|
+
notAuth();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!ok) {
|
|
19
|
+
notAuth();
|
|
20
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.AuthorizeRejectedError, {
|
|
21
|
+
route,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
authorized(payload);
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
.catch((err) => {
|
|
29
|
+
notAuth();
|
|
30
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
31
|
+
route,
|
|
32
|
+
err,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.authorizeRequest = authorizeRequest;
|
|
37
|
+
//# sourceMappingURL=authorize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../../src/incoming/http/authorize.ts"],"names":[],"mappings":";;;AAEA,+CAA2C;AAC3C,uCAA4C;AAGrC,MAAM,gBAAgB,GAAG,CAC9B,MAAmB,EACnB,GAAyB,EACzB,OAAY,EACZ,KAAyB,EACzB,UAAkC,EAClC,UAAsB,GAAG,EAAE,CAAC,SAAS,EACrC,EAAE;IACF,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,EAAE;QACzB,UAAU,CAAC,OAAO,CAAC,CAAA;QACnB,OAAM;KACP;IAED,MAAM,CAAC,IAAI;SACR,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;SACnC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE;QACX,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YAChB,OAAO,EAAE,CAAA;YACT,OAAM;SACP;QACD,IAAI,CAAC,EAAE,EAAE;YACP,OAAO,EAAE,CAAA;YACT,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,sBAAsB,EAAE;gBAC5D,KAAK;aACN,CAAC,CAAA;SACH;aAAM;YACL,UAAU,CAAC,OAAO,CAAC,CAAA;SACpB;IACH,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,EAAE,CAAA;QACT,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,sBAAsB,EAAE;YAC5D,KAAK;YACL,GAAG;SACJ,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AApCY,QAAA,gBAAgB,oBAoC5B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BasedServer } from '../../server';
|
|
2
|
+
import { BasedFunctionRoute } from '../../functions';
|
|
3
|
+
import { HttpSession, Context } from '../../context';
|
|
4
|
+
export declare const httpFunction: (route: BasedFunctionRoute, ctx: Context<HttpSession>, server: BasedServer, payload?: Uint8Array) => void;
|