quidproquo-dev-server 0.0.231 → 0.0.233
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/lib/commonjs/allServiceConfig.d.ts +1 -1
- package/lib/commonjs/allServiceConfig.js +6 -5
- package/lib/commonjs/config/settings/defineDevServerConfig.js +2 -2
- package/lib/commonjs/getActionProcessor/core/event/express/api/getEventGetStorySessionActionProcessor.js +27 -3
- package/lib/commonjs/getActionProcessor/core/event/express/api/getEventMatchStoryActionProcessor.js +1 -3
- package/lib/commonjs/getActionProcessor/core/event/express/api/getEventTransformResponseResultActionProcessor.js +1 -3
- package/lib/commonjs/getActionProcessor/core/event/express/api/index.d.ts +1 -1
- package/lib/commonjs/implementations/route.d.ts +1 -1
- package/lib/commonjs/implementations/route.js +22 -21
- package/lib/commonjs/index.d.ts +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/main.js +11 -12
- package/lib/commonjs/types/ExpressEvent.d.ts +1 -1
- package/lib/esm/actionProcessor/graphDatabaseOverride/getGraphDatabaseExecuteOpenCypherQueryActionProcessor.js +1 -1
- package/lib/esm/allServiceConfig.d.ts +1 -1
- package/lib/esm/allServiceConfig.js +2 -1
- package/lib/esm/config/settings/defineDevServerConfig.js +2 -2
- package/lib/esm/getActionProcessor/core/event/express/api/getEventGetStorySessionActionProcessor.js +32 -3
- package/lib/esm/getActionProcessor/core/event/express/api/getEventMatchStoryActionProcessor.js +2 -4
- package/lib/esm/getActionProcessor/core/event/express/api/getEventTransformResponseResultActionProcessor.js +1 -3
- package/lib/esm/getActionProcessor/core/event/express/api/index.d.ts +1 -1
- package/lib/esm/implementations/route.d.ts +1 -1
- package/lib/esm/implementations/route.js +4 -3
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/main.js +3 -4
- package/lib/esm/types/ExpressEvent.d.ts +1 -1
- package/package.json +10 -7
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllServiceConfigs = void 0;
|
|
4
|
-
const
|
|
4
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
5
6
|
// Create an async function to fetch all services
|
|
6
7
|
function getAllServiceConfigs(devServerConfig) {
|
|
7
8
|
// Clone it
|
|
@@ -16,14 +17,14 @@ function getAllServiceConfigs(devServerConfig) {
|
|
|
16
17
|
// const appSettings = qpqCoreUtils.getApplicationModuleSetting(qpqConfig);
|
|
17
18
|
// appSettings.feature = undefined;
|
|
18
19
|
// appSettings.environment = 'production';
|
|
19
|
-
const baseDomain =
|
|
20
|
+
const baseDomain = quidproquo_webserver_1.qpqWebServerUtils.getDomainRoot(rootDomain, quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
|
|
20
21
|
// Change the domain
|
|
21
|
-
const dnsConfigs =
|
|
22
|
+
const dnsConfigs = quidproquo_webserver_1.qpqWebServerUtils.getDnsConfigs(qpqConfig);
|
|
22
23
|
for (const dnsConfig of dnsConfigs) {
|
|
23
24
|
dnsConfig.dnsBase = rootDomain;
|
|
24
25
|
}
|
|
25
26
|
// Expose global cors headers
|
|
26
|
-
const defaultRouteSettings =
|
|
27
|
+
const defaultRouteSettings = quidproquo_webserver_1.qpqWebServerUtils.getDefaultRouteSettings(qpqConfig);
|
|
27
28
|
for (const getDefaultRouteSetting of defaultRouteSettings) {
|
|
28
29
|
getDefaultRouteSetting.routeOptions.allowedOrigins = [
|
|
29
30
|
...(getDefaultRouteSetting.routeOptions.allowedOrigins || []),
|
|
@@ -32,7 +33,7 @@ function getAllServiceConfigs(devServerConfig) {
|
|
|
32
33
|
];
|
|
33
34
|
}
|
|
34
35
|
// Expose global cors headers
|
|
35
|
-
const routes =
|
|
36
|
+
const routes = quidproquo_webserver_1.qpqWebServerUtils.getAllRoutes(qpqConfig);
|
|
36
37
|
for (const route of routes) {
|
|
37
38
|
route.options.allowedOrigins = [...(route.options.allowedOrigins || []), `http://${baseDomain}`, '*'];
|
|
38
39
|
}
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.defineDevServerConfig = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
7
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const defineDevServerConfig = (buildPath, advancedSettings) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const onlyDeploySafe = (_a = advancedSettings === null || advancedSettings === void 0 ? void 0 : advancedSettings.onlyDeploySafe) !== null && _a !== void 0 ? _a : true;
|
|
12
12
|
const vpcList = (advancedSettings === null || advancedSettings === void 0 ? void 0 : advancedSettings.vpcList) || [];
|
|
13
13
|
const pathToRuntime = path_1.default.join(__dirname, '../../entry/serviceFunction/runCypherQuery');
|
|
14
|
-
const graphAccessConfigs = vpcList.map((vpcName) => (0, quidproquo_webserver_1.defineServiceFunction)(
|
|
14
|
+
const graphAccessConfigs = vpcList.map((vpcName) => (0, quidproquo_webserver_1.defineServiceFunction)(`full@${pathToRuntime}::runCypherQuery`, {
|
|
15
15
|
virtualNetworkName: vpcName,
|
|
16
16
|
functionName: `graphQuery${vpcName}`,
|
|
17
17
|
}));
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-void */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,8 +10,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
10
|
};
|
|
13
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
12
|
exports.getEventGetStorySessionActionProcessor = void 0;
|
|
13
|
+
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
15
14
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
16
|
-
const
|
|
15
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
16
|
+
const getProcessGetStorySession = (qpqConfig) => {
|
|
17
|
+
return ({ matchStoryResult, qpqEventRecord }, session) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const accessToken = quidproquo_webserver_1.qpqWebServerUtils.getAccessTokenFromHeaders(qpqEventRecord.headers);
|
|
20
|
+
if (!accessToken) {
|
|
21
|
+
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
22
|
+
}
|
|
23
|
+
// if this endpoint has no auth settings, BUT we do have an access token
|
|
24
|
+
// then we want to just attempt to extract info for logs, but we will say that its
|
|
25
|
+
// wasValid = false
|
|
26
|
+
if (!((_b = (_a = matchStoryResult.config) === null || _a === void 0 ? void 0 : _a.routeAuthSettings) === null || _b === void 0 ? void 0 : _b.userDirectoryName)) {
|
|
27
|
+
// If this endpoint is unauthenticated, then we will just decode it, and say it wasnt valid, for logs
|
|
28
|
+
const info = quidproquo_webserver_1.qpqWebServerUtils.decodeJWT(accessToken);
|
|
29
|
+
return (0, quidproquo_core_1.actionResult)(Object.assign(Object.assign({}, session), { decodedAccessToken: {
|
|
30
|
+
exp: (info === null || info === void 0 ? void 0 : info.exp) || 0,
|
|
31
|
+
userDirectory: '',
|
|
32
|
+
userId: (info === null || info === void 0 ? void 0 : info.sub) || (info === null || info === void 0 ? void 0 : info.id) || (info === null || info === void 0 ? void 0 : info.userId) || (info === null || info === void 0 ? void 0 : info.username) || '',
|
|
33
|
+
username: (info === null || info === void 0 ? void 0 : info.username) || (info === null || info === void 0 ? void 0 : info.userId) || (info === null || info === void 0 ? void 0 : info.sub) || (info === null || info === void 0 ? void 0 : info.id) || '',
|
|
34
|
+
wasValid: false,
|
|
35
|
+
} }));
|
|
36
|
+
}
|
|
37
|
+
const decodedAccessToken = yield (0, quidproquo_actionprocessor_awslambda_1.decodeAccessToken)(matchStoryResult.config.routeAuthSettings.userDirectoryName, qpqConfig, accessToken, true);
|
|
38
|
+
return (0, quidproquo_core_1.actionResult)(Object.assign(Object.assign({}, session), { decodedAccessToken }));
|
|
39
|
+
});
|
|
40
|
+
};
|
|
17
41
|
const getEventGetStorySessionActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
42
|
return ({
|
|
19
43
|
[quidproquo_core_1.EventActionType.GetStorySession]: getProcessGetStorySession(qpqConfig),
|
package/lib/commonjs/getActionProcessor/core/event/express/api/getEventMatchStoryActionProcessor.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getEventMatchStoryActionProcessor = void 0;
|
|
13
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
13
|
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
15
14
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
16
15
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
@@ -20,8 +19,7 @@ const getProcessMatchStory = (qpqConfig) => {
|
|
|
20
19
|
// Sort the routes by string length
|
|
21
20
|
// Note: We may need to filter variable routes out {} as the variables are length independent
|
|
22
21
|
const sortedRoutes = routes
|
|
23
|
-
.filter((r) => r.method === qpqEventRecord.method ||
|
|
24
|
-
qpqEventRecord.method === 'OPTIONS')
|
|
22
|
+
.filter((r) => r.method === qpqEventRecord.method || qpqEventRecord.method === 'OPTIONS')
|
|
25
23
|
.sort((a, b) => {
|
|
26
24
|
if (a.path.length < b.path.length)
|
|
27
25
|
return -1;
|
|
@@ -40,9 +40,7 @@ const getProcessTransformResponseResult = (qpqConfig) =>
|
|
|
40
40
|
const [record] = qpqEventRecordResponses;
|
|
41
41
|
const [expressEvent] = eventParams;
|
|
42
42
|
// If we have an error, we need to transform it to a response, otherwise we can just use the record as is
|
|
43
|
-
const successRecord = record.success
|
|
44
|
-
? record.result
|
|
45
|
-
: getResponseFromErrorResult(record.error);
|
|
43
|
+
const successRecord = record.success ? record.result : getResponseFromErrorResult(record.error);
|
|
46
44
|
const recordHeaders = successRecord.headers || {};
|
|
47
45
|
const headers = Object.assign(Object.assign({}, quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(qpqConfig, {}, expressEvent.headers)), recordHeaders);
|
|
48
46
|
return (0, quidproquo_core_1.actionResult)({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ActionProcessorListResolver } from 'quidproquo';
|
|
1
|
+
import { ActionProcessorListResolver } from 'quidproquo-core';
|
|
2
2
|
export declare const getExpressApiEventEventProcessor: ActionProcessorListResolver;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DynamicModuleLoader, QPQConfig } from 'quidproquo';
|
|
1
|
+
import { DynamicModuleLoader, QPQConfig } from 'quidproquo-core';
|
|
2
2
|
import { ExpressEvent, ExpressEventResponse } from '../types';
|
|
3
3
|
export declare const route: (expressEvent: ExpressEvent, qpqConfig: QPQConfig, dynamicModuleLoader: DynamicModuleLoader) => Promise<ExpressEventResponse>;
|
|
@@ -10,39 +10,40 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.route = void 0;
|
|
13
|
-
const crypto_1 = require("crypto");
|
|
14
|
-
const quidproquo_1 = require("quidproquo");
|
|
15
13
|
const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
|
|
16
14
|
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
17
|
-
const
|
|
15
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
16
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
17
|
+
const crypto_1 = require("crypto");
|
|
18
18
|
const actionProcessor_1 = require("../actionProcessor");
|
|
19
|
+
const getActionProcessor_1 = require("../getActionProcessor");
|
|
19
20
|
// TODO: Make this a util or something based on server time or something..
|
|
20
21
|
const getDateNow = () => new Date().toISOString();
|
|
21
22
|
const ErrorTypeHttpResponseMap = {
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
23
|
+
[quidproquo_core_1.ErrorTypeEnum.BadRequest]: 400,
|
|
24
|
+
[quidproquo_core_1.ErrorTypeEnum.Unauthorized]: 401,
|
|
25
|
+
[quidproquo_core_1.ErrorTypeEnum.PaymentRequired]: 402,
|
|
26
|
+
[quidproquo_core_1.ErrorTypeEnum.Forbidden]: 403,
|
|
27
|
+
[quidproquo_core_1.ErrorTypeEnum.NotFound]: 404,
|
|
28
|
+
[quidproquo_core_1.ErrorTypeEnum.TimeOut]: 408,
|
|
29
|
+
[quidproquo_core_1.ErrorTypeEnum.Conflict]: 409,
|
|
30
|
+
[quidproquo_core_1.ErrorTypeEnum.UnsupportedMediaType]: 415,
|
|
31
|
+
[quidproquo_core_1.ErrorTypeEnum.OutOfResources]: 500,
|
|
32
|
+
[quidproquo_core_1.ErrorTypeEnum.GenericError]: 500,
|
|
33
|
+
[quidproquo_core_1.ErrorTypeEnum.NotImplemented]: 501,
|
|
34
|
+
[quidproquo_core_1.ErrorTypeEnum.NoContent]: 204,
|
|
35
|
+
[quidproquo_core_1.ErrorTypeEnum.Invalid]: 422,
|
|
35
36
|
};
|
|
36
37
|
const route = (expressEvent, qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
const serviceName =
|
|
38
|
-
const resolveStory = (0,
|
|
38
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
39
|
+
const resolveStory = (0, quidproquo_core_1.createRuntime)(qpqConfig, {
|
|
39
40
|
depth: 0,
|
|
40
|
-
accessToken:
|
|
41
|
+
accessToken: quidproquo_webserver_1.qpqWebServerUtils.getAccessTokenFromHeaders(expressEvent.headers),
|
|
41
42
|
context: {},
|
|
42
43
|
}, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
44
|
return (Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, quidproquo_actionprocessor_awslambda_1.getAwsActionProcessors)(qpqConfig, dynamicModuleLoader))), (yield (0, getActionProcessor_1.getExpressApiEventEventProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, actionProcessor_1.getGraphDatabaseActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, quidproquo_actionprocessor_node_1.getCustomActionActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
44
|
-
}), getDateNow, (0, quidproquo_actionprocessor_awslambda_1.getLogger)(qpqConfig), `${serviceName}::${(0, crypto_1.randomUUID)()}`,
|
|
45
|
-
const result = yield resolveStory(
|
|
45
|
+
}), getDateNow, (0, quidproquo_actionprocessor_awslambda_1.getLogger)(qpqConfig), `${serviceName}::${(0, crypto_1.randomUUID)()}`, quidproquo_core_1.QpqRuntimeType.API, dynamicModuleLoader, []);
|
|
46
|
+
const result = yield resolveStory(quidproquo_core_1.askProcessEvent, [expressEvent]);
|
|
46
47
|
// Run the callback
|
|
47
48
|
if (!result.error) {
|
|
48
49
|
const response = {
|
package/lib/commonjs/index.d.ts
CHANGED
package/lib/commonjs/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./main"), exports);
|
|
18
17
|
__exportStar(require("./config"), exports);
|
|
18
|
+
__exportStar(require("./main"), exports);
|
package/lib/commonjs/main.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,20 +13,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
13
|
};
|
|
15
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
15
|
exports.startDevServer = void 0;
|
|
17
|
-
|
|
16
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
17
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
18
18
|
const body_parser_1 = __importDefault(require("body-parser"));
|
|
19
19
|
const express_1 = __importDefault(require("express"));
|
|
20
20
|
const multer_1 = __importDefault(require("multer"));
|
|
21
21
|
const path_1 = __importDefault(require("path"));
|
|
22
|
-
const quidproquo_1 = require("quidproquo");
|
|
23
|
-
const implementations_1 = require("./implementations");
|
|
24
22
|
const allServiceConfig_1 = require("./allServiceConfig");
|
|
25
|
-
const
|
|
23
|
+
const implementations_1 = require("./implementations");
|
|
24
|
+
const getServiceBaseDomain = (qpqConfig, devServerConfig) => quidproquo_webserver_1.qpqWebServerUtils.getDomainRoot(`${devServerConfig.serverDomain}:${devServerConfig.serverPort}`, quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
|
|
26
25
|
const getApiDomainsFromConfig = (qpqConfig, devServerConfig) => {
|
|
27
26
|
const baseDomain = getServiceBaseDomain(qpqConfig, devServerConfig);
|
|
28
|
-
const serviceName =
|
|
27
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
29
28
|
// Get apis
|
|
30
|
-
const apiConfigs =
|
|
29
|
+
const apiConfigs = quidproquo_webserver_1.qpqWebServerUtils.getApiConfigs(qpqConfig);
|
|
31
30
|
const apiDomains = apiConfigs.map((apiConfig) => ({
|
|
32
31
|
apiName: apiConfig.apiName,
|
|
33
32
|
service: serviceName,
|
|
@@ -39,7 +38,7 @@ const getApiDomainsFromConfig = (qpqConfig, devServerConfig) => {
|
|
|
39
38
|
return apiDomains;
|
|
40
39
|
};
|
|
41
40
|
const getDynamicModuleLoader = (qpqConfig, devServerConfig) => {
|
|
42
|
-
const serviceName =
|
|
41
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
43
42
|
return (runtime) => __awaiter(void 0, void 0, void 0, function* () { return devServerConfig.dynamicModuleLoader(serviceName, runtime); });
|
|
44
43
|
};
|
|
45
44
|
const startDevServer = (devServerConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -57,7 +56,7 @@ const startDevServer = (devServerConfig) => __awaiter(void 0, void 0, void 0, fu
|
|
|
57
56
|
res.header('Access-Control-Allow-Methods', '*');
|
|
58
57
|
res.header('Access-Control-Allow-Origin', '*');
|
|
59
58
|
res.header('Access-Control-Allow-Credentials', 'false');
|
|
60
|
-
const serviceList = allServiceConfig.map((qpqConfig) =>
|
|
59
|
+
const serviceList = allServiceConfig.map((qpqConfig) => quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig)).map((name) => `api/${name}`);
|
|
61
60
|
res.json(serviceList);
|
|
62
61
|
});
|
|
63
62
|
app.use(express_1.default.json());
|
|
@@ -85,13 +84,13 @@ const startDevServer = (devServerConfig) => __awaiter(void 0, void 0, void 0, fu
|
|
|
85
84
|
res.header('Access-Control-Allow-Credentials', 'false');
|
|
86
85
|
// TODO: Get list of services from config dynamically
|
|
87
86
|
const serviceLog = req.body;
|
|
88
|
-
let runtimeModule =
|
|
89
|
-
if (serviceLog.runtimeType ===
|
|
87
|
+
let runtimeModule = quidproquo_core_1.askProcessEvent;
|
|
88
|
+
if (serviceLog.runtimeType === quidproquo_core_1.QpqRuntimeType.EXECUTE_STORY) {
|
|
90
89
|
const [srcEntry, module] = serviceLog.tags[0].split('::');
|
|
91
90
|
const loadedModule = yield devServerConfig.dynamicModuleLoader(serviceLog.moduleName, srcEntry);
|
|
92
91
|
runtimeModule = loadedModule[module];
|
|
93
92
|
}
|
|
94
|
-
const result = yield (0,
|
|
93
|
+
const result = yield (0, quidproquo_core_1.qpqExecuteLog)(serviceLog, runtimeModule);
|
|
95
94
|
res.json(result);
|
|
96
95
|
}));
|
|
97
96
|
// Proxy for all services
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { askThrowError, ErrorTypeEnum, getProcessCustomImplementation, GraphDatabaseActionType, qpqCoreUtils, } from 'quidproquo-core';
|
|
2
2
|
import { askServiceFunctionExecute } from 'quidproquo-webserver';
|
|
3
3
|
import { randomUUID } from 'crypto';
|
|
4
4
|
const getGraphDatabaseExecuteOpenCypherStory = (qpqConfig) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { qpqCoreUtils
|
|
1
|
+
import { qpqCoreUtils } from 'quidproquo-core';
|
|
2
|
+
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
2
3
|
// Create an async function to fetch all services
|
|
3
4
|
export function getAllServiceConfigs(devServerConfig) {
|
|
4
5
|
// Clone it
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import { defineServiceFunction } from 'quidproquo-webserver';
|
|
2
|
+
import path from 'path';
|
|
3
3
|
export const defineDevServerConfig = (buildPath, advancedSettings) => {
|
|
4
4
|
const onlyDeploySafe = advancedSettings?.onlyDeploySafe ?? true;
|
|
5
5
|
const vpcList = advancedSettings?.vpcList || [];
|
|
6
6
|
const pathToRuntime = path.join(__dirname, '../../entry/serviceFunction/runCypherQuery');
|
|
7
|
-
const graphAccessConfigs = vpcList.map((vpcName) => defineServiceFunction(
|
|
7
|
+
const graphAccessConfigs = vpcList.map((vpcName) => defineServiceFunction(`full@${pathToRuntime}::runCypherQuery`, {
|
|
8
8
|
virtualNetworkName: vpcName,
|
|
9
9
|
functionName: `graphQuery${vpcName}`,
|
|
10
10
|
}));
|
package/lib/esm/getActionProcessor/core/event/express/api/getEventGetStorySessionActionProcessor.js
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1
|
+
import { decodeAccessToken } from 'quidproquo-actionprocessor-awslambda';
|
|
3
2
|
import { actionResult, EventActionType, } from 'quidproquo-core';
|
|
4
|
-
|
|
3
|
+
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
4
|
+
const getProcessGetStorySession = (qpqConfig) => {
|
|
5
|
+
return async ({ matchStoryResult, qpqEventRecord }, session) => {
|
|
6
|
+
const accessToken = qpqWebServerUtils.getAccessTokenFromHeaders(qpqEventRecord.headers);
|
|
7
|
+
if (!accessToken) {
|
|
8
|
+
return actionResult(void 0);
|
|
9
|
+
}
|
|
10
|
+
// if this endpoint has no auth settings, BUT we do have an access token
|
|
11
|
+
// then we want to just attempt to extract info for logs, but we will say that its
|
|
12
|
+
// wasValid = false
|
|
13
|
+
if (!matchStoryResult.config?.routeAuthSettings?.userDirectoryName) {
|
|
14
|
+
// If this endpoint is unauthenticated, then we will just decode it, and say it wasnt valid, for logs
|
|
15
|
+
const info = qpqWebServerUtils.decodeJWT(accessToken);
|
|
16
|
+
return actionResult({
|
|
17
|
+
...session,
|
|
18
|
+
decodedAccessToken: {
|
|
19
|
+
exp: info?.exp || 0,
|
|
20
|
+
userDirectory: '',
|
|
21
|
+
userId: info?.sub || info?.id || info?.userId || info?.username || '',
|
|
22
|
+
username: info?.username || info?.userId || info?.sub || info?.id || '',
|
|
23
|
+
wasValid: false,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const decodedAccessToken = await decodeAccessToken(matchStoryResult.config.routeAuthSettings.userDirectoryName, qpqConfig, accessToken, true);
|
|
28
|
+
return actionResult({
|
|
29
|
+
...session,
|
|
30
|
+
decodedAccessToken,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
};
|
|
5
34
|
export const getEventGetStorySessionActionProcessor = async (qpqConfig) => ({
|
|
6
35
|
[EventActionType.GetStorySession]: getProcessGetStorySession(qpqConfig),
|
|
7
36
|
});
|
package/lib/esm/getActionProcessor/core/event/express/api/getEventMatchStoryActionProcessor.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import { awsLambdaUtils } from 'quidproquo-actionprocessor-awslambda';
|
|
3
2
|
import { actionResult, actionResultError, ErrorTypeEnum, EventActionType, } from 'quidproquo-core';
|
|
4
|
-
import { qpqWebServerUtils
|
|
3
|
+
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
5
4
|
const getProcessMatchStory = (qpqConfig) => {
|
|
6
5
|
const routes = qpqWebServerUtils.getAllRoutes(qpqConfig);
|
|
7
6
|
return async ({ qpqEventRecord }) => {
|
|
8
7
|
// Sort the routes by string length
|
|
9
8
|
// Note: We may need to filter variable routes out {} as the variables are length independent
|
|
10
9
|
const sortedRoutes = routes
|
|
11
|
-
.filter((r) => r.method === qpqEventRecord.method ||
|
|
12
|
-
qpqEventRecord.method === 'OPTIONS')
|
|
10
|
+
.filter((r) => r.method === qpqEventRecord.method || qpqEventRecord.method === 'OPTIONS')
|
|
13
11
|
.sort((a, b) => {
|
|
14
12
|
if (a.path.length < b.path.length)
|
|
15
13
|
return -1;
|
|
@@ -28,9 +28,7 @@ async ({ eventParams, qpqEventRecordResponses }) => {
|
|
|
28
28
|
const [record] = qpqEventRecordResponses;
|
|
29
29
|
const [expressEvent] = eventParams;
|
|
30
30
|
// If we have an error, we need to transform it to a response, otherwise we can just use the record as is
|
|
31
|
-
const successRecord = record.success
|
|
32
|
-
? record.result
|
|
33
|
-
: getResponseFromErrorResult(record.error);
|
|
31
|
+
const successRecord = record.success ? record.result : getResponseFromErrorResult(record.error);
|
|
34
32
|
const recordHeaders = successRecord.headers || {};
|
|
35
33
|
const headers = {
|
|
36
34
|
...qpqWebServerUtils.getCorsHeaders(qpqConfig, {}, expressEvent.headers),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ActionProcessorListResolver } from 'quidproquo';
|
|
1
|
+
import { ActionProcessorListResolver } from 'quidproquo-core';
|
|
2
2
|
export declare const getExpressApiEventEventProcessor: ActionProcessorListResolver;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DynamicModuleLoader, QPQConfig } from 'quidproquo';
|
|
1
|
+
import { DynamicModuleLoader, QPQConfig } from 'quidproquo-core';
|
|
2
2
|
import { ExpressEvent, ExpressEventResponse } from '../types';
|
|
3
3
|
export declare const route: (expressEvent: ExpressEvent, qpqConfig: QPQConfig, dynamicModuleLoader: DynamicModuleLoader) => Promise<ExpressEventResponse>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
2
|
-
import { askProcessEvent, createRuntime, ErrorTypeEnum, qpqCoreUtils, QpqRuntimeType, qpqWebServerUtils, } from 'quidproquo';
|
|
3
1
|
import { getAwsActionProcessors, getLogger } from 'quidproquo-actionprocessor-awslambda';
|
|
4
2
|
import { getCustomActionActionProcessor } from 'quidproquo-actionprocessor-node';
|
|
5
|
-
import {
|
|
3
|
+
import { askProcessEvent, createRuntime, ErrorTypeEnum, qpqCoreUtils, QpqRuntimeType } from 'quidproquo-core';
|
|
4
|
+
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
5
|
+
import { randomUUID } from 'crypto';
|
|
6
6
|
import { getGraphDatabaseActionProcessor } from '../actionProcessor';
|
|
7
|
+
import { getExpressApiEventEventProcessor } from '../getActionProcessor';
|
|
7
8
|
// TODO: Make this a util or something based on server time or something..
|
|
8
9
|
const getDateNow = () => new Date().toISOString();
|
|
9
10
|
const ErrorTypeHttpResponseMap = {
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
package/lib/esm/main.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { askProcessEvent, qpqCoreUtils, qpqExecuteLog, QpqRuntimeType } from 'quidproquo-core';
|
|
2
|
+
import { qpqWebServerUtils } from 'quidproquo-webserver';
|
|
3
3
|
import bodyParser from 'body-parser';
|
|
4
4
|
import express from 'express';
|
|
5
5
|
import multer from 'multer';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import { askProcessEvent, qpqCoreUtils, qpqExecuteLog, QpqRuntimeType, qpqWebServerUtils, } from 'quidproquo';
|
|
8
|
-
import { route } from './implementations';
|
|
9
7
|
import { getAllServiceConfigs } from './allServiceConfig';
|
|
8
|
+
import { route } from './implementations';
|
|
10
9
|
const getServiceBaseDomain = (qpqConfig, devServerConfig) => qpqWebServerUtils.getDomainRoot(`${devServerConfig.serverDomain}:${devServerConfig.serverPort}`, qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
|
|
11
10
|
const getApiDomainsFromConfig = (qpqConfig, devServerConfig) => {
|
|
12
11
|
const baseDomain = getServiceBaseDomain(qpqConfig, devServerConfig);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-dev-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.233",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
16
16
|
"watch": "tsc -p tsconfig.commonjs.json -w",
|
|
17
17
|
"build:cjs": "tsc -p tsconfig.commonjs.json",
|
|
18
|
-
"build:esm": "tsc -p tsconfig.esm.json"
|
|
18
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
19
|
+
"lint": "npx eslint .",
|
|
20
|
+
"lint:fix": "npx eslint . --fix",
|
|
21
|
+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\""
|
|
19
22
|
},
|
|
20
23
|
"repository": {
|
|
21
24
|
"type": "git",
|
|
@@ -30,14 +33,14 @@
|
|
|
30
33
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
31
34
|
"dependencies": {
|
|
32
35
|
"multer": "^1.4.5-lts.1",
|
|
33
|
-
"quidproquo-core": "0.0.
|
|
34
|
-
"quidproquo-webserver": "0.0.
|
|
35
|
-
"quidproquo-actionprocessor-awslambda": "0.0.
|
|
36
|
-
"quidproquo-actionprocessor-node": "0.0.
|
|
36
|
+
"quidproquo-core": "0.0.233",
|
|
37
|
+
"quidproquo-webserver": "0.0.233",
|
|
38
|
+
"quidproquo-actionprocessor-awslambda": "0.0.233",
|
|
39
|
+
"quidproquo-actionprocessor-node": "0.0.233"
|
|
37
40
|
},
|
|
38
41
|
"devDependencies": {
|
|
39
42
|
"@types/multer": "^1.4.12",
|
|
40
|
-
"quidproquo-tsconfig": "0.0.
|
|
43
|
+
"quidproquo-tsconfig": "0.0.233",
|
|
41
44
|
"typescript": "^4.9.3"
|
|
42
45
|
}
|
|
43
46
|
}
|