first commit

This commit is contained in:
Nilton Constantino
2026-04-22 14:55:58 +01:00
commit d48172539a
149 changed files with 4604 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
plugins {
id("java-library-conventions")
}
dependencies {
api(Dependencies.jacksonDatabind)
}
@@ -0,0 +1,11 @@
package net.bquarkz.ai.gateway.configuration;
import java.time.format.DateTimeFormatter;
public final class DateTimeFormatters {
public static final DateTimeFormatter ISO_DATETIME = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
public static final DateTimeFormatter ISO_DATE = DateTimeFormatter.ISO_LOCAL_DATE;
public static final String ISO_DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ssXXX";
private DateTimeFormatters() {}
}
@@ -0,0 +1,9 @@
package net.bquarkz.ai.gateway.configuration;
public final class Profiles {
public static final String LOCAL = "local";
public static final String STAGING = "staging";
public static final String PRODUCTION = "production";
private Profiles() {}
}
@@ -0,0 +1,12 @@
package net.bquarkz.ai.gateway.core;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@Data
@SuperBuilder
@NoArgsConstructor
public abstract class BaseModel<ID> {
private ID id;
}
@@ -0,0 +1,12 @@
package net.bquarkz.ai.gateway.core;
import lombok.Value;
@Value
public class Identifier<T> {
T value;
public static <T> Identifier<T> of(T value) {
return new Identifier<>(value);
}
}
@@ -0,0 +1,17 @@
package net.bquarkz.ai.gateway.core.security;
import lombok.Value;
@Value
public class AccessGrant {
boolean granted;
String reason;
public static AccessGrant allowed() {
return new AccessGrant(true, null);
}
public static AccessGrant denied(String reason) {
return new AccessGrant(false, reason);
}
}
@@ -0,0 +1,9 @@
package net.bquarkz.ai.gateway.core.security;
import java.util.Set;
public interface Session {
String getAgentId();
Set<String> getScopes();
String getEnvironment();
}
@@ -0,0 +1,6 @@
package net.bquarkz.ai.gateway.exceptions;
public class GatewayException extends RuntimeException {
public GatewayException(String message) { super(message); }
public GatewayException(String message, Throwable cause) { super(message, cause); }
}
@@ -0,0 +1,13 @@
package net.bquarkz.ai.gateway.exceptions;
import lombok.Getter;
@Getter
public class PolicyDeniedException extends GatewayException {
private final String matchedRule;
public PolicyDeniedException(String reason, String matchedRule) {
super(reason);
this.matchedRule = matchedRule;
}
}
@@ -0,0 +1,7 @@
package net.bquarkz.ai.gateway.exceptions;
public class ToolNotFoundException extends GatewayException {
public ToolNotFoundException(String toolName) {
super("Tool not found: " + toolName);
}
}
@@ -0,0 +1,5 @@
package net.bquarkz.ai.gateway.exceptions;
public class UnauthorizedException extends GatewayException {
public UnauthorizedException(String reason) { super(reason); }
}
@@ -0,0 +1,5 @@
package net.bquarkz.ai.gateway.exceptions;
public class ValidationException extends GatewayException {
public ValidationException(String reason) { super(reason); }
}
@@ -0,0 +1,22 @@
package net.bquarkz.ai.gateway.messages;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Value;
@Value
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResponsePayload<T> {
T data;
String error;
String requestId;
public static <T> ResponsePayload<T> success(T data, String requestId) {
return ResponsePayload.<T>builder().data(data).requestId(requestId).build();
}
public static <T> ResponsePayload<T> error(String error, String requestId) {
return ResponsePayload.<T>builder().error(error).requestId(requestId).build();
}
}
@@ -0,0 +1,12 @@
package net.bquarkz.ai.gateway.messages;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@Data
@SuperBuilder
@NoArgsConstructor
public abstract class TransportMessageRequest {
private String requestId;
}