@teamkeel/functions-runtime 0.221.2 → 0.221.4
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/index.d.ts +20 -10
- package/dist/index.js +1001 -25
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,12 @@ declare module '@teamkeel/functions-runtime/constraints' {
|
|
|
28
28
|
};
|
|
29
29
|
export type EnumConstraint = StringConstraint;
|
|
30
30
|
|
|
31
|
+
}
|
|
32
|
+
declare module '@teamkeel/functions-runtime/customFunctions/index' {
|
|
33
|
+
import { Config, CustomFunctionResponsePayload, CustomFunctionRequestPayload } from "@teamkeel/functions-runtime/types";
|
|
34
|
+
const handler: ({ method, params, id }: CustomFunctionRequestPayload, config: Config) => Promise<CustomFunctionResponsePayload>;
|
|
35
|
+
export default handler;
|
|
36
|
+
|
|
31
37
|
}
|
|
32
38
|
declare module '@teamkeel/functions-runtime/db/query' {
|
|
33
39
|
export type SqlQueryParts = SqlQueryPart[];
|
|
@@ -94,22 +100,17 @@ declare module '@teamkeel/functions-runtime/fetch/index' {
|
|
|
94
100
|
const _default: (uri: string, opts: RequestOpts) => Promise<import("node-fetch").Response>;
|
|
95
101
|
export default _default;
|
|
96
102
|
|
|
97
|
-
}
|
|
98
|
-
declare module '@teamkeel/functions-runtime/handler/index' {
|
|
99
|
-
import { Config } from "@teamkeel/functions-runtime/types";
|
|
100
|
-
const startRuntimeServer: ({ functions, api }: Config) => void;
|
|
101
|
-
export default startRuntimeServer;
|
|
102
|
-
|
|
103
103
|
}
|
|
104
104
|
declare module '@teamkeel/functions-runtime/index' {
|
|
105
105
|
import Query, { ChainableQuery } from "@teamkeel/functions-runtime/query";
|
|
106
106
|
import * as QueryConstraints from "@teamkeel/functions-runtime/constraints";
|
|
107
107
|
import Logger, { ConsoleTransport, Level as LogLevel } from "@teamkeel/functions-runtime/logger/index";
|
|
108
108
|
import { Identity } from "@teamkeel/functions-runtime/types";
|
|
109
|
+
import handleCustomFunction from "@teamkeel/functions-runtime/customFunctions/index";
|
|
109
110
|
export * from "@teamkeel/functions-runtime/returnTypes";
|
|
110
111
|
export * from "@teamkeel/functions-runtime/db/resolver";
|
|
111
112
|
import { queryResolverFromEnv } from "@teamkeel/functions-runtime/db/resolver";
|
|
112
|
-
export { Query, ChainableQuery, QueryConstraints, Logger, ConsoleTransport, LogLevel, Identity, queryResolverFromEnv, };
|
|
113
|
+
export { Query, ChainableQuery, QueryConstraints, Logger, ConsoleTransport, LogLevel, Identity, queryResolverFromEnv, handleCustomFunction, };
|
|
113
114
|
|
|
114
115
|
}
|
|
115
116
|
declare module '@teamkeel/functions-runtime/logger/index' {
|
|
@@ -239,8 +240,10 @@ declare module '@teamkeel/functions-runtime/staticAnalysis/cli' {
|
|
|
239
240
|
|
|
240
241
|
}
|
|
241
242
|
declare module '@teamkeel/functions-runtime/types' {
|
|
243
|
+
import { JSONRPCParams, JSONRPCRequest, JSONRPCResponse } from "json-rpc-2.0";
|
|
242
244
|
import { StringConstraint, BooleanConstraint, NumberConstraint, DateConstraint, EnumConstraint } from "@teamkeel/functions-runtime/constraints";
|
|
243
245
|
import { Logger } from "@teamkeel/functions-runtime/index";
|
|
246
|
+
import Query from "@teamkeel/functions-runtime/query";
|
|
244
247
|
import { QueryResolver } from "@teamkeel/functions-runtime/db/resolver";
|
|
245
248
|
export interface QueryOpts {
|
|
246
249
|
tableName: string;
|
|
@@ -266,13 +269,20 @@ declare module '@teamkeel/functions-runtime/types' {
|
|
|
266
269
|
id: string;
|
|
267
270
|
email: string;
|
|
268
271
|
}
|
|
272
|
+
export type CustomFunctionRequestPayload = JSONRPCRequest;
|
|
273
|
+
export type CustomFunctionResponsePayload = JSONRPCResponse;
|
|
269
274
|
export interface CustomFunction {
|
|
270
|
-
call: any
|
|
275
|
+
call: (payload: JSONRPCParams, api: API) => Promise<any>;
|
|
271
276
|
}
|
|
277
|
+
type API = {
|
|
278
|
+
[apiName: string]: Query<BuiltInFields>;
|
|
279
|
+
};
|
|
280
|
+
export type Functions = Record<string, CustomFunction>;
|
|
272
281
|
export interface Config {
|
|
273
|
-
functions:
|
|
274
|
-
api:
|
|
282
|
+
functions: Functions;
|
|
283
|
+
api: API;
|
|
275
284
|
}
|
|
285
|
+
export {};
|
|
276
286
|
|
|
277
287
|
}
|
|
278
288
|
declare module '@teamkeel/functions-runtime/util/camelCaser' {
|
package/dist/index.js
CHANGED
|
@@ -2572,6 +2572,943 @@ var require_source = __commonJS({
|
|
|
2572
2572
|
}
|
|
2573
2573
|
});
|
|
2574
2574
|
|
|
2575
|
+
// node_modules/json-rpc-2.0/dist/models.js
|
|
2576
|
+
var require_models = __commonJS({
|
|
2577
|
+
"node_modules/json-rpc-2.0/dist/models.js"(exports) {
|
|
2578
|
+
"use strict";
|
|
2579
|
+
var __extends = exports && exports.__extends || function() {
|
|
2580
|
+
var extendStatics = function(d, b) {
|
|
2581
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
2582
|
+
d2.__proto__ = b2;
|
|
2583
|
+
} || function(d2, b2) {
|
|
2584
|
+
for (var p in b2)
|
|
2585
|
+
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
2586
|
+
d2[p] = b2[p];
|
|
2587
|
+
};
|
|
2588
|
+
return extendStatics(d, b);
|
|
2589
|
+
};
|
|
2590
|
+
return function(d, b) {
|
|
2591
|
+
if (typeof b !== "function" && b !== null)
|
|
2592
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2593
|
+
extendStatics(d, b);
|
|
2594
|
+
function __() {
|
|
2595
|
+
this.constructor = d;
|
|
2596
|
+
}
|
|
2597
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2598
|
+
};
|
|
2599
|
+
}();
|
|
2600
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2601
|
+
exports.createJSONRPCNotification = exports.createJSONRPCRequest = exports.createJSONRPCSuccessResponse = exports.createJSONRPCErrorResponse = exports.JSONRPCErrorCode = exports.JSONRPCErrorException = exports.isJSONRPCResponses = exports.isJSONRPCResponse = exports.isJSONRPCRequests = exports.isJSONRPCRequest = exports.isJSONRPCID = exports.JSONRPC = void 0;
|
|
2602
|
+
exports.JSONRPC = "2.0";
|
|
2603
|
+
var isJSONRPCID = function(id) {
|
|
2604
|
+
return typeof id === "string" || typeof id === "number" || id === null;
|
|
2605
|
+
};
|
|
2606
|
+
exports.isJSONRPCID = isJSONRPCID;
|
|
2607
|
+
var isJSONRPCRequest = function(payload) {
|
|
2608
|
+
return payload.jsonrpc === exports.JSONRPC && payload.method !== void 0 && payload.result === void 0 && payload.error === void 0;
|
|
2609
|
+
};
|
|
2610
|
+
exports.isJSONRPCRequest = isJSONRPCRequest;
|
|
2611
|
+
var isJSONRPCRequests = function(payload) {
|
|
2612
|
+
return Array.isArray(payload) && payload.every(exports.isJSONRPCRequest);
|
|
2613
|
+
};
|
|
2614
|
+
exports.isJSONRPCRequests = isJSONRPCRequests;
|
|
2615
|
+
var isJSONRPCResponse = function(payload) {
|
|
2616
|
+
return payload.jsonrpc === exports.JSONRPC && payload.id !== void 0 && (payload.result !== void 0 || payload.error !== void 0);
|
|
2617
|
+
};
|
|
2618
|
+
exports.isJSONRPCResponse = isJSONRPCResponse;
|
|
2619
|
+
var isJSONRPCResponses = function(payload) {
|
|
2620
|
+
return Array.isArray(payload) && payload.every(exports.isJSONRPCResponse);
|
|
2621
|
+
};
|
|
2622
|
+
exports.isJSONRPCResponses = isJSONRPCResponses;
|
|
2623
|
+
var createJSONRPCError = function(code, message, data) {
|
|
2624
|
+
var error = { code, message };
|
|
2625
|
+
if (data != null) {
|
|
2626
|
+
error.data = data;
|
|
2627
|
+
}
|
|
2628
|
+
return error;
|
|
2629
|
+
};
|
|
2630
|
+
var JSONRPCErrorException = function(_super) {
|
|
2631
|
+
__extends(JSONRPCErrorException2, _super);
|
|
2632
|
+
function JSONRPCErrorException2(message, code, data) {
|
|
2633
|
+
var _this = _super.call(this, message) || this;
|
|
2634
|
+
Object.setPrototypeOf(_this, JSONRPCErrorException2.prototype);
|
|
2635
|
+
_this.code = code;
|
|
2636
|
+
_this.data = data;
|
|
2637
|
+
return _this;
|
|
2638
|
+
}
|
|
2639
|
+
JSONRPCErrorException2.prototype.toObject = function() {
|
|
2640
|
+
return createJSONRPCError(this.code, this.message, this.data);
|
|
2641
|
+
};
|
|
2642
|
+
return JSONRPCErrorException2;
|
|
2643
|
+
}(Error);
|
|
2644
|
+
exports.JSONRPCErrorException = JSONRPCErrorException;
|
|
2645
|
+
var JSONRPCErrorCode2;
|
|
2646
|
+
(function(JSONRPCErrorCode3) {
|
|
2647
|
+
JSONRPCErrorCode3[JSONRPCErrorCode3["ParseError"] = -32700] = "ParseError";
|
|
2648
|
+
JSONRPCErrorCode3[JSONRPCErrorCode3["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
2649
|
+
JSONRPCErrorCode3[JSONRPCErrorCode3["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
2650
|
+
JSONRPCErrorCode3[JSONRPCErrorCode3["InvalidParams"] = -32602] = "InvalidParams";
|
|
2651
|
+
JSONRPCErrorCode3[JSONRPCErrorCode3["InternalError"] = -32603] = "InternalError";
|
|
2652
|
+
})(JSONRPCErrorCode2 = exports.JSONRPCErrorCode || (exports.JSONRPCErrorCode = {}));
|
|
2653
|
+
var createJSONRPCErrorResponse2 = function(id, code, message, data) {
|
|
2654
|
+
return {
|
|
2655
|
+
jsonrpc: exports.JSONRPC,
|
|
2656
|
+
id,
|
|
2657
|
+
error: createJSONRPCError(code, message, data)
|
|
2658
|
+
};
|
|
2659
|
+
};
|
|
2660
|
+
exports.createJSONRPCErrorResponse = createJSONRPCErrorResponse2;
|
|
2661
|
+
var createJSONRPCSuccessResponse2 = function(id, result) {
|
|
2662
|
+
return {
|
|
2663
|
+
jsonrpc: exports.JSONRPC,
|
|
2664
|
+
id,
|
|
2665
|
+
result: result !== null && result !== void 0 ? result : null
|
|
2666
|
+
};
|
|
2667
|
+
};
|
|
2668
|
+
exports.createJSONRPCSuccessResponse = createJSONRPCSuccessResponse2;
|
|
2669
|
+
var createJSONRPCRequest = function(id, method, params) {
|
|
2670
|
+
return {
|
|
2671
|
+
jsonrpc: exports.JSONRPC,
|
|
2672
|
+
id,
|
|
2673
|
+
method,
|
|
2674
|
+
params
|
|
2675
|
+
};
|
|
2676
|
+
};
|
|
2677
|
+
exports.createJSONRPCRequest = createJSONRPCRequest;
|
|
2678
|
+
var createJSONRPCNotification = function(method, params) {
|
|
2679
|
+
return {
|
|
2680
|
+
jsonrpc: exports.JSONRPC,
|
|
2681
|
+
method,
|
|
2682
|
+
params
|
|
2683
|
+
};
|
|
2684
|
+
};
|
|
2685
|
+
exports.createJSONRPCNotification = createJSONRPCNotification;
|
|
2686
|
+
}
|
|
2687
|
+
});
|
|
2688
|
+
|
|
2689
|
+
// node_modules/json-rpc-2.0/dist/internal.js
|
|
2690
|
+
var require_internal = __commonJS({
|
|
2691
|
+
"node_modules/json-rpc-2.0/dist/internal.js"(exports) {
|
|
2692
|
+
"use strict";
|
|
2693
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2694
|
+
exports.DefaultErrorCode = void 0;
|
|
2695
|
+
exports.DefaultErrorCode = 0;
|
|
2696
|
+
}
|
|
2697
|
+
});
|
|
2698
|
+
|
|
2699
|
+
// node_modules/json-rpc-2.0/dist/client.js
|
|
2700
|
+
var require_client = __commonJS({
|
|
2701
|
+
"node_modules/json-rpc-2.0/dist/client.js"(exports) {
|
|
2702
|
+
"use strict";
|
|
2703
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2704
|
+
function adopt(value) {
|
|
2705
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2706
|
+
resolve(value);
|
|
2707
|
+
});
|
|
2708
|
+
}
|
|
2709
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2710
|
+
function fulfilled(value) {
|
|
2711
|
+
try {
|
|
2712
|
+
step(generator.next(value));
|
|
2713
|
+
} catch (e) {
|
|
2714
|
+
reject(e);
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
function rejected(value) {
|
|
2718
|
+
try {
|
|
2719
|
+
step(generator["throw"](value));
|
|
2720
|
+
} catch (e) {
|
|
2721
|
+
reject(e);
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
function step(result) {
|
|
2725
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2726
|
+
}
|
|
2727
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2728
|
+
});
|
|
2729
|
+
};
|
|
2730
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
2731
|
+
var _ = { label: 0, sent: function() {
|
|
2732
|
+
if (t[0] & 1)
|
|
2733
|
+
throw t[1];
|
|
2734
|
+
return t[1];
|
|
2735
|
+
}, trys: [], ops: [] }, f, y, t, g;
|
|
2736
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
2737
|
+
return this;
|
|
2738
|
+
}), g;
|
|
2739
|
+
function verb(n) {
|
|
2740
|
+
return function(v) {
|
|
2741
|
+
return step([n, v]);
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
function step(op) {
|
|
2745
|
+
if (f)
|
|
2746
|
+
throw new TypeError("Generator is already executing.");
|
|
2747
|
+
while (_)
|
|
2748
|
+
try {
|
|
2749
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
2750
|
+
return t;
|
|
2751
|
+
if (y = 0, t)
|
|
2752
|
+
op = [op[0] & 2, t.value];
|
|
2753
|
+
switch (op[0]) {
|
|
2754
|
+
case 0:
|
|
2755
|
+
case 1:
|
|
2756
|
+
t = op;
|
|
2757
|
+
break;
|
|
2758
|
+
case 4:
|
|
2759
|
+
_.label++;
|
|
2760
|
+
return { value: op[1], done: false };
|
|
2761
|
+
case 5:
|
|
2762
|
+
_.label++;
|
|
2763
|
+
y = op[1];
|
|
2764
|
+
op = [0];
|
|
2765
|
+
continue;
|
|
2766
|
+
case 7:
|
|
2767
|
+
op = _.ops.pop();
|
|
2768
|
+
_.trys.pop();
|
|
2769
|
+
continue;
|
|
2770
|
+
default:
|
|
2771
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
2772
|
+
_ = 0;
|
|
2773
|
+
continue;
|
|
2774
|
+
}
|
|
2775
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2776
|
+
_.label = op[1];
|
|
2777
|
+
break;
|
|
2778
|
+
}
|
|
2779
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
2780
|
+
_.label = t[1];
|
|
2781
|
+
t = op;
|
|
2782
|
+
break;
|
|
2783
|
+
}
|
|
2784
|
+
if (t && _.label < t[2]) {
|
|
2785
|
+
_.label = t[2];
|
|
2786
|
+
_.ops.push(op);
|
|
2787
|
+
break;
|
|
2788
|
+
}
|
|
2789
|
+
if (t[2])
|
|
2790
|
+
_.ops.pop();
|
|
2791
|
+
_.trys.pop();
|
|
2792
|
+
continue;
|
|
2793
|
+
}
|
|
2794
|
+
op = body.call(thisArg, _);
|
|
2795
|
+
} catch (e) {
|
|
2796
|
+
op = [6, e];
|
|
2797
|
+
y = 0;
|
|
2798
|
+
} finally {
|
|
2799
|
+
f = t = 0;
|
|
2800
|
+
}
|
|
2801
|
+
if (op[0] & 5)
|
|
2802
|
+
throw op[1];
|
|
2803
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
2804
|
+
}
|
|
2805
|
+
};
|
|
2806
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2807
|
+
exports.JSONRPCClient = void 0;
|
|
2808
|
+
var models_1 = require_models();
|
|
2809
|
+
var internal_1 = require_internal();
|
|
2810
|
+
var JSONRPCClient = function() {
|
|
2811
|
+
function JSONRPCClient2(_send, createID) {
|
|
2812
|
+
this._send = _send;
|
|
2813
|
+
this.createID = createID;
|
|
2814
|
+
this.idToResolveMap = /* @__PURE__ */ new Map();
|
|
2815
|
+
this.id = 0;
|
|
2816
|
+
}
|
|
2817
|
+
JSONRPCClient2.prototype._createID = function() {
|
|
2818
|
+
if (this.createID) {
|
|
2819
|
+
return this.createID();
|
|
2820
|
+
} else {
|
|
2821
|
+
return ++this.id;
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
JSONRPCClient2.prototype.timeout = function(delay, overrideCreateJSONRPCErrorResponse) {
|
|
2825
|
+
var _this = this;
|
|
2826
|
+
if (overrideCreateJSONRPCErrorResponse === void 0) {
|
|
2827
|
+
overrideCreateJSONRPCErrorResponse = function(id) {
|
|
2828
|
+
return (0, models_1.createJSONRPCErrorResponse)(id, internal_1.DefaultErrorCode, "Request timeout");
|
|
2829
|
+
};
|
|
2830
|
+
}
|
|
2831
|
+
var timeoutRequest = function(ids, request) {
|
|
2832
|
+
var timeoutID = setTimeout(function() {
|
|
2833
|
+
ids.forEach(function(id) {
|
|
2834
|
+
var resolve = _this.idToResolveMap.get(id);
|
|
2835
|
+
if (resolve) {
|
|
2836
|
+
_this.idToResolveMap.delete(id);
|
|
2837
|
+
resolve(overrideCreateJSONRPCErrorResponse(id));
|
|
2838
|
+
}
|
|
2839
|
+
});
|
|
2840
|
+
}, delay);
|
|
2841
|
+
return request().then(function(result) {
|
|
2842
|
+
clearTimeout(timeoutID);
|
|
2843
|
+
return result;
|
|
2844
|
+
}, function(error) {
|
|
2845
|
+
clearTimeout(timeoutID);
|
|
2846
|
+
return Promise.reject(error);
|
|
2847
|
+
});
|
|
2848
|
+
};
|
|
2849
|
+
var requestAdvanced = function(request, clientParams) {
|
|
2850
|
+
var ids = (!Array.isArray(request) ? [request] : request).map(function(request2) {
|
|
2851
|
+
return request2.id;
|
|
2852
|
+
}).filter(isDefinedAndNonNull);
|
|
2853
|
+
return timeoutRequest(ids, function() {
|
|
2854
|
+
return _this.requestAdvanced(request, clientParams);
|
|
2855
|
+
});
|
|
2856
|
+
};
|
|
2857
|
+
return {
|
|
2858
|
+
request: function(method, params, clientParams) {
|
|
2859
|
+
var id = _this._createID();
|
|
2860
|
+
return timeoutRequest([id], function() {
|
|
2861
|
+
return _this.requestWithID(method, params, clientParams, id);
|
|
2862
|
+
});
|
|
2863
|
+
},
|
|
2864
|
+
requestAdvanced: function(request, clientParams) {
|
|
2865
|
+
return requestAdvanced(request, clientParams);
|
|
2866
|
+
}
|
|
2867
|
+
};
|
|
2868
|
+
};
|
|
2869
|
+
JSONRPCClient2.prototype.request = function(method, params, clientParams) {
|
|
2870
|
+
return this.requestWithID(method, params, clientParams, this._createID());
|
|
2871
|
+
};
|
|
2872
|
+
JSONRPCClient2.prototype.requestWithID = function(method, params, clientParams, id) {
|
|
2873
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
2874
|
+
var request, response;
|
|
2875
|
+
return __generator(this, function(_a) {
|
|
2876
|
+
switch (_a.label) {
|
|
2877
|
+
case 0:
|
|
2878
|
+
request = (0, models_1.createJSONRPCRequest)(id, method, params);
|
|
2879
|
+
return [4, this.requestAdvanced(request, clientParams)];
|
|
2880
|
+
case 1:
|
|
2881
|
+
response = _a.sent();
|
|
2882
|
+
if (response.result !== void 0 && !response.error) {
|
|
2883
|
+
return [2, response.result];
|
|
2884
|
+
} else if (response.result === void 0 && response.error) {
|
|
2885
|
+
return [2, Promise.reject(new models_1.JSONRPCErrorException(response.error.message, response.error.code, response.error.data))];
|
|
2886
|
+
} else {
|
|
2887
|
+
return [2, Promise.reject(new Error("An unexpected error occurred"))];
|
|
2888
|
+
}
|
|
2889
|
+
return [2];
|
|
2890
|
+
}
|
|
2891
|
+
});
|
|
2892
|
+
});
|
|
2893
|
+
};
|
|
2894
|
+
JSONRPCClient2.prototype.requestAdvanced = function(requests, clientParams) {
|
|
2895
|
+
var _this = this;
|
|
2896
|
+
var areRequestsOriginallyArray = Array.isArray(requests);
|
|
2897
|
+
if (!Array.isArray(requests)) {
|
|
2898
|
+
requests = [requests];
|
|
2899
|
+
}
|
|
2900
|
+
var requestsWithID = requests.filter(function(request) {
|
|
2901
|
+
return isDefinedAndNonNull(request.id);
|
|
2902
|
+
});
|
|
2903
|
+
var promises = requestsWithID.map(function(request) {
|
|
2904
|
+
return new Promise(function(resolve) {
|
|
2905
|
+
return _this.idToResolveMap.set(request.id, resolve);
|
|
2906
|
+
});
|
|
2907
|
+
});
|
|
2908
|
+
var promise = Promise.all(promises).then(function(responses) {
|
|
2909
|
+
if (areRequestsOriginallyArray || !responses.length) {
|
|
2910
|
+
return responses;
|
|
2911
|
+
} else {
|
|
2912
|
+
return responses[0];
|
|
2913
|
+
}
|
|
2914
|
+
});
|
|
2915
|
+
return this.send(areRequestsOriginallyArray ? requests : requests[0], clientParams).then(function() {
|
|
2916
|
+
return promise;
|
|
2917
|
+
}, function(error) {
|
|
2918
|
+
requestsWithID.forEach(function(request) {
|
|
2919
|
+
_this.receive((0, models_1.createJSONRPCErrorResponse)(request.id, internal_1.DefaultErrorCode, error && error.message || "Failed to send a request"));
|
|
2920
|
+
});
|
|
2921
|
+
return promise;
|
|
2922
|
+
});
|
|
2923
|
+
};
|
|
2924
|
+
JSONRPCClient2.prototype.notify = function(method, params, clientParams) {
|
|
2925
|
+
var request = (0, models_1.createJSONRPCNotification)(method, params);
|
|
2926
|
+
this.send(request, clientParams).then(void 0, function() {
|
|
2927
|
+
return void 0;
|
|
2928
|
+
});
|
|
2929
|
+
};
|
|
2930
|
+
JSONRPCClient2.prototype.send = function(payload, clientParams) {
|
|
2931
|
+
return this._send(payload, clientParams);
|
|
2932
|
+
};
|
|
2933
|
+
JSONRPCClient2.prototype.rejectAllPendingRequests = function(message) {
|
|
2934
|
+
this.idToResolveMap.forEach(function(resolve, id) {
|
|
2935
|
+
return resolve((0, models_1.createJSONRPCErrorResponse)(id, internal_1.DefaultErrorCode, message));
|
|
2936
|
+
});
|
|
2937
|
+
this.idToResolveMap.clear();
|
|
2938
|
+
};
|
|
2939
|
+
JSONRPCClient2.prototype.receive = function(responses) {
|
|
2940
|
+
var _this = this;
|
|
2941
|
+
if (!Array.isArray(responses)) {
|
|
2942
|
+
responses = [responses];
|
|
2943
|
+
}
|
|
2944
|
+
responses.forEach(function(response) {
|
|
2945
|
+
var resolve = _this.idToResolveMap.get(response.id);
|
|
2946
|
+
if (resolve) {
|
|
2947
|
+
_this.idToResolveMap.delete(response.id);
|
|
2948
|
+
resolve(response);
|
|
2949
|
+
}
|
|
2950
|
+
});
|
|
2951
|
+
};
|
|
2952
|
+
return JSONRPCClient2;
|
|
2953
|
+
}();
|
|
2954
|
+
exports.JSONRPCClient = JSONRPCClient;
|
|
2955
|
+
var isDefinedAndNonNull = function(value) {
|
|
2956
|
+
return value !== void 0 && value !== null;
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
});
|
|
2960
|
+
|
|
2961
|
+
// node_modules/json-rpc-2.0/dist/server.js
|
|
2962
|
+
var require_server = __commonJS({
|
|
2963
|
+
"node_modules/json-rpc-2.0/dist/server.js"(exports) {
|
|
2964
|
+
"use strict";
|
|
2965
|
+
var __assign = exports && exports.__assign || function() {
|
|
2966
|
+
__assign = Object.assign || function(t) {
|
|
2967
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2968
|
+
s = arguments[i];
|
|
2969
|
+
for (var p in s)
|
|
2970
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
2971
|
+
t[p] = s[p];
|
|
2972
|
+
}
|
|
2973
|
+
return t;
|
|
2974
|
+
};
|
|
2975
|
+
return __assign.apply(this, arguments);
|
|
2976
|
+
};
|
|
2977
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2978
|
+
function adopt(value) {
|
|
2979
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2980
|
+
resolve(value);
|
|
2981
|
+
});
|
|
2982
|
+
}
|
|
2983
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2984
|
+
function fulfilled(value) {
|
|
2985
|
+
try {
|
|
2986
|
+
step(generator.next(value));
|
|
2987
|
+
} catch (e) {
|
|
2988
|
+
reject(e);
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
function rejected(value) {
|
|
2992
|
+
try {
|
|
2993
|
+
step(generator["throw"](value));
|
|
2994
|
+
} catch (e) {
|
|
2995
|
+
reject(e);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
function step(result) {
|
|
2999
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
3000
|
+
}
|
|
3001
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
3002
|
+
});
|
|
3003
|
+
};
|
|
3004
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
3005
|
+
var _ = { label: 0, sent: function() {
|
|
3006
|
+
if (t[0] & 1)
|
|
3007
|
+
throw t[1];
|
|
3008
|
+
return t[1];
|
|
3009
|
+
}, trys: [], ops: [] }, f, y, t, g;
|
|
3010
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
3011
|
+
return this;
|
|
3012
|
+
}), g;
|
|
3013
|
+
function verb(n) {
|
|
3014
|
+
return function(v) {
|
|
3015
|
+
return step([n, v]);
|
|
3016
|
+
};
|
|
3017
|
+
}
|
|
3018
|
+
function step(op) {
|
|
3019
|
+
if (f)
|
|
3020
|
+
throw new TypeError("Generator is already executing.");
|
|
3021
|
+
while (_)
|
|
3022
|
+
try {
|
|
3023
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
3024
|
+
return t;
|
|
3025
|
+
if (y = 0, t)
|
|
3026
|
+
op = [op[0] & 2, t.value];
|
|
3027
|
+
switch (op[0]) {
|
|
3028
|
+
case 0:
|
|
3029
|
+
case 1:
|
|
3030
|
+
t = op;
|
|
3031
|
+
break;
|
|
3032
|
+
case 4:
|
|
3033
|
+
_.label++;
|
|
3034
|
+
return { value: op[1], done: false };
|
|
3035
|
+
case 5:
|
|
3036
|
+
_.label++;
|
|
3037
|
+
y = op[1];
|
|
3038
|
+
op = [0];
|
|
3039
|
+
continue;
|
|
3040
|
+
case 7:
|
|
3041
|
+
op = _.ops.pop();
|
|
3042
|
+
_.trys.pop();
|
|
3043
|
+
continue;
|
|
3044
|
+
default:
|
|
3045
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
3046
|
+
_ = 0;
|
|
3047
|
+
continue;
|
|
3048
|
+
}
|
|
3049
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
3050
|
+
_.label = op[1];
|
|
3051
|
+
break;
|
|
3052
|
+
}
|
|
3053
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
3054
|
+
_.label = t[1];
|
|
3055
|
+
t = op;
|
|
3056
|
+
break;
|
|
3057
|
+
}
|
|
3058
|
+
if (t && _.label < t[2]) {
|
|
3059
|
+
_.label = t[2];
|
|
3060
|
+
_.ops.push(op);
|
|
3061
|
+
break;
|
|
3062
|
+
}
|
|
3063
|
+
if (t[2])
|
|
3064
|
+
_.ops.pop();
|
|
3065
|
+
_.trys.pop();
|
|
3066
|
+
continue;
|
|
3067
|
+
}
|
|
3068
|
+
op = body.call(thisArg, _);
|
|
3069
|
+
} catch (e) {
|
|
3070
|
+
op = [6, e];
|
|
3071
|
+
y = 0;
|
|
3072
|
+
} finally {
|
|
3073
|
+
f = t = 0;
|
|
3074
|
+
}
|
|
3075
|
+
if (op[0] & 5)
|
|
3076
|
+
throw op[1];
|
|
3077
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
3078
|
+
}
|
|
3079
|
+
};
|
|
3080
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|
3081
|
+
if (pack || arguments.length === 2)
|
|
3082
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3083
|
+
if (ar || !(i in from)) {
|
|
3084
|
+
if (!ar)
|
|
3085
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
3086
|
+
ar[i] = from[i];
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
3090
|
+
};
|
|
3091
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3092
|
+
exports.JSONRPCServer = void 0;
|
|
3093
|
+
var models_1 = require_models();
|
|
3094
|
+
var internal_1 = require_internal();
|
|
3095
|
+
var createParseErrorResponse = function() {
|
|
3096
|
+
return (0, models_1.createJSONRPCErrorResponse)(null, models_1.JSONRPCErrorCode.ParseError, "Parse error");
|
|
3097
|
+
};
|
|
3098
|
+
var createInvalidRequestResponse = function(request) {
|
|
3099
|
+
return (0, models_1.createJSONRPCErrorResponse)((0, models_1.isJSONRPCID)(request.id) ? request.id : null, models_1.JSONRPCErrorCode.InvalidRequest, "Invalid Request");
|
|
3100
|
+
};
|
|
3101
|
+
var createMethodNotFoundResponse = function(id) {
|
|
3102
|
+
return (0, models_1.createJSONRPCErrorResponse)(id, models_1.JSONRPCErrorCode.MethodNotFound, "Method not found");
|
|
3103
|
+
};
|
|
3104
|
+
var JSONRPCServer = function() {
|
|
3105
|
+
function JSONRPCServer2(options) {
|
|
3106
|
+
if (options === void 0) {
|
|
3107
|
+
options = {};
|
|
3108
|
+
}
|
|
3109
|
+
var _a;
|
|
3110
|
+
this.mapErrorToJSONRPCErrorResponse = defaultMapErrorToJSONRPCErrorResponse;
|
|
3111
|
+
this.nameToMethodDictionary = {};
|
|
3112
|
+
this.middleware = null;
|
|
3113
|
+
this.errorListener = (_a = options.errorListener) !== null && _a !== void 0 ? _a : console.warn;
|
|
3114
|
+
}
|
|
3115
|
+
JSONRPCServer2.prototype.hasMethod = function(name) {
|
|
3116
|
+
return !!this.nameToMethodDictionary[name];
|
|
3117
|
+
};
|
|
3118
|
+
JSONRPCServer2.prototype.addMethod = function(name, method) {
|
|
3119
|
+
this.addMethodAdvanced(name, this.toJSONRPCMethod(method));
|
|
3120
|
+
};
|
|
3121
|
+
JSONRPCServer2.prototype.toJSONRPCMethod = function(method) {
|
|
3122
|
+
return function(request, serverParams) {
|
|
3123
|
+
var response = method(request.params, serverParams);
|
|
3124
|
+
return Promise.resolve(response).then(function(result) {
|
|
3125
|
+
return mapResultToJSONRPCResponse(request.id, result);
|
|
3126
|
+
});
|
|
3127
|
+
};
|
|
3128
|
+
};
|
|
3129
|
+
JSONRPCServer2.prototype.addMethodAdvanced = function(name, method) {
|
|
3130
|
+
var _a;
|
|
3131
|
+
this.nameToMethodDictionary = __assign(__assign({}, this.nameToMethodDictionary), (_a = {}, _a[name] = method, _a));
|
|
3132
|
+
};
|
|
3133
|
+
JSONRPCServer2.prototype.receiveJSON = function(json, serverParams) {
|
|
3134
|
+
var request = this.tryParseRequestJSON(json);
|
|
3135
|
+
if (request) {
|
|
3136
|
+
return this.receive(request, serverParams);
|
|
3137
|
+
} else {
|
|
3138
|
+
return Promise.resolve(createParseErrorResponse());
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
JSONRPCServer2.prototype.tryParseRequestJSON = function(json) {
|
|
3142
|
+
try {
|
|
3143
|
+
return JSON.parse(json);
|
|
3144
|
+
} catch (_a) {
|
|
3145
|
+
return null;
|
|
3146
|
+
}
|
|
3147
|
+
};
|
|
3148
|
+
JSONRPCServer2.prototype.receive = function(request, serverParams) {
|
|
3149
|
+
if (Array.isArray(request)) {
|
|
3150
|
+
return this.receiveMultiple(request, serverParams);
|
|
3151
|
+
} else {
|
|
3152
|
+
return this.receiveSingle(request, serverParams);
|
|
3153
|
+
}
|
|
3154
|
+
};
|
|
3155
|
+
JSONRPCServer2.prototype.receiveMultiple = function(requests, serverParams) {
|
|
3156
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
3157
|
+
var responses;
|
|
3158
|
+
var _this = this;
|
|
3159
|
+
return __generator(this, function(_a) {
|
|
3160
|
+
switch (_a.label) {
|
|
3161
|
+
case 0:
|
|
3162
|
+
return [4, Promise.all(requests.map(function(request) {
|
|
3163
|
+
return _this.receiveSingle(request, serverParams);
|
|
3164
|
+
}))];
|
|
3165
|
+
case 1:
|
|
3166
|
+
responses = _a.sent().filter(isNonNull);
|
|
3167
|
+
if (responses.length === 1) {
|
|
3168
|
+
return [2, responses[0]];
|
|
3169
|
+
} else if (responses.length) {
|
|
3170
|
+
return [2, responses];
|
|
3171
|
+
} else {
|
|
3172
|
+
return [2, null];
|
|
3173
|
+
}
|
|
3174
|
+
return [2];
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
});
|
|
3178
|
+
};
|
|
3179
|
+
JSONRPCServer2.prototype.receiveSingle = function(request, serverParams) {
|
|
3180
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
3181
|
+
var method, response;
|
|
3182
|
+
return __generator(this, function(_a) {
|
|
3183
|
+
switch (_a.label) {
|
|
3184
|
+
case 0:
|
|
3185
|
+
method = this.nameToMethodDictionary[request.method];
|
|
3186
|
+
if (!!(0, models_1.isJSONRPCRequest)(request))
|
|
3187
|
+
return [3, 1];
|
|
3188
|
+
return [2, createInvalidRequestResponse(request)];
|
|
3189
|
+
case 1:
|
|
3190
|
+
return [4, this.callMethod(method, request, serverParams)];
|
|
3191
|
+
case 2:
|
|
3192
|
+
response = _a.sent();
|
|
3193
|
+
return [2, mapResponse(request, response)];
|
|
3194
|
+
}
|
|
3195
|
+
});
|
|
3196
|
+
});
|
|
3197
|
+
};
|
|
3198
|
+
JSONRPCServer2.prototype.applyMiddleware = function() {
|
|
3199
|
+
var middlewares = [];
|
|
3200
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3201
|
+
middlewares[_i] = arguments[_i];
|
|
3202
|
+
}
|
|
3203
|
+
if (this.middleware) {
|
|
3204
|
+
this.middleware = this.combineMiddlewares(__spreadArray([
|
|
3205
|
+
this.middleware
|
|
3206
|
+
], middlewares, true));
|
|
3207
|
+
} else {
|
|
3208
|
+
this.middleware = this.combineMiddlewares(middlewares);
|
|
3209
|
+
}
|
|
3210
|
+
};
|
|
3211
|
+
JSONRPCServer2.prototype.combineMiddlewares = function(middlewares) {
|
|
3212
|
+
if (!middlewares.length) {
|
|
3213
|
+
return null;
|
|
3214
|
+
} else {
|
|
3215
|
+
return middlewares.reduce(this.middlewareReducer);
|
|
3216
|
+
}
|
|
3217
|
+
};
|
|
3218
|
+
JSONRPCServer2.prototype.middlewareReducer = function(prevMiddleware, nextMiddleware) {
|
|
3219
|
+
return function(next, request, serverParams) {
|
|
3220
|
+
return prevMiddleware(function(request2, serverParams2) {
|
|
3221
|
+
return nextMiddleware(next, request2, serverParams2);
|
|
3222
|
+
}, request, serverParams);
|
|
3223
|
+
};
|
|
3224
|
+
};
|
|
3225
|
+
JSONRPCServer2.prototype.callMethod = function(method, request, serverParams) {
|
|
3226
|
+
var _this = this;
|
|
3227
|
+
var callMethod = function(request2, serverParams2) {
|
|
3228
|
+
if (method) {
|
|
3229
|
+
return method(request2, serverParams2);
|
|
3230
|
+
} else if (request2.id !== void 0) {
|
|
3231
|
+
return Promise.resolve(createMethodNotFoundResponse(request2.id));
|
|
3232
|
+
} else {
|
|
3233
|
+
return Promise.resolve(null);
|
|
3234
|
+
}
|
|
3235
|
+
};
|
|
3236
|
+
var onError = function(error) {
|
|
3237
|
+
_this.errorListener('An unexpected error occurred while executing "'.concat(request.method, '" JSON-RPC method:'), error);
|
|
3238
|
+
return Promise.resolve(_this.mapErrorToJSONRPCErrorResponseIfNecessary(request.id, error));
|
|
3239
|
+
};
|
|
3240
|
+
try {
|
|
3241
|
+
return (this.middleware || noopMiddleware)(callMethod, request, serverParams).then(void 0, onError);
|
|
3242
|
+
} catch (error) {
|
|
3243
|
+
return onError(error);
|
|
3244
|
+
}
|
|
3245
|
+
};
|
|
3246
|
+
JSONRPCServer2.prototype.mapErrorToJSONRPCErrorResponseIfNecessary = function(id, error) {
|
|
3247
|
+
if (id !== void 0) {
|
|
3248
|
+
return this.mapErrorToJSONRPCErrorResponse(id, error);
|
|
3249
|
+
} else {
|
|
3250
|
+
return null;
|
|
3251
|
+
}
|
|
3252
|
+
};
|
|
3253
|
+
return JSONRPCServer2;
|
|
3254
|
+
}();
|
|
3255
|
+
exports.JSONRPCServer = JSONRPCServer;
|
|
3256
|
+
var isNonNull = function(value) {
|
|
3257
|
+
return value !== null;
|
|
3258
|
+
};
|
|
3259
|
+
var noopMiddleware = function(next, request, serverParams) {
|
|
3260
|
+
return next(request, serverParams);
|
|
3261
|
+
};
|
|
3262
|
+
var mapResultToJSONRPCResponse = function(id, result) {
|
|
3263
|
+
if (id !== void 0) {
|
|
3264
|
+
return (0, models_1.createJSONRPCSuccessResponse)(id, result);
|
|
3265
|
+
} else {
|
|
3266
|
+
return null;
|
|
3267
|
+
}
|
|
3268
|
+
};
|
|
3269
|
+
var defaultMapErrorToJSONRPCErrorResponse = function(id, error) {
|
|
3270
|
+
var _a;
|
|
3271
|
+
var message = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : "An unexpected error occurred";
|
|
3272
|
+
var code = internal_1.DefaultErrorCode;
|
|
3273
|
+
var data;
|
|
3274
|
+
if (error instanceof models_1.JSONRPCErrorException) {
|
|
3275
|
+
code = error.code;
|
|
3276
|
+
data = error.data;
|
|
3277
|
+
}
|
|
3278
|
+
return (0, models_1.createJSONRPCErrorResponse)(id, code, message, data);
|
|
3279
|
+
};
|
|
3280
|
+
var mapResponse = function(request, response) {
|
|
3281
|
+
if (response) {
|
|
3282
|
+
return response;
|
|
3283
|
+
} else if (request.id !== void 0) {
|
|
3284
|
+
return (0, models_1.createJSONRPCErrorResponse)(request.id, models_1.JSONRPCErrorCode.InternalError, "Internal error");
|
|
3285
|
+
} else {
|
|
3286
|
+
return null;
|
|
3287
|
+
}
|
|
3288
|
+
};
|
|
3289
|
+
}
|
|
3290
|
+
});
|
|
3291
|
+
|
|
3292
|
+
// node_modules/json-rpc-2.0/dist/server-and-client.js
|
|
3293
|
+
var require_server_and_client = __commonJS({
|
|
3294
|
+
"node_modules/json-rpc-2.0/dist/server-and-client.js"(exports) {
|
|
3295
|
+
"use strict";
|
|
3296
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
3297
|
+
function adopt(value) {
|
|
3298
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
3299
|
+
resolve(value);
|
|
3300
|
+
});
|
|
3301
|
+
}
|
|
3302
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
3303
|
+
function fulfilled(value) {
|
|
3304
|
+
try {
|
|
3305
|
+
step(generator.next(value));
|
|
3306
|
+
} catch (e) {
|
|
3307
|
+
reject(e);
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
function rejected(value) {
|
|
3311
|
+
try {
|
|
3312
|
+
step(generator["throw"](value));
|
|
3313
|
+
} catch (e) {
|
|
3314
|
+
reject(e);
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
function step(result) {
|
|
3318
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
3319
|
+
}
|
|
3320
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
3321
|
+
});
|
|
3322
|
+
};
|
|
3323
|
+
var __generator = exports && exports.__generator || function(thisArg, body) {
|
|
3324
|
+
var _ = { label: 0, sent: function() {
|
|
3325
|
+
if (t[0] & 1)
|
|
3326
|
+
throw t[1];
|
|
3327
|
+
return t[1];
|
|
3328
|
+
}, trys: [], ops: [] }, f, y, t, g;
|
|
3329
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
3330
|
+
return this;
|
|
3331
|
+
}), g;
|
|
3332
|
+
function verb(n) {
|
|
3333
|
+
return function(v) {
|
|
3334
|
+
return step([n, v]);
|
|
3335
|
+
};
|
|
3336
|
+
}
|
|
3337
|
+
function step(op) {
|
|
3338
|
+
if (f)
|
|
3339
|
+
throw new TypeError("Generator is already executing.");
|
|
3340
|
+
while (_)
|
|
3341
|
+
try {
|
|
3342
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
3343
|
+
return t;
|
|
3344
|
+
if (y = 0, t)
|
|
3345
|
+
op = [op[0] & 2, t.value];
|
|
3346
|
+
switch (op[0]) {
|
|
3347
|
+
case 0:
|
|
3348
|
+
case 1:
|
|
3349
|
+
t = op;
|
|
3350
|
+
break;
|
|
3351
|
+
case 4:
|
|
3352
|
+
_.label++;
|
|
3353
|
+
return { value: op[1], done: false };
|
|
3354
|
+
case 5:
|
|
3355
|
+
_.label++;
|
|
3356
|
+
y = op[1];
|
|
3357
|
+
op = [0];
|
|
3358
|
+
continue;
|
|
3359
|
+
case 7:
|
|
3360
|
+
op = _.ops.pop();
|
|
3361
|
+
_.trys.pop();
|
|
3362
|
+
continue;
|
|
3363
|
+
default:
|
|
3364
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
3365
|
+
_ = 0;
|
|
3366
|
+
continue;
|
|
3367
|
+
}
|
|
3368
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
3369
|
+
_.label = op[1];
|
|
3370
|
+
break;
|
|
3371
|
+
}
|
|
3372
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
3373
|
+
_.label = t[1];
|
|
3374
|
+
t = op;
|
|
3375
|
+
break;
|
|
3376
|
+
}
|
|
3377
|
+
if (t && _.label < t[2]) {
|
|
3378
|
+
_.label = t[2];
|
|
3379
|
+
_.ops.push(op);
|
|
3380
|
+
break;
|
|
3381
|
+
}
|
|
3382
|
+
if (t[2])
|
|
3383
|
+
_.ops.pop();
|
|
3384
|
+
_.trys.pop();
|
|
3385
|
+
continue;
|
|
3386
|
+
}
|
|
3387
|
+
op = body.call(thisArg, _);
|
|
3388
|
+
} catch (e) {
|
|
3389
|
+
op = [6, e];
|
|
3390
|
+
y = 0;
|
|
3391
|
+
} finally {
|
|
3392
|
+
f = t = 0;
|
|
3393
|
+
}
|
|
3394
|
+
if (op[0] & 5)
|
|
3395
|
+
throw op[1];
|
|
3396
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3400
|
+
exports.JSONRPCServerAndClient = void 0;
|
|
3401
|
+
var models_1 = require_models();
|
|
3402
|
+
var JSONRPCServerAndClient = function() {
|
|
3403
|
+
function JSONRPCServerAndClient2(server, client, options) {
|
|
3404
|
+
if (options === void 0) {
|
|
3405
|
+
options = {};
|
|
3406
|
+
}
|
|
3407
|
+
var _a;
|
|
3408
|
+
this.server = server;
|
|
3409
|
+
this.client = client;
|
|
3410
|
+
this.errorListener = (_a = options.errorListener) !== null && _a !== void 0 ? _a : console.warn;
|
|
3411
|
+
}
|
|
3412
|
+
JSONRPCServerAndClient2.prototype.applyServerMiddleware = function() {
|
|
3413
|
+
var _a;
|
|
3414
|
+
var middlewares = [];
|
|
3415
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3416
|
+
middlewares[_i] = arguments[_i];
|
|
3417
|
+
}
|
|
3418
|
+
(_a = this.server).applyMiddleware.apply(_a, middlewares);
|
|
3419
|
+
};
|
|
3420
|
+
JSONRPCServerAndClient2.prototype.hasMethod = function(name) {
|
|
3421
|
+
return this.server.hasMethod(name);
|
|
3422
|
+
};
|
|
3423
|
+
JSONRPCServerAndClient2.prototype.addMethod = function(name, method) {
|
|
3424
|
+
this.server.addMethod(name, method);
|
|
3425
|
+
};
|
|
3426
|
+
JSONRPCServerAndClient2.prototype.addMethodAdvanced = function(name, method) {
|
|
3427
|
+
this.server.addMethodAdvanced(name, method);
|
|
3428
|
+
};
|
|
3429
|
+
JSONRPCServerAndClient2.prototype.timeout = function(delay) {
|
|
3430
|
+
return this.client.timeout(delay);
|
|
3431
|
+
};
|
|
3432
|
+
JSONRPCServerAndClient2.prototype.request = function(method, params, clientParams) {
|
|
3433
|
+
return this.client.request(method, params, clientParams);
|
|
3434
|
+
};
|
|
3435
|
+
JSONRPCServerAndClient2.prototype.requestAdvanced = function(jsonRPCRequest, clientParams) {
|
|
3436
|
+
return this.client.requestAdvanced(jsonRPCRequest, clientParams);
|
|
3437
|
+
};
|
|
3438
|
+
JSONRPCServerAndClient2.prototype.notify = function(method, params, clientParams) {
|
|
3439
|
+
this.client.notify(method, params, clientParams);
|
|
3440
|
+
};
|
|
3441
|
+
JSONRPCServerAndClient2.prototype.rejectAllPendingRequests = function(message) {
|
|
3442
|
+
this.client.rejectAllPendingRequests(message);
|
|
3443
|
+
};
|
|
3444
|
+
JSONRPCServerAndClient2.prototype.receiveAndSend = function(payload, serverParams, clientParams) {
|
|
3445
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
3446
|
+
var response, message;
|
|
3447
|
+
return __generator(this, function(_a) {
|
|
3448
|
+
switch (_a.label) {
|
|
3449
|
+
case 0:
|
|
3450
|
+
if (!((0, models_1.isJSONRPCResponse)(payload) || (0, models_1.isJSONRPCResponses)(payload)))
|
|
3451
|
+
return [3, 1];
|
|
3452
|
+
this.client.receive(payload);
|
|
3453
|
+
return [3, 4];
|
|
3454
|
+
case 1:
|
|
3455
|
+
if (!((0, models_1.isJSONRPCRequest)(payload) || (0, models_1.isJSONRPCRequests)(payload)))
|
|
3456
|
+
return [3, 3];
|
|
3457
|
+
return [4, this.server.receive(payload, serverParams)];
|
|
3458
|
+
case 2:
|
|
3459
|
+
response = _a.sent();
|
|
3460
|
+
if (response) {
|
|
3461
|
+
return [2, this.client.send(response, clientParams)];
|
|
3462
|
+
}
|
|
3463
|
+
return [3, 4];
|
|
3464
|
+
case 3:
|
|
3465
|
+
message = "Received an invalid JSON-RPC message";
|
|
3466
|
+
this.errorListener(message, payload);
|
|
3467
|
+
return [2, Promise.reject(new Error(message))];
|
|
3468
|
+
case 4:
|
|
3469
|
+
return [2];
|
|
3470
|
+
}
|
|
3471
|
+
});
|
|
3472
|
+
});
|
|
3473
|
+
};
|
|
3474
|
+
return JSONRPCServerAndClient2;
|
|
3475
|
+
}();
|
|
3476
|
+
exports.JSONRPCServerAndClient = JSONRPCServerAndClient;
|
|
3477
|
+
}
|
|
3478
|
+
});
|
|
3479
|
+
|
|
3480
|
+
// node_modules/json-rpc-2.0/dist/index.js
|
|
3481
|
+
var require_dist16 = __commonJS({
|
|
3482
|
+
"node_modules/json-rpc-2.0/dist/index.js"(exports) {
|
|
3483
|
+
"use strict";
|
|
3484
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3485
|
+
if (k2 === void 0)
|
|
3486
|
+
k2 = k;
|
|
3487
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3488
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3489
|
+
desc = { enumerable: true, get: function() {
|
|
3490
|
+
return m[k];
|
|
3491
|
+
} };
|
|
3492
|
+
}
|
|
3493
|
+
Object.defineProperty(o, k2, desc);
|
|
3494
|
+
} : function(o, m, k, k2) {
|
|
3495
|
+
if (k2 === void 0)
|
|
3496
|
+
k2 = k;
|
|
3497
|
+
o[k2] = m[k];
|
|
3498
|
+
});
|
|
3499
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
3500
|
+
for (var p in m)
|
|
3501
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
3502
|
+
__createBinding(exports2, m, p);
|
|
3503
|
+
};
|
|
3504
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3505
|
+
__exportStar(require_client(), exports);
|
|
3506
|
+
__exportStar(require_models(), exports);
|
|
3507
|
+
__exportStar(require_server(), exports);
|
|
3508
|
+
__exportStar(require_server_and_client(), exports);
|
|
3509
|
+
}
|
|
3510
|
+
});
|
|
3511
|
+
|
|
2575
3512
|
// node_modules/pg/node_modules/postgres-array/index.js
|
|
2576
3513
|
var require_postgres_array = __commonJS({
|
|
2577
3514
|
"node_modules/pg/node_modules/postgres-array/index.js"(exports) {
|
|
@@ -5436,7 +6373,7 @@ var require_parser = __commonJS({
|
|
|
5436
6373
|
});
|
|
5437
6374
|
|
|
5438
6375
|
// node_modules/pg-protocol/dist/index.js
|
|
5439
|
-
var
|
|
6376
|
+
var require_dist17 = __commonJS({
|
|
5440
6377
|
"node_modules/pg-protocol/dist/index.js"(exports) {
|
|
5441
6378
|
"use strict";
|
|
5442
6379
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -5465,7 +6402,7 @@ var require_connection = __commonJS({
|
|
|
5465
6402
|
"use strict";
|
|
5466
6403
|
var net = require("net");
|
|
5467
6404
|
var EventEmitter = require("events").EventEmitter;
|
|
5468
|
-
var { parse, serialize } =
|
|
6405
|
+
var { parse, serialize } = require_dist17();
|
|
5469
6406
|
var flushBuffer = serialize.flush();
|
|
5470
6407
|
var syncBuffer = serialize.sync();
|
|
5471
6408
|
var endBuffer = serialize.end();
|
|
@@ -5642,7 +6579,7 @@ var require_connection = __commonJS({
|
|
|
5642
6579
|
});
|
|
5643
6580
|
|
|
5644
6581
|
// node_modules/pg/lib/client.js
|
|
5645
|
-
var
|
|
6582
|
+
var require_client2 = __commonJS({
|
|
5646
6583
|
"node_modules/pg/lib/client.js"(exports, module2) {
|
|
5647
6584
|
"use strict";
|
|
5648
6585
|
var EventEmitter = require("events").EventEmitter;
|
|
@@ -8137,7 +9074,7 @@ var require_query2 = __commonJS({
|
|
|
8137
9074
|
});
|
|
8138
9075
|
|
|
8139
9076
|
// node_modules/pg/lib/native/client.js
|
|
8140
|
-
var
|
|
9077
|
+
var require_client3 = __commonJS({
|
|
8141
9078
|
"node_modules/pg/lib/native/client.js"(exports, module2) {
|
|
8142
9079
|
"use strict";
|
|
8143
9080
|
var Native = require_pg_native();
|
|
@@ -8373,7 +9310,7 @@ var require_client2 = __commonJS({
|
|
|
8373
9310
|
var require_native = __commonJS({
|
|
8374
9311
|
"node_modules/pg/lib/native/index.js"(exports, module2) {
|
|
8375
9312
|
"use strict";
|
|
8376
|
-
module2.exports =
|
|
9313
|
+
module2.exports = require_client3();
|
|
8377
9314
|
}
|
|
8378
9315
|
});
|
|
8379
9316
|
|
|
@@ -8381,11 +9318,11 @@ var require_native = __commonJS({
|
|
|
8381
9318
|
var require_lib2 = __commonJS({
|
|
8382
9319
|
"node_modules/pg/lib/index.js"(exports, module2) {
|
|
8383
9320
|
"use strict";
|
|
8384
|
-
var Client =
|
|
9321
|
+
var Client = require_client2();
|
|
8385
9322
|
var defaults = require_defaults();
|
|
8386
9323
|
var Connection = require_connection();
|
|
8387
9324
|
var Pool = require_pg_pool();
|
|
8388
|
-
var { DatabaseError } =
|
|
9325
|
+
var { DatabaseError } = require_dist17();
|
|
8389
9326
|
var poolFactory = (Client2) => {
|
|
8390
9327
|
return class BoundPool extends Pool {
|
|
8391
9328
|
constructor(options) {
|
|
@@ -9081,11 +10018,11 @@ var require_MiddlewareStack = __commonJS({
|
|
|
9081
10018
|
return mw.name + ": " + (mw.tags || []).join(",");
|
|
9082
10019
|
});
|
|
9083
10020
|
},
|
|
9084
|
-
resolve: (
|
|
10021
|
+
resolve: (handler2, context) => {
|
|
9085
10022
|
for (const middleware of getMiddlewareList().map((entry) => entry.middleware).reverse()) {
|
|
9086
|
-
|
|
10023
|
+
handler2 = middleware(handler2, context);
|
|
9087
10024
|
}
|
|
9088
|
-
return
|
|
10025
|
+
return handler2;
|
|
9089
10026
|
}
|
|
9090
10027
|
};
|
|
9091
10028
|
return stack;
|
|
@@ -9117,7 +10054,7 @@ var require_dist_cjs6 = __commonJS({
|
|
|
9117
10054
|
});
|
|
9118
10055
|
|
|
9119
10056
|
// node_modules/@aws-sdk/smithy-client/dist-cjs/client.js
|
|
9120
|
-
var
|
|
10057
|
+
var require_client4 = __commonJS({
|
|
9121
10058
|
"node_modules/@aws-sdk/smithy-client/dist-cjs/client.js"(exports) {
|
|
9122
10059
|
"use strict";
|
|
9123
10060
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -9131,12 +10068,12 @@ var require_client3 = __commonJS({
|
|
|
9131
10068
|
send(command, optionsOrCb, cb) {
|
|
9132
10069
|
const options = typeof optionsOrCb !== "function" ? optionsOrCb : void 0;
|
|
9133
10070
|
const callback = typeof optionsOrCb === "function" ? optionsOrCb : cb;
|
|
9134
|
-
const
|
|
10071
|
+
const handler2 = command.resolveMiddleware(this.middlewareStack, this.config, options);
|
|
9135
10072
|
if (callback) {
|
|
9136
|
-
|
|
10073
|
+
handler2(command).then((result) => callback(null, result.output), (err) => callback(err)).catch(() => {
|
|
9137
10074
|
});
|
|
9138
10075
|
} else {
|
|
9139
|
-
return
|
|
10076
|
+
return handler2(command).then((result) => result.output);
|
|
9140
10077
|
}
|
|
9141
10078
|
}
|
|
9142
10079
|
destroy() {
|
|
@@ -9959,7 +10896,7 @@ var require_dist_cjs7 = __commonJS({
|
|
|
9959
10896
|
"use strict";
|
|
9960
10897
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9961
10898
|
var tslib_1 = require_tslib();
|
|
9962
|
-
tslib_1.__exportStar(
|
|
10899
|
+
tslib_1.__exportStar(require_client4(), exports);
|
|
9963
10900
|
tslib_1.__exportStar(require_command(), exports);
|
|
9964
10901
|
tslib_1.__exportStar(require_constants(), exports);
|
|
9965
10902
|
tslib_1.__exportStar(require_date_utils(), exports);
|
|
@@ -12872,7 +13809,7 @@ var require_version = __commonJS({
|
|
|
12872
13809
|
});
|
|
12873
13810
|
|
|
12874
13811
|
// node_modules/uuid/dist/index.js
|
|
12875
|
-
var
|
|
13812
|
+
var require_dist18 = __commonJS({
|
|
12876
13813
|
"node_modules/uuid/dist/index.js"(exports) {
|
|
12877
13814
|
"use strict";
|
|
12878
13815
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -13040,7 +13977,7 @@ var require_StandardRetryStrategy = __commonJS({
|
|
|
13040
13977
|
exports.StandardRetryStrategy = void 0;
|
|
13041
13978
|
var protocol_http_1 = require_dist_cjs8();
|
|
13042
13979
|
var service_error_classification_1 = require_dist_cjs15();
|
|
13043
|
-
var uuid_1 =
|
|
13980
|
+
var uuid_1 = require_dist18();
|
|
13044
13981
|
var config_1 = require_config2();
|
|
13045
13982
|
var constants_1 = require_constants3();
|
|
13046
13983
|
var defaultRetryQuota_1 = require_defaultRetryQuota();
|
|
@@ -20969,7 +21906,7 @@ var require_auth = __commonJS({
|
|
|
20969
21906
|
});
|
|
20970
21907
|
|
|
20971
21908
|
// node_modules/@aws-sdk/types/dist-cjs/client.js
|
|
20972
|
-
var
|
|
21909
|
+
var require_client5 = __commonJS({
|
|
20973
21910
|
"node_modules/@aws-sdk/types/dist-cjs/client.js"(exports) {
|
|
20974
21911
|
"use strict";
|
|
20975
21912
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -21142,7 +22079,7 @@ var require_dist_cjs37 = __commonJS({
|
|
|
21142
22079
|
var tslib_1 = require_tslib();
|
|
21143
22080
|
tslib_1.__exportStar(require_abort(), exports);
|
|
21144
22081
|
tslib_1.__exportStar(require_auth(), exports);
|
|
21145
|
-
tslib_1.__exportStar(
|
|
22082
|
+
tslib_1.__exportStar(require_client5(), exports);
|
|
21146
22083
|
tslib_1.__exportStar(require_command2(), exports);
|
|
21147
22084
|
tslib_1.__exportStar(require_credentials(), exports);
|
|
21148
22085
|
tslib_1.__exportStar(require_crypto(), exports);
|
|
@@ -22355,7 +23292,7 @@ var require_commands = __commonJS({
|
|
|
22355
23292
|
});
|
|
22356
23293
|
|
|
22357
23294
|
// node_modules/@aws-sdk/client-sso/dist-cjs/models/index.js
|
|
22358
|
-
var
|
|
23295
|
+
var require_models2 = __commonJS({
|
|
22359
23296
|
"node_modules/@aws-sdk/client-sso/dist-cjs/models/index.js"(exports) {
|
|
22360
23297
|
"use strict";
|
|
22361
23298
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -22474,7 +23411,7 @@ var require_dist_cjs40 = __commonJS({
|
|
|
22474
23411
|
tslib_1.__exportStar(require_SSO(), exports);
|
|
22475
23412
|
tslib_1.__exportStar(require_SSOClient(), exports);
|
|
22476
23413
|
tslib_1.__exportStar(require_commands(), exports);
|
|
22477
|
-
tslib_1.__exportStar(
|
|
23414
|
+
tslib_1.__exportStar(require_models2(), exports);
|
|
22478
23415
|
tslib_1.__exportStar(require_pagination2(), exports);
|
|
22479
23416
|
var SSOServiceException_1 = require_SSOServiceException();
|
|
22480
23417
|
Object.defineProperty(exports, "SSOServiceException", { enumerable: true, get: function() {
|
|
@@ -24145,7 +25082,7 @@ var require_defaultRoleAssumers = __commonJS({
|
|
|
24145
25082
|
});
|
|
24146
25083
|
|
|
24147
25084
|
// node_modules/@aws-sdk/client-sts/dist-cjs/models/index.js
|
|
24148
|
-
var
|
|
25085
|
+
var require_models3 = __commonJS({
|
|
24149
25086
|
"node_modules/@aws-sdk/client-sts/dist-cjs/models/index.js"(exports) {
|
|
24150
25087
|
"use strict";
|
|
24151
25088
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -24165,7 +25102,7 @@ var require_dist_cjs46 = __commonJS({
|
|
|
24165
25102
|
tslib_1.__exportStar(require_STSClient(), exports);
|
|
24166
25103
|
tslib_1.__exportStar(require_commands2(), exports);
|
|
24167
25104
|
tslib_1.__exportStar(require_defaultRoleAssumers(), exports);
|
|
24168
|
-
tslib_1.__exportStar(
|
|
25105
|
+
tslib_1.__exportStar(require_models3(), exports);
|
|
24169
25106
|
var STSServiceException_1 = require_STSServiceException();
|
|
24170
25107
|
Object.defineProperty(exports, "STSServiceException", { enumerable: true, get: function() {
|
|
24171
25108
|
return STSServiceException_1.STSServiceException;
|
|
@@ -24743,7 +25680,7 @@ var require_commands3 = __commonJS({
|
|
|
24743
25680
|
});
|
|
24744
25681
|
|
|
24745
25682
|
// node_modules/@aws-sdk/client-rds-data/dist-cjs/models/index.js
|
|
24746
|
-
var
|
|
25683
|
+
var require_models4 = __commonJS({
|
|
24747
25684
|
"node_modules/@aws-sdk/client-rds-data/dist-cjs/models/index.js"(exports) {
|
|
24748
25685
|
"use strict";
|
|
24749
25686
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -24762,7 +25699,7 @@ var require_dist_cjs47 = __commonJS({
|
|
|
24762
25699
|
tslib_1.__exportStar(require_RDSData(), exports);
|
|
24763
25700
|
tslib_1.__exportStar(require_RDSDataClient(), exports);
|
|
24764
25701
|
tslib_1.__exportStar(require_commands3(), exports);
|
|
24765
|
-
tslib_1.__exportStar(
|
|
25702
|
+
tslib_1.__exportStar(require_models4(), exports);
|
|
24766
25703
|
var RDSDataServiceException_1 = require_RDSDataServiceException();
|
|
24767
25704
|
Object.defineProperty(exports, "RDSDataServiceException", { enumerable: true, get: function() {
|
|
24768
25705
|
return RDSDataServiceException_1.RDSDataServiceException;
|
|
@@ -24781,6 +25718,7 @@ __export(src_exports, {
|
|
|
24781
25718
|
PgQueryResolver: () => PgQueryResolver,
|
|
24782
25719
|
Query: () => Query,
|
|
24783
25720
|
QueryConstraints: () => constraints_exports,
|
|
25721
|
+
handleCustomFunction: () => customFunctions_default,
|
|
24784
25722
|
queryResolverFromEnv: () => queryResolverFromEnv
|
|
24785
25723
|
});
|
|
24786
25724
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -25225,6 +26163,43 @@ var Logger = class {
|
|
|
25225
26163
|
}
|
|
25226
26164
|
};
|
|
25227
26165
|
|
|
26166
|
+
// src/customFunctions/index.ts
|
|
26167
|
+
var import_json_rpc_2 = __toESM(require_dist16());
|
|
26168
|
+
var handler = async ({ method: name, params, id }, config) => {
|
|
26169
|
+
const { api, functions } = config;
|
|
26170
|
+
if (!(name in functions)) {
|
|
26171
|
+
return (0, import_json_rpc_2.createJSONRPCErrorResponse)(
|
|
26172
|
+
id,
|
|
26173
|
+
import_json_rpc_2.JSONRPCErrorCode.MethodNotFound,
|
|
26174
|
+
`no corresponding function found for '${name}'`
|
|
26175
|
+
);
|
|
26176
|
+
}
|
|
26177
|
+
try {
|
|
26178
|
+
const result = await functions[name].call(params, api);
|
|
26179
|
+
if (!result) {
|
|
26180
|
+
return (0, import_json_rpc_2.createJSONRPCErrorResponse)(
|
|
26181
|
+
id,
|
|
26182
|
+
import_json_rpc_2.JSONRPCErrorCode.ParseError,
|
|
26183
|
+
`no result returned from function '${name}'`
|
|
26184
|
+
);
|
|
26185
|
+
}
|
|
26186
|
+
return (0, import_json_rpc_2.createJSONRPCSuccessResponse)(id, result);
|
|
26187
|
+
} catch (e) {
|
|
26188
|
+
let msg = "";
|
|
26189
|
+
if (e instanceof Error) {
|
|
26190
|
+
msg = e.message;
|
|
26191
|
+
} else {
|
|
26192
|
+
msg = JSON.stringify(e);
|
|
26193
|
+
}
|
|
26194
|
+
return (0, import_json_rpc_2.createJSONRPCErrorResponse)(
|
|
26195
|
+
id,
|
|
26196
|
+
import_json_rpc_2.JSONRPCErrorCode.InternalError,
|
|
26197
|
+
e.message
|
|
26198
|
+
);
|
|
26199
|
+
}
|
|
26200
|
+
};
|
|
26201
|
+
var customFunctions_default = handler;
|
|
26202
|
+
|
|
25228
26203
|
// src/db/resolver.ts
|
|
25229
26204
|
var import_pg = __toESM(require_lib2());
|
|
25230
26205
|
var import_client_rds_data = __toESM(require_dist_cjs47());
|
|
@@ -25487,5 +26462,6 @@ var AwsRdsDataClientQueryResolver = class {
|
|
|
25487
26462
|
PgQueryResolver,
|
|
25488
26463
|
Query,
|
|
25489
26464
|
QueryConstraints,
|
|
26465
|
+
handleCustomFunction,
|
|
25490
26466
|
queryResolverFromEnv
|
|
25491
26467
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamkeel/functions-runtime",
|
|
3
|
-
"version": "0.221.
|
|
3
|
+
"version": "0.221.4",
|
|
4
4
|
"description": "Internal package used by @teamkeel/sdk",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"chalk": "^4.1.2",
|
|
38
38
|
"change-case": "^4.1.2",
|
|
39
39
|
"commander": "^9.4.1",
|
|
40
|
+
"json-rpc-2.0": "^1.4.1",
|
|
40
41
|
"ksuid": "^3.0.0",
|
|
41
42
|
"node-fetch": "^3.2.10",
|
|
42
43
|
"pg": "^8.8.0"
|