asset workspace progress
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record AssetReference(String value) {
|
||||
private static final String ASSET_ID_PREFIX = "asset:id:";
|
||||
private static final String ASSET_ROOT_PREFIX = "asset:root:";
|
||||
|
||||
public AssetReference {
|
||||
value = Objects.requireNonNull(value, "value").trim();
|
||||
if (value.isBlank()) {
|
||||
throw new IllegalArgumentException("value must not be blank");
|
||||
}
|
||||
}
|
||||
|
||||
public static AssetReference of(String value) {
|
||||
return new AssetReference(value);
|
||||
}
|
||||
|
||||
public static AssetReference forAssetId(int assetId) {
|
||||
if (assetId <= 0) {
|
||||
throw new IllegalArgumentException("assetId must be positive");
|
||||
}
|
||||
return new AssetReference(ASSET_ID_PREFIX + assetId);
|
||||
}
|
||||
|
||||
public static AssetReference forRelativeAssetRoot(String relativeAssetRoot) {
|
||||
final String normalized = Objects.requireNonNull(relativeAssetRoot, "relativeAssetRoot").trim();
|
||||
if (normalized.isBlank()) {
|
||||
throw new IllegalArgumentException("relativeAssetRoot must not be blank");
|
||||
}
|
||||
return new AssetReference(ASSET_ROOT_PREFIX + normalized);
|
||||
}
|
||||
|
||||
public boolean isAssetIdReference() {
|
||||
return value.startsWith(ASSET_ID_PREFIX);
|
||||
}
|
||||
|
||||
public boolean isAssetRootReference() {
|
||||
return value.startsWith(ASSET_ROOT_PREFIX);
|
||||
}
|
||||
|
||||
public String rawValue() {
|
||||
if (isAssetIdReference()) {
|
||||
return value.substring(ASSET_ID_PREFIX.length());
|
||||
}
|
||||
if (isAssetRootReference()) {
|
||||
return value.substring(ASSET_ROOT_PREFIX.length());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,9 +1,8 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.PackerProjectContext;
|
||||
import p.packer.assets.AssetFamilyCatalog;
|
||||
import p.packer.assets.OutputCodecCatalog;
|
||||
import p.packer.assets.OutputFormatCatalog;
|
||||
import p.packer.messages.assets.AssetFamilyCatalog;
|
||||
import p.packer.messages.assets.OutputCodecCatalog;
|
||||
import p.packer.messages.assets.OutputFormatCatalog;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
-3
@@ -1,8 +1,5 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.PackerOperationStatus;
|
||||
import p.packer.assets.AssetReference;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public record CreateAssetResult(
|
||||
|
||||
-3
@@ -1,8 +1,5 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.PackerProjectContext;
|
||||
import p.packer.assets.AssetReference;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record GetAssetDetailsRequest(
|
||||
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.PackerOperationStatus;
|
||||
import p.packer.assets.PackerAssetDetailsDTO;
|
||||
import p.packer.diagnostics.PackerDiagnosticDTO;
|
||||
import p.packer.dtos.PackerAssetDetailsDTO;
|
||||
import p.packer.dtos.PackerDiagnosticDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.PackerProjectContext;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record InitWorkspaceRequest(
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.PackerOperationStatus;
|
||||
import p.packer.diagnostics.PackerDiagnosticDTO;
|
||||
import p.packer.dtos.PackerDiagnosticDTO;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.PackerProjectContext;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record ListAssetsRequest(
|
||||
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.PackerOperationStatus;
|
||||
import p.packer.assets.PackerAssetSummaryDTO;
|
||||
import p.packer.diagnostics.PackerDiagnosticDTO;
|
||||
import p.packer.dtos.PackerAssetSummaryDTO;
|
||||
import p.packer.dtos.PackerDiagnosticDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package p.packer.messages;
|
||||
|
||||
public enum PackerOperationStatus {
|
||||
SUCCESS,
|
||||
PARTIAL,
|
||||
FAILED
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerProjectContext(
|
||||
String projectId,
|
||||
Path rootPath) {
|
||||
|
||||
public PackerProjectContext {
|
||||
projectId = Objects.requireNonNull(projectId, "projectId").trim();
|
||||
rootPath = Objects.requireNonNull(rootPath, "rootPath").toAbsolutePath().normalize();
|
||||
if (projectId.isBlank()) {
|
||||
throw new IllegalArgumentException("projectId must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum AssetFamilyCatalog {
|
||||
IMAGE_BANK("image_bank"),
|
||||
PALETTE_BANK("palette_bank"),
|
||||
SOUND_BANK("sound_bank"),
|
||||
UNKNOWN("unknown");
|
||||
|
||||
private final String manifestType;
|
||||
|
||||
AssetFamilyCatalog(String manifestType) {
|
||||
this.manifestType = manifestType;
|
||||
}
|
||||
|
||||
public String manifestType() {
|
||||
return manifestType;
|
||||
}
|
||||
|
||||
public boolean matchesQuery(String normalizedQuery) {
|
||||
return manifestType.contains(normalizedQuery);
|
||||
}
|
||||
|
||||
public static AssetFamilyCatalog fromManifestType(String manifestType) {
|
||||
if (manifestType == null) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
final String normalized = manifestType.trim().toLowerCase(Locale.ROOT);
|
||||
for (AssetFamilyCatalog candidate : values()) {
|
||||
if (candidate == UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
if (candidate.manifestType.equals(normalized)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum OutputCodecCatalog {
|
||||
NONE("NONE", "None"),
|
||||
UNKNOWN("UNKNOWN", "Unknown");
|
||||
|
||||
private final String manifestValue;
|
||||
private final String displayName;
|
||||
|
||||
OutputCodecCatalog(String manifestValue, String displayName) {
|
||||
this.manifestValue = manifestValue;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String manifestValue() {
|
||||
return manifestValue;
|
||||
}
|
||||
|
||||
public String displayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public static OutputCodecCatalog fromManifestValue(String manifestValue) {
|
||||
if (manifestValue == null) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
final String normalized = manifestValue.trim().toUpperCase(Locale.ROOT);
|
||||
for (OutputCodecCatalog candidate : values()) {
|
||||
if (candidate.manifestValue.equals(normalized)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public enum OutputFormatCatalog {
|
||||
TILES_INDEXED_V1(AssetFamilyCatalog.IMAGE_BANK, "TILES/indexed_v1", "TILES/indexed_v1"),
|
||||
PALETTE_INDEXED_V1(AssetFamilyCatalog.PALETTE_BANK, "PALETTE/indexed_v1", "PALETTE/indexed_v1"),
|
||||
SOUND_BANK_V1(AssetFamilyCatalog.SOUND_BANK, "SOUND/bank_v1", "SOUND/bank_v1"),
|
||||
AUDIO_PCM_V1(AssetFamilyCatalog.SOUND_BANK, "AUDIO/pcm_v1", "AUDIO/pcm_v1"),
|
||||
UNKNOWN(AssetFamilyCatalog.UNKNOWN, "unknown", "Unknown");
|
||||
|
||||
private final AssetFamilyCatalog assetFamily;
|
||||
private final String manifestValue;
|
||||
private final String displayName;
|
||||
|
||||
OutputFormatCatalog(AssetFamilyCatalog assetFamily, String manifestValue, String displayName) {
|
||||
this.assetFamily = assetFamily;
|
||||
this.manifestValue = manifestValue;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public AssetFamilyCatalog assetFamily() {
|
||||
return assetFamily;
|
||||
}
|
||||
|
||||
public String manifestValue() {
|
||||
return manifestValue;
|
||||
}
|
||||
|
||||
public String displayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public List<OutputCodecCatalog> availableCodecs() {
|
||||
return this == UNKNOWN ? List.of() : List.of(OutputCodecCatalog.NONE);
|
||||
}
|
||||
|
||||
public boolean supports(OutputCodecCatalog codec) {
|
||||
return availableCodecs().contains(codec);
|
||||
}
|
||||
|
||||
public static List<OutputFormatCatalog> supportedFor(AssetFamilyCatalog assetFamily) {
|
||||
if (assetFamily == null || assetFamily == AssetFamilyCatalog.UNKNOWN) {
|
||||
return List.of();
|
||||
}
|
||||
return java.util.Arrays.stream(values())
|
||||
.filter(candidate -> candidate != UNKNOWN)
|
||||
.filter(candidate -> candidate.assetFamily == assetFamily)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static OutputFormatCatalog fromManifestValue(String manifestValue) {
|
||||
if (manifestValue == null) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
final String normalized = manifestValue.trim().toLowerCase(Locale.ROOT);
|
||||
for (OutputFormatCatalog candidate : values()) {
|
||||
if (candidate == UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
if (candidate.manifestValue.toLowerCase(Locale.ROOT).equals(normalized)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
public enum PackerAssetState {
|
||||
REGISTERED,
|
||||
UNREGISTERED
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
public enum PackerBuildParticipation {
|
||||
INCLUDED,
|
||||
EXCLUDED
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
public enum PackerCodecConfigurationFieldType {
|
||||
TEXT,
|
||||
BOOLEAN,
|
||||
INTEGER,
|
||||
ENUM
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package p.packer.messages.diagnostics;
|
||||
|
||||
public enum PackerDiagnosticCategory {
|
||||
STRUCTURAL,
|
||||
HYGIENE,
|
||||
VERSIONING,
|
||||
MIGRATION,
|
||||
BUILD
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package p.packer.messages.diagnostics;
|
||||
|
||||
public enum PackerDiagnosticSeverity {
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR
|
||||
}
|
||||
Reference in New Issue
Block a user