mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-14 01:59:05 +03:00
update parser names
This commit is contained in:
Generated
+3
-3
@@ -60,7 +60,7 @@ dependencies:
|
||||
express-async-errors: 3.1.1_express@4.17.1
|
||||
express-session: 1.17.1
|
||||
fast-json-stable-hash: 1.0.2
|
||||
kamaitachi-common: github.com/zkldi/Kamaitachi-common/3ee7ec47e9f5e76a956f09af4fe851d159e31b25
|
||||
kamaitachi-common: github.com/zkldi/Kamaitachi-common/ccdc405f9fa6c080d87080106a229f0f403ad8e1
|
||||
mongodb: 3.6.6
|
||||
monk: 7.3.4
|
||||
multer: 1.4.2
|
||||
@@ -4637,8 +4637,8 @@ packages:
|
||||
'@types/yoga-layout': 1.9.2
|
||||
dev: true
|
||||
|
||||
github.com/zkldi/Kamaitachi-common/3ee7ec47e9f5e76a956f09af4fe851d159e31b25:
|
||||
resolution: {tarball: https://codeload.github.com/zkldi/Kamaitachi-common/tar.gz/3ee7ec47e9f5e76a956f09af4fe851d159e31b25}
|
||||
github.com/zkldi/Kamaitachi-common/ccdc405f9fa6c080d87080106a229f0f403ad8e1:
|
||||
resolution: {tarball: https://codeload.github.com/zkldi/Kamaitachi-common/tar.gz/ccdc405f9fa6c080d87080106a229f0f403ad8e1}
|
||||
name: kamaitachi-common
|
||||
version: 0.1.0
|
||||
dependencies:
|
||||
|
||||
@@ -117,9 +117,9 @@ export function ResolveFileUploadData(
|
||||
logger: KtLogger
|
||||
) {
|
||||
switch (importType) {
|
||||
case "file/csv:eamusement-iidx":
|
||||
case "file/eamusement-iidx-csv":
|
||||
return ParseEamusementCSV(fileData, body, logger);
|
||||
case "file/json:batch-manual":
|
||||
case "file/batch-manual":
|
||||
return ParseBatchManual(fileData, body, logger);
|
||||
default:
|
||||
logger.error(
|
||||
|
||||
@@ -29,7 +29,7 @@ router.post("/import", RequireLoggedIn, async (req, res) => {
|
||||
let responseData = await ExpressWrappedScoreImportMain(
|
||||
userDoc,
|
||||
true,
|
||||
"ir/json:direct-manual",
|
||||
"ir/direct-manual",
|
||||
(logger) => ParseDirectManual(req.body, logger)
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
This is temporary documentation for the import mechanisms in this folder.
|
||||
|
||||
# ImportType
|
||||
|
||||
An import type is a string in the following form:
|
||||
|
||||
(mode)/(name).
|
||||
|
||||
## ImportType Modes
|
||||
|
||||
- `file`: A file is uploaded to the server, and data is drew from a buffer.
|
||||
- `ir`: The data is sent to us in a HTTP Request Body.
|
||||
- `api`: We request the data on the users behalf from another service.
|
||||
|
||||
## ImportType Names
|
||||
|
||||
- `file/eamusement-iidx-csv`: An IIDX e-amusement CSV file.
|
||||
- `file/batch-manual`: A JSON file that follows our BATCH-MANUAL specification.
|
||||
|
||||
- `ir/direct-manual`: A request body containing JSON in BATCH-MANUAL form.
|
||||
|
||||
# Parsers
|
||||
|
||||
Parser functions convert the input data into an Iterable. This iterable may
|
||||
take any form, such as an Array or a Generator which yields paginated API returns.
|
||||
|
||||
They also return some information about the import, such as the game and
|
||||
playtypes involved. It will also return a Converter Function.
|
||||
|
||||
The iterable itself can contain any style of data. In general, one element
|
||||
of the iterable will likely correlate with one score. However, in some
|
||||
scenarios, one element of the iterable may contain multiple scores, such as
|
||||
iterating over the rows of an IIDX E-amusement CSV, where one row contains
|
||||
up to 5 separate scores.
|
||||
|
||||
# Converters
|
||||
|
||||
Converter functions are applied upon every member of the iterable. These
|
||||
convert a member of the iterable into a Dry Score, which is a partial
|
||||
Kamaitachi Score.
|
||||
|
||||
Converter functions may return the Dry Score, or any of the 'Score Failures' -
|
||||
A specific set of fail states for a score import, such as the score being
|
||||
invalid or the appropriate song/chart data for it not existing.
|
||||
|
||||
Converter functions may also return an array of the previous results, in the
|
||||
case that a single element of the iterable corresponded to multiple scores.
|
||||
|
||||
# Common
|
||||
|
||||
This is for common code - `ir/direct-manual` and `file/batch-manual` use very
|
||||
similar code paths, so code here is pulled out into a common folder.
|
||||
@@ -34,7 +34,7 @@ const ktdWrap = (msg: string, game: Game = "iidx", version = null): any => ({
|
||||
|
||||
const logger = CreateLogCtx("converter.test.ts");
|
||||
|
||||
const importType = "file/json:batch-manual" as const;
|
||||
const importType = "file/batch-manual" as const;
|
||||
|
||||
t.test("#ResolveMatchTypeToKTData", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -24,7 +24,7 @@ function ParseBatchManual(
|
||||
);
|
||||
}
|
||||
|
||||
return ParseBatchManualFromObject(jsonData, "file/json:batch-manual", logger);
|
||||
return ParseBatchManualFromObject(jsonData, "file/batch-manual", logger);
|
||||
}
|
||||
|
||||
export default ParseBatchManual;
|
||||
|
||||
@@ -58,7 +58,7 @@ export async function EamScoreConverter(
|
||||
if (!ktchiChart) {
|
||||
throw new KTDataNotFoundFailure(
|
||||
`Could not find chart for ${HUMANISED_CHART_TITLE}`,
|
||||
"file/csv:eamusement-iidx",
|
||||
"file/eamusement-iidx-csv",
|
||||
data,
|
||||
context
|
||||
);
|
||||
@@ -127,7 +127,7 @@ export async function EamScoreConverter(
|
||||
service: context.serviceOrigin,
|
||||
comment: null,
|
||||
game: "iidx",
|
||||
importType: "file/csv:eamusement-iidx",
|
||||
importType: "file/eamusement-iidx-csv",
|
||||
scoreData: {
|
||||
score: exscore,
|
||||
lamp,
|
||||
@@ -236,7 +236,7 @@ const ConverterFn: ConverterFunction<IIDXEamusementCSVData, IIDXEamusementCSVCon
|
||||
if (!ktchiSong) {
|
||||
return new KTDataNotFoundFailure(
|
||||
`Could not find song for ${data.title}.`,
|
||||
"file/csv:eamusement-iidx",
|
||||
importType,
|
||||
data,
|
||||
context
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ function ParseDirectManual(
|
||||
body: Record<string, unknown>,
|
||||
logger: KtLogger
|
||||
): ParserFunctionReturnsSync<BatchManualScore, BatchManualContext> {
|
||||
return ParseBatchManualFromObject(body, "ir/json:direct-manual", logger);
|
||||
return ParseBatchManualFromObject(body, "ir/direct-manual", logger);
|
||||
}
|
||||
|
||||
export default ParseDirectManual;
|
||||
|
||||
+6
-6
@@ -122,13 +122,13 @@ export interface TextDocument extends MongoDBDocument {
|
||||
}
|
||||
|
||||
export interface ImportTypeDataMap {
|
||||
"file/csv:eamusement-iidx": IIDXEamusementCSVData;
|
||||
"file/json:batch-manual": BatchManualScore;
|
||||
"ir/json:direct-manual": BatchManualScore;
|
||||
"file/eamusement-iidx-csv": IIDXEamusementCSVData;
|
||||
"file/batch-manual": BatchManualScore;
|
||||
"ir/direct-manual": BatchManualScore;
|
||||
}
|
||||
|
||||
export interface ImportTypeContextMap {
|
||||
"file/csv:eamusement-iidx": IIDXEamusementCSVContext;
|
||||
"file/json:batch-manual": BatchManualContext;
|
||||
"ir/json:direct-manual": BatchManualContext;
|
||||
"file/eamusement-iidx-csv": IIDXEamusementCSVContext;
|
||||
"file/batch-manual": BatchManualContext;
|
||||
"ir/direct-manual": BatchManualContext;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user