quidproquo-webserver
Advanced tools
Comparing version 0.0.191 to 0.0.192
@@ -8,2 +8,5 @@ import { QPQConfig, QPQConfigAdvancedSettings } from 'quidproquo-core'; | ||
} | ||
export declare const defineLogs: (buildPath: string, webFilesPath: string, rootDomain: string, advancedSettings?: QPQConfigAdvancedLogSettings) => QPQConfig; | ||
export declare const logReportsResourceName = "qpq-log-reports"; | ||
export declare const wsConnectionResourceName = "qpq-admin-connections"; | ||
export declare const adminUserDirectory = "qpq-admin"; | ||
export declare const defineLogs: (buildPath: string, webFilesPath: string, rootDomain: string, hostService: string, services: string[], advancedSettings?: QPQConfigAdvancedLogSettings) => QPQConfig; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defineLogs = void 0; | ||
exports.defineLogs = exports.adminUserDirectory = exports.wsConnectionResourceName = exports.logReportsResourceName = void 0; | ||
const quidproquo_core_1 = require("quidproquo-core"); | ||
const route_1 = require("./route"); | ||
const webEntry_1 = require("./webEntry"); | ||
const websocket_1 = require("./websocket"); | ||
// NEVER EVER CHANGE THIS NAME | ||
@@ -13,6 +14,9 @@ // if you do, you might get logs generated from the logging service | ||
const logResourceName = 'qpq-logs'; | ||
const defineLogs = (buildPath, webFilesPath, rootDomain, advancedSettings) => { | ||
exports.logReportsResourceName = 'qpq-log-reports'; | ||
exports.wsConnectionResourceName = 'qpq-admin-connections'; | ||
exports.adminUserDirectory = 'qpq-admin'; | ||
const defineLogs = (buildPath, webFilesPath, rootDomain, hostService, services, advancedSettings) => { | ||
const routeAuthSettings = { | ||
routeAuthSettings: { | ||
userDirectoryName: 'qpq-admin', | ||
userDirectoryName: exports.adminUserDirectory, | ||
}, | ||
@@ -35,2 +39,3 @@ }; | ||
const configs = [ | ||
(0, quidproquo_core_1.defineGlobal)('qpq-serviceNames', services), | ||
(0, quidproquo_core_1.defineGlobal)('qpq-log-retention-days', logRetentionDays), | ||
@@ -61,2 +66,10 @@ (0, quidproquo_core_1.defineStorageDrive)(logResourceName, { | ||
}), | ||
(0, quidproquo_core_1.defineStorageDrive)(exports.logReportsResourceName, { | ||
deprecated: advancedSettings === null || advancedSettings === void 0 ? void 0 : advancedSettings.deprecated, | ||
lifecycleRules: [ | ||
{ | ||
deleteAfterDays: 30, | ||
}, | ||
], | ||
}), | ||
(0, quidproquo_core_1.defineKeyValueStore)(logResourceName, 'correlation', [], { | ||
@@ -70,9 +83,14 @@ indexes: [ | ||
}), | ||
(0, quidproquo_core_1.defineUserDirectory)('qpq-admin', buildPath), | ||
(0, quidproquo_core_1.defineKeyValueStore)(exports.wsConnectionResourceName, 'id', undefined, { | ||
indexes: ['userId'], | ||
}), | ||
(0, quidproquo_core_1.defineUserDirectory)(exports.adminUserDirectory, buildPath), | ||
(0, route_1.defineRoute)('POST', '/login', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'loginController'), 'login'), | ||
(0, route_1.defineRoute)('POST', '/refreshToken', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'loginController'), 'refreshToken'), | ||
(0, route_1.defineRoute)('POST', '/challenge', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'loginController'), 'respondToAuthChallenge'), | ||
(0, route_1.defineRoute)('GET', '/admin/services', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'logController'), 'getServiceNames'), | ||
(0, route_1.defineRoute)('POST', '/log/list', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'logController'), 'getLogs', routeAuthSettings), | ||
(0, route_1.defineRoute)('GET', '/log/{correlationId}', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'logController'), 'getLog', routeAuthSettings), | ||
(0, route_1.defineRoute)('GET', '/log/children/{fromCorrelation}', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'logController'), 'getChildren', routeAuthSettings), | ||
(0, route_1.defineRoute)('GET', '/log/{correlationId}/hierarchies', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'logController'), 'getHierarchies', routeAuthSettings), | ||
(0, route_1.defineRoute)('GET', '/log/downloadurl/{correlationId}', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'logController'), 'downloadUrl', routeAuthSettings), | ||
@@ -83,2 +101,18 @@ (0, route_1.defineRoute)('POST', '/log/chat/message', (0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'logController'), 'sendChatMessage', routeAuthSettings), | ||
(0, quidproquo_core_1.defineKeyValueStore)('qpq-log-messages', 'correlationId', ['timestamp']), | ||
(0, websocket_1.defineWebsocket)('wsadmin', rootDomain, buildPath, { | ||
onConnect: { | ||
src: (0, quidproquo_core_1.getServiceEntry)('log', 'webSocket', 'onWebsocketEvent'), | ||
runtime: 'onConnect', | ||
}, | ||
onDisconnect: { | ||
src: (0, quidproquo_core_1.getServiceEntry)('log', 'webSocket', 'onWebsocketEvent'), | ||
runtime: 'onDisconnect', | ||
}, | ||
onMessage: { | ||
src: (0, quidproquo_core_1.getServiceEntry)('log', 'webSocket', 'onWebsocketEvent'), | ||
runtime: 'onMessage', | ||
}, | ||
}, { | ||
apiName: 'wsadmin', | ||
}), | ||
(0, webEntry_1.defineWebEntry)('admin', { | ||
@@ -100,3 +134,8 @@ buildPath: webFilesPath, | ||
// maybe pass in the api / localhost port in as args | ||
'connect-src': ["'self'", { api: 'api' }, 'http://localhost:8080'], | ||
'connect-src': [ | ||
"'self'", | ||
{ api: 'api' }, | ||
'http://localhost:8080', | ||
{ protocol: 'wss', api: 'wsadmin', service: hostService }, | ||
], | ||
'style-src': [ | ||
@@ -103,0 +142,0 @@ "'self'", |
@@ -7,1 +7,2 @@ export * from './actions'; | ||
export * from './services'; | ||
export * from './context'; |
@@ -23,1 +23,2 @@ "use strict"; | ||
__exportStar(require("./services"), exports); | ||
__exportStar(require("./context"), exports); |
@@ -8,2 +8,7 @@ import { QpqRuntimeType, AskResponse } from 'quidproquo-core'; | ||
runtimeType: QpqRuntimeType; | ||
infoFilter: string; | ||
errorFilter: string; | ||
serviceFilter: string; | ||
userFilter: string; | ||
onlyErrors: boolean; | ||
} | ||
@@ -14,2 +19,6 @@ export declare function getLogs(event: HTTPEvent, params: {}): AskResponse<HTTPEventResponse>; | ||
}): Generator<import("quidproquo-core").Action<any>, HTTPEventResponse<string>, any>; | ||
export declare function getServiceNames(event: HTTPEvent): Generator<import("quidproquo-core").ConfigGetGlobalAction, HTTPEventResponse<string>, unknown>; | ||
export declare function getHierarchies(event: HTTPEvent, params: { | ||
correlationId: string; | ||
}): Generator<import("quidproquo-core").Action<any>, HTTPEventResponse<string>, any>; | ||
export declare function getChildren(event: HTTPEvent, params: { | ||
@@ -16,0 +25,0 @@ fromCorrelation: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getChatMessages = exports.sendChatMessage = exports.downloadUrl = exports.getChildren = exports.getLog = exports.getLogs = void 0; | ||
exports.getChatMessages = exports.sendChatMessage = exports.downloadUrl = exports.getChildren = exports.getHierarchies = exports.getServiceNames = exports.getLog = exports.getLogs = void 0; | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
@@ -8,8 +8,8 @@ const quidproquo_core_1 = require("quidproquo-core"); | ||
const logMetadataData_1 = require("../data/logMetadataData"); | ||
const askLogSendChatMessage_1 = require("../logic/askLogSendChatMessage"); | ||
const askGetLogChatMessages_1 = require("../logic/askGetLogChatMessages"); | ||
const logic_1 = require("../logic"); | ||
const askLogSendChatMessage_1 = require("../../logic/askLogSendChatMessage"); | ||
const askGetLogChatMessages_1 = require("../../logic/askGetLogChatMessages"); | ||
const logic_1 = require("../../logic"); | ||
function* getLogs(event, params) { | ||
const { nextPageKey, startIsoDateTime, endIsoDateTime, runtimeType } = (0, httpEventUtils_1.fromJsonEventRequest)(event); | ||
const logs = yield* logic_1.logsLogic.askGetLogs(runtimeType, startIsoDateTime, endIsoDateTime, nextPageKey); | ||
const { nextPageKey, startIsoDateTime, endIsoDateTime, runtimeType, errorFilter, serviceFilter, infoFilter, userFilter, onlyErrors, } = (0, httpEventUtils_1.fromJsonEventRequest)(event); | ||
const logs = yield* logic_1.logsLogic.askGetLogs(runtimeType, startIsoDateTime, endIsoDateTime, errorFilter, serviceFilter, infoFilter, userFilter, onlyErrors, nextPageKey); | ||
return (0, httpEventUtils_1.toJsonEventResponse)(logs); | ||
@@ -26,2 +26,12 @@ } | ||
exports.getLog = getLog; | ||
function* getServiceNames(event) { | ||
const serviceNames = yield* (0, quidproquo_core_1.askConfigGetGlobal)('qpq-serviceNames'); | ||
return (0, httpEventUtils_1.toJsonEventResponse)(serviceNames); | ||
} | ||
exports.getServiceNames = getServiceNames; | ||
function* getHierarchies(event, params) { | ||
const reportUrl = yield* (0, logMetadataData_1.askGetHierarchiesByCorrelation)(params.correlationId, event.query.refresh === 'true'); | ||
return (0, httpEventUtils_1.toJsonEventResponse)({ url: reportUrl }); | ||
} | ||
exports.getHierarchies = getHierarchies; | ||
function* getChildren(event, params) { | ||
@@ -28,0 +38,0 @@ const log = yield* (0, logMetadataData_1.askGetByFromCorrelation)(params.fromCorrelation); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -30,6 +7,6 @@ exports.respondToAuthChallenge = exports.refreshToken = exports.login = void 0; | ||
const index_1 = require("../../../../index"); | ||
const authLogic = __importStar(require("../logic/auth")); | ||
const logic_1 = require("../../logic"); | ||
function* login(event) { | ||
const { username, password } = index_1.qpqWebServerUtils.fromJsonEventRequest(event); | ||
const authResponse = yield* authLogic.askLogin(username, password); | ||
const authResponse = yield* logic_1.authLogic.askLogin(username, password); | ||
return index_1.qpqWebServerUtils.toJsonEventResponse(authResponse); | ||
@@ -40,3 +17,3 @@ } | ||
const { refreshToken } = index_1.qpqWebServerUtils.fromJsonEventRequest(event); | ||
const refreshResponse = yield* authLogic.askRefreshToken(refreshToken); | ||
const refreshResponse = yield* logic_1.authLogic.askRefreshToken(refreshToken); | ||
return index_1.qpqWebServerUtils.toJsonEventResponse(refreshResponse); | ||
@@ -48,5 +25,5 @@ } | ||
// TODO: Make this more generic ~ Currently we only support one challenge | ||
const response = yield* authLogic.askRespondToAuthChallenge(authChallenge.email, quidproquo_core_1.AuthenticateUserChallenge.NEW_PASSWORD_REQUIRED, authChallenge.session, authChallenge.newPassword); | ||
const response = yield* logic_1.authLogic.askRespondToAuthChallenge(authChallenge.email, quidproquo_core_1.AuthenticateUserChallenge.NEW_PASSWORD_REQUIRED, authChallenge.session, authChallenge.newPassword); | ||
return index_1.qpqWebServerUtils.toJsonEventResponse(response); | ||
} | ||
exports.respondToAuthChallenge = respondToAuthChallenge; |
@@ -1,6 +0,10 @@ | ||
import { AskResponse, QpqPagedData, QpqRuntimeType } from 'quidproquo-core'; | ||
import { AskResponse, QpqPagedData, QpqRuntimeType, StoryResultMetadata, StoryResultMetadataWithChildren } from 'quidproquo-core'; | ||
import { LogMetadata } from '../domain'; | ||
export declare function askUpsert(logMetadata: LogMetadata): AskResponse<void>; | ||
export declare function askListLogs(runtimeType: QpqRuntimeType, startDateTime: string, endDateTime: string, nextPageKey?: string): AskResponse<QpqPagedData<LogMetadata>>; | ||
export declare function askListLogs(runtimeType: QpqRuntimeType, startDateTime: string, endDateTime: string, errorFilter: string, serviceFilter: string, infoFilter: string, userFilter: string, onlyErrors: boolean, nextPageKey?: string): AskResponse<QpqPagedData<LogMetadata>>; | ||
export declare function askGetByCorrelation(correlation: string): AskResponse<LogMetadata | undefined>; | ||
export declare function askGetByFromCorrelation(fromCorrelation: string): AskResponse<QpqPagedData<LogMetadata>>; | ||
export declare function askGetAllByFromCorrelation(fromCorrelation: string): AskResponse<LogMetadata[]>; | ||
export declare function askFindRootLog(fromCorrelation?: string): AskResponse<LogMetadata | undefined>; | ||
export declare function askCreateHierarchy(rootStoryResultMetadata: StoryResultMetadata): AskResponse<StoryResultMetadataWithChildren>; | ||
export declare function askGetHierarchiesByCorrelation(correlation: string, forceRefresh: boolean): AskResponse<string | undefined>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.askGetByFromCorrelation = exports.askGetByCorrelation = exports.askListLogs = exports.askUpsert = void 0; | ||
exports.askGetHierarchiesByCorrelation = exports.askCreateHierarchy = exports.askFindRootLog = exports.askGetAllByFromCorrelation = exports.askGetByFromCorrelation = exports.askGetByCorrelation = exports.askListLogs = exports.askUpsert = void 0; | ||
const quidproquo_core_1 = require("quidproquo-core"); | ||
const config_1 = require("../../../../config"); | ||
const metadataStoreName = 'qpq-logs'; | ||
@@ -10,3 +11,20 @@ function* askUpsert(logMetadata) { | ||
exports.askUpsert = askUpsert; | ||
function* askListLogs(runtimeType, startDateTime, endDateTime, nextPageKey) { | ||
function* askListLogs(runtimeType, startDateTime, endDateTime, errorFilter, serviceFilter, infoFilter, userFilter, onlyErrors, nextPageKey) { | ||
const filters = []; | ||
if (onlyErrors) { | ||
filters.push((0, quidproquo_core_1.kvsExists)('error')); | ||
} | ||
if (serviceFilter) { | ||
filters.push((0, quidproquo_core_1.kvsEqual)('moduleName', serviceFilter)); | ||
} | ||
if (infoFilter) { | ||
filters.push((0, quidproquo_core_1.kvsContains)('generic', infoFilter)); | ||
} | ||
if (errorFilter) { | ||
filters.push((0, quidproquo_core_1.kvsContains)('error', errorFilter)); | ||
} | ||
if (userFilter) { | ||
filters.push((0, quidproquo_core_1.kvsContains)('userInfo', userFilter)); | ||
} | ||
console.log('filters', JSON.stringify(filters, null, 2)); | ||
const logs = yield* (0, quidproquo_core_1.askKeyValueStoreQuery)(metadataStoreName, (0, quidproquo_core_1.kvsAnd)([ | ||
@@ -17,2 +35,3 @@ (0, quidproquo_core_1.kvsEqual)('runtimeType', runtimeType), | ||
nextPageKey, | ||
filter: filters.length > 0 ? (0, quidproquo_core_1.kvsAnd)(filters) : undefined, | ||
}); | ||
@@ -32,1 +51,36 @@ return logs; | ||
exports.askGetByFromCorrelation = askGetByFromCorrelation; | ||
function* askGetAllByFromCorrelation(fromCorrelation) { | ||
return yield* (0, quidproquo_core_1.askKeyValueStoreQueryAll)(metadataStoreName, (0, quidproquo_core_1.kvsEqual)('fromCorrelation', fromCorrelation)); | ||
} | ||
exports.askGetAllByFromCorrelation = askGetAllByFromCorrelation; | ||
function* askFindRootLog(fromCorrelation) { | ||
if (!fromCorrelation) { | ||
return; | ||
} | ||
const parentLog = yield* askGetByCorrelation(fromCorrelation); | ||
return (yield* askFindRootLog(parentLog === null || parentLog === void 0 ? void 0 : parentLog.fromCorrelation)) || parentLog; | ||
} | ||
exports.askFindRootLog = askFindRootLog; | ||
function* askCreateHierarchy(rootStoryResultMetadata) { | ||
const childrenLogs = yield* askGetAllByFromCorrelation(rootStoryResultMetadata.correlation); | ||
const sortedChildren = childrenLogs.sort((a, b) => { | ||
return a.startedAt < b.startedAt ? -1 : 1; | ||
}); | ||
const childrenWithHierarchies = yield* (0, quidproquo_core_1.askMapParallel)(sortedChildren, askCreateHierarchy); | ||
return Object.assign(Object.assign({}, rootStoryResultMetadata), { children: childrenWithHierarchies }); | ||
} | ||
exports.askCreateHierarchy = askCreateHierarchy; | ||
function* askGetHierarchiesByCorrelation(correlation, forceRefresh) { | ||
const root = yield* askFindRootLog(correlation); | ||
if (root) { | ||
const rootReportFilename = `${root.correlation}-tree.json`; | ||
const reportExists = yield* (0, quidproquo_core_1.askFileExists)(config_1.logReportsResourceName, rootReportFilename); | ||
if (!reportExists || forceRefresh) { | ||
const report = yield* askCreateHierarchy(root); | ||
yield* (0, quidproquo_core_1.askFileWriteTextContents)(config_1.logReportsResourceName, rootReportFilename, JSON.stringify(report)); | ||
} | ||
return yield* (0, quidproquo_core_1.askFileGenerateTemporarySecureUrl)(config_1.logReportsResourceName, rootReportFilename, 1 * 60 * 1000); | ||
} | ||
return undefined; | ||
} | ||
exports.askGetHierarchiesByCorrelation = askGetHierarchiesByCorrelation; |
@@ -1,12 +0,4 @@ | ||
import { QpqRuntimeType } from "quidproquo-core"; | ||
export interface LogMetadata { | ||
correlation: string; | ||
fromCorrelation?: string; | ||
moduleName: string; | ||
runtimeType: QpqRuntimeType; | ||
startedAt: string; | ||
generic: string; | ||
error?: string; | ||
executionTimeMs: number; | ||
import { StoryResultMetadata } from 'quidproquo-core'; | ||
export type LogMetadata = StoryResultMetadata & { | ||
ttl?: number; | ||
} | ||
}; |
"use strict"; | ||
// import { QpqRuntimeType } from "quidproquo-core"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.onCreate = void 0; | ||
const askUpdateDatabaseFromLogFiles_1 = require("../logic/askUpdateDatabaseFromLogFiles"); | ||
const askUpdateDatabaseFromLogFiles_1 = require("../../logic/askUpdateDatabaseFromLogFiles"); | ||
function* onCreate(event) { | ||
@@ -6,0 +6,0 @@ yield* (0, askUpdateDatabaseFromLogFiles_1.askUpdateDatabaseFromLogFiles)(event.driveName, event.filePaths); |
@@ -1,1 +0,2 @@ | ||
export * from "./entry"; | ||
export * from './entry'; | ||
export * from './logic'; |
@@ -18,1 +18,2 @@ "use strict"; | ||
__exportStar(require("./entry"), exports); | ||
__exportStar(require("./logic"), exports); |
@@ -16,2 +16,3 @@ "use strict"; | ||
[(0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'logController')]: require('../services/log/entry/controller/logController'), | ||
[(0, quidproquo_core_1.getServiceEntry)('log', 'webSocket', 'onWebsocketEvent')]: require('../services/log/entry/webSocket/onWebsocketEvent'), | ||
[(0, quidproquo_core_1.getServiceEntry)('log', 'controller', 'loginController')]: require('../services/log/entry/controller/loginController'), | ||
@@ -18,0 +19,0 @@ [(0, quidproquo_core_1.getServiceEntry)('log', 'storageDrive', 'onCreate')]: require('../services/log/entry/storageDrive/onCreate'), |
@@ -10,1 +10,2 @@ export * from './HTTPEvent'; | ||
export * from './CloudflareDnsDeployEvent'; | ||
export * from './webSocket'; |
@@ -26,1 +26,2 @@ "use strict"; | ||
__exportStar(require("./CloudflareDnsDeployEvent"), exports); | ||
__exportStar(require("./webSocket"), exports); |
@@ -7,1 +7,2 @@ export * from './headerUtils'; | ||
export * from './pathUtils'; | ||
export * from './jwtUtils'; |
@@ -23,1 +23,2 @@ "use strict"; | ||
__exportStar(require("./pathUtils"), exports); | ||
__exportStar(require("./jwtUtils"), exports); |
{ | ||
"name": "quidproquo-webserver", | ||
"version": "0.0.191", | ||
"version": "0.0.192", | ||
"description": "", | ||
@@ -29,8 +29,8 @@ "main": "./lib/commonjs/index.js", | ||
"@anthropic-ai/sdk": "^0.19.1", | ||
"quidproquo-core": "0.0.191" | ||
"quidproquo-core": "0.0.192" | ||
}, | ||
"devDependencies": { | ||
"quidproquo-tsconfig": "0.0.191", | ||
"quidproquo-tsconfig": "0.0.192", | ||
"typescript": "^4.9.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237736
316
4457
+ Addedquidproquo-core@0.0.192(transitive)
- Removedquidproquo-core@0.0.191(transitive)
Updatedquidproquo-core@0.0.192