Add option in API to normalize file extension

This commit is contained in:
Jordan Eldredge 2023-03-04 11:03:07 -08:00
parent a4b8d52f92
commit 2f032ff385
4 changed files with 38 additions and 6 deletions

View file

@ -1,6 +1,7 @@
import CommonSkinResolver from "./CommonSkinResolver";
import { NodeResolver, toId } from "./NodeResolver";
import ReviewResolver from "./ReviewResolver";
import path from "path";
export default class ClassicSkinResolver
extends CommonSkinResolver
@ -10,6 +11,13 @@ export default class ClassicSkinResolver
async id() {
return toId(this.__typename, this.md5());
}
async filename(normalize_extension = false) {
const filename = await this._model.getFileName();
if (normalize_extension) {
return path.parse(filename).name + ".wsz";
}
return filename;
}
museum_url() {
return this._model.getMuseumUrl();
}

View file

@ -12,9 +12,7 @@ export default class CommonSkinResolver {
md5() {
return this._model.getMd5();
}
filename() {
return this._model.getFileName();
}
download_url() {
return this._model.getSkinUrl();
}

View file

@ -1,6 +1,7 @@
import SkinModel from "../../../data/SkinModel";
import CommonSkinResolver from "./CommonSkinResolver";
import { NodeResolver, toId } from "./NodeResolver";
import path from "path";
export default class ModernSkinResolver
extends CommonSkinResolver
@ -11,4 +12,11 @@ export default class ModernSkinResolver
async id() {
return toId(this.__typename, this.md5());
}
async filename(normalize_extension = false) {
const filename = await this._model.getFileName();
if (normalize_extension) {
return path.parse(filename).name + ".wal";
}
return filename;
}
}

View file

@ -32,7 +32,13 @@ interface Skin {
Filename of skin when uploaded to the Museum. Note: In some cases a skin
has been uploaded under multiple names. Here we just pick one.
"""
filename: String
filename(
"""
If true, the the correct file extension (.wsz or .wal) will be .
Otherwise, the original user-uploaded file extension will be used.
"""
normalize_extension: Boolean = false
): String
"""
Has the skin been tweeted?
@ -97,7 +103,13 @@ type ModernSkin implements Skin & Node {
Filename of skin when uploaded to the Museum. Note: In some cases a skin
has been uploaded under multiple names. Here we just pick one.
"""
filename: String
filename(
"""
If true, the the correct file extension (.wsz or .wal) will be .
Otherwise, the original user-uploaded file extension will be used.
"""
normalize_extension: Boolean = false
): String
"""
Has the skin been tweeted?
@ -174,7 +186,13 @@ type ClassicSkin implements Skin & Node {
Filename of skin when uploaded to the Museum. Note: In some cases a skin
has been uploaded under multiple names. Here we just pick one.
"""
filename: String
filename(
"""
If true, the the correct file extension (.wsz or .wal) will be .
Otherwise, the original user-uploaded file extension will be used.
"""
normalize_extension: Boolean = false
): String
"""
Text of the readme file extracted from the skin