mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-11 08:48:15 +03:00
Last one out, get the lights.
This commit is contained in:
Generated
+2
-2
@@ -3960,7 +3960,7 @@
|
||||
},
|
||||
"node_modules/kamaitachi-common": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "git+ssh://git@github.com/zkldi/Kamaitachi-common.git#5348ee725a8c30ed18fd73673d20640068f37422",
|
||||
"resolved": "git+ssh://git@github.com/zkldi/Kamaitachi-common.git#6a576ae6ff465d0a2c5d2a6657ac642611e0f331",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"monk": "^7.3.3"
|
||||
@@ -12027,7 +12027,7 @@
|
||||
}
|
||||
},
|
||||
"kamaitachi-common": {
|
||||
"version": "git+ssh://git@github.com/zkldi/Kamaitachi-common.git#5348ee725a8c30ed18fd73673d20640068f37422",
|
||||
"version": "git+ssh://git@github.com/zkldi/Kamaitachi-common.git#6a576ae6ff465d0a2c5d2a6657ac642611e0f331",
|
||||
"from": "kamaitachi-common@git+https://github.com/zkldi/Kamaitachi-common.git",
|
||||
"requires": {
|
||||
"monk": "^7.3.3"
|
||||
|
||||
+11
-5
@@ -1,6 +1,8 @@
|
||||
import winston, { format, transports } from "winston";
|
||||
import winston, { format, Logger, transports } from "winston";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { PublicUserDocument } from "kamaitachi-common";
|
||||
import { FormatUserDoc } from "./core/user-core";
|
||||
|
||||
const level = process.env.LOG_LEVEL ?? "info";
|
||||
|
||||
@@ -8,10 +10,10 @@ const IN_PROD = process.env.NODE_ENV === "production";
|
||||
const IN_TESTING = process.env.NODE_ENV === "test";
|
||||
|
||||
const ktblackPrintf = format.printf(
|
||||
({ level, message, context, timestamp, ...meta }) =>
|
||||
`${timestamp} [${context ?? "ktblack-root"}] ${level}: ${message}${
|
||||
meta.length ? `, ${JSON.stringify(meta)}` : ""
|
||||
}`
|
||||
({ level, message, context = "ktblack-root", timestamp, ...meta }) =>
|
||||
`${timestamp} [${
|
||||
Array.isArray(context) ? context.join(" | ") : context
|
||||
}] ${level}: ${message}${meta.length ? `, ${JSON.stringify(meta)}` : ""}`
|
||||
);
|
||||
|
||||
const defaultFormatRoute = format.combine(
|
||||
@@ -70,4 +72,8 @@ function createLogCtx(context: string) {
|
||||
return logger.child({ context });
|
||||
}
|
||||
|
||||
export function createScoreLogger(user: PublicUserDocument, importID: string) {
|
||||
return logger.child({ context: ["Score Import", FormatUserDoc(user)], importID });
|
||||
}
|
||||
|
||||
export default createLogCtx;
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
import { ImportDocument, PublicUserDocument } from "kamaitachi-common";
|
||||
import createLogCtx from "../../logger";
|
||||
import {
|
||||
IDStrings,
|
||||
ImportDocument,
|
||||
ImportTypes,
|
||||
KTBlackImportDocument,
|
||||
PublicUserDocument,
|
||||
} from "kamaitachi-common";
|
||||
import createLogCtx, { createScoreLogger } from "../../logger";
|
||||
import { ConverterFunction } from "../../types";
|
||||
import { InsertQueue } from "./core/insert-score";
|
||||
import { ProcessIterableData } from "./processing/score-processor";
|
||||
|
||||
const logger = createLogCtx("score-import-main.ts");
|
||||
import crypto from "crypto";
|
||||
|
||||
export default async function ScoreImportMain<D, C>(
|
||||
user: PublicUserDocument,
|
||||
importType: ImportTypes,
|
||||
idStrings: IDStrings[],
|
||||
iterableData: Iterable<D> | AsyncIterable<D>,
|
||||
ConverterFunction: ConverterFunction<D, C>,
|
||||
context: C
|
||||
) {
|
||||
const importID = crypto.randomBytes(20).toString("hex");
|
||||
|
||||
const logger = createScoreLogger(user, importID);
|
||||
|
||||
// @todo: scope logger properly
|
||||
logger.verbose("Received import request.");
|
||||
|
||||
@@ -27,7 +38,8 @@ export default async function ScoreImportMain<D, C>(
|
||||
// @todo
|
||||
|
||||
// Create import document
|
||||
const ImportDocument: = {
|
||||
|
||||
}
|
||||
const ImportDocument: KTBlackImportDocument = {
|
||||
importType,
|
||||
idStrings: idStrings,
|
||||
};
|
||||
}
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ import {
|
||||
ScoreDocument,
|
||||
SongDocument,
|
||||
} from "kamaitachi-common";
|
||||
import { Logger } from "winston";
|
||||
import { ConverterFailure } from "./score-import/framework/core/converter-errors";
|
||||
import { Converters } from "./score-import/import-types/import-types";
|
||||
|
||||
@@ -48,7 +49,7 @@ export type ConverterFnReturn = ConverterFailure | ConverterFnSuccessReturn | nu
|
||||
export type ConverterFunctionReturns = ConverterFnReturn | ConverterFnReturn[];
|
||||
|
||||
export interface ConverterFunction<D, C> {
|
||||
(data: D, processContext: C): Promise<ConverterFunctionReturns>;
|
||||
(data: D, processContext: C, logger: Logger): Promise<ConverterFunctionReturns>;
|
||||
}
|
||||
|
||||
export interface ParserFunctionReturnsSync<D, C> {
|
||||
|
||||
Reference in New Issue
Block a user