* Introduce project_personas table with foreign keys to projects and agent_personas * Add project_skills table with foreign key to projects and agent_skills * Include override boolean field in agent_persona_skills and project_skills * Update schema and migration files to reflect new tables and fields * Enhance CORS handling to reflect request origin
This commit is contained in:
+21
-14
@@ -115,32 +115,39 @@ func GetHeadSpecHeaders() []string {
|
||||
|
||||
// SetCORSHeaders sets CORS headers on a response writer
|
||||
func SetCORSHeaders(w ResponseWriter, r Request, config CORSConfig) {
|
||||
// Set allowed origins
|
||||
// if len(config.AllowedOrigins) > 0 {
|
||||
// w.SetHeader("Access-Control-Allow-Origin", strings.Join(config.AllowedOrigins, ", "))
|
||||
// }
|
||||
|
||||
// Todo origin list parsing
|
||||
w.SetHeader("Access-Control-Allow-Origin", "*")
|
||||
// Reflect the request origin; fall back to wildcard only when no origin is present
|
||||
origin := r.Header("Origin")
|
||||
if origin == "" {
|
||||
origin = "*"
|
||||
} else {
|
||||
// Vary must be set so caches don't serve one origin's response to another
|
||||
httpW := w.UnderlyingResponseWriter()
|
||||
httpW.Header().Set("Vary", "Origin")
|
||||
}
|
||||
w.SetHeader("Access-Control-Allow-Origin", origin)
|
||||
|
||||
// Set allowed methods
|
||||
if len(config.AllowedMethods) > 0 {
|
||||
w.SetHeader("Access-Control-Allow-Methods", strings.Join(config.AllowedMethods, ", "))
|
||||
}
|
||||
|
||||
// Set allowed headers
|
||||
// if len(config.AllowedHeaders) > 0 {
|
||||
// w.SetHeader("Access-Control-Allow-Headers", strings.Join(config.AllowedHeaders, ", "))
|
||||
// }
|
||||
w.SetHeader("Access-Control-Allow-Headers", "*")
|
||||
// Reflect the preflight request headers when present; otherwise use the explicit config list
|
||||
requestedHeaders := r.Header("Access-Control-Request-Headers")
|
||||
if requestedHeaders != "" {
|
||||
w.SetHeader("Access-Control-Allow-Headers", requestedHeaders)
|
||||
} else if len(config.AllowedHeaders) > 0 {
|
||||
w.SetHeader("Access-Control-Allow-Headers", strings.Join(config.AllowedHeaders, ", "))
|
||||
}
|
||||
|
||||
// Set max age
|
||||
if config.MaxAge > 0 {
|
||||
w.SetHeader("Access-Control-Max-Age", fmt.Sprintf("%d", config.MaxAge))
|
||||
}
|
||||
|
||||
// Allow credentials
|
||||
w.SetHeader("Access-Control-Allow-Credentials", "true")
|
||||
// Allow credentials only when a specific origin is reflected (not wildcard)
|
||||
if origin != "*" {
|
||||
w.SetHeader("Access-Control-Allow-Credentials", "true")
|
||||
}
|
||||
|
||||
// Expose headers that clients can read
|
||||
exposeHeaders := config.AllowedHeaders
|
||||
|
||||
+4
@@ -50,6 +50,10 @@ type ServerInstanceConfig struct {
|
||||
// GZIP enables GZIP compression middleware
|
||||
GZIP bool `mapstructure:"gzip"`
|
||||
|
||||
// HTTP2 enables HTTP/2 with the Extended CONNECT protocol (RFC 8441) for WebSocket support.
|
||||
// Requires TLS; pair with SSLCert/SSLKey, SelfSignedSSL, or AutoTLS.
|
||||
HTTP2 bool `mapstructure:"http2"`
|
||||
|
||||
// TLS/HTTPS configuration options (mutually exclusive)
|
||||
// Option 1: Provide certificate and key files directly
|
||||
SSLCert string `mapstructure:"ssl_cert"`
|
||||
|
||||
+1
@@ -50,6 +50,7 @@ func New(opts ...DialectOption) *Dialect {
|
||||
feature.Output |
|
||||
feature.OffsetFetch |
|
||||
feature.FKDefaultOnAction |
|
||||
feature.Merge |
|
||||
feature.UpdateFromTable |
|
||||
feature.MSSavepoint
|
||||
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ package mssqldialect
|
||||
|
||||
// Version is the current release version.
|
||||
func Version() string {
|
||||
return "1.2.16"
|
||||
return "1.2.18"
|
||||
}
|
||||
|
||||
+3
-1
@@ -57,8 +57,10 @@ func New(opts ...DialectOption) *Dialect {
|
||||
feature.CompositeIn |
|
||||
feature.FKDefaultOnAction |
|
||||
feature.DeleteReturning |
|
||||
feature.Merge |
|
||||
feature.MergeReturning |
|
||||
feature.AlterColumnExists
|
||||
feature.AlterColumnExists |
|
||||
feature.CreateIndexIfNotExists
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(d)
|
||||
|
||||
+5
-5
@@ -38,17 +38,17 @@ func (in *Inspector) Inspect(ctx context.Context) (sqlschema.Database, error) {
|
||||
|
||||
exclude := in.ExcludeTables
|
||||
if len(exclude) == 0 {
|
||||
// Avoid getting NOT LIKE ALL (ARRAY[NULL]) if bun.In() is called with an empty slice.
|
||||
// Avoid getting NOT LIKE ALL (ARRAY[NULL]) if bun.List() is called with an empty slice.
|
||||
exclude = []string{""}
|
||||
}
|
||||
|
||||
var tables []*InformationSchemaTable
|
||||
if err := in.db.NewRaw(sqlInspectTables, in.SchemaName, bun.In(exclude)).Scan(ctx, &tables); err != nil {
|
||||
if err := in.db.NewRaw(sqlInspectTables, in.SchemaName, bun.List(exclude)).Scan(ctx, &tables); err != nil {
|
||||
return dbSchema, err
|
||||
}
|
||||
|
||||
var fks []*ForeignKey
|
||||
if err := in.db.NewRaw(sqlInspectForeignKeys, in.SchemaName, bun.In(exclude), bun.In(exclude)).Scan(ctx, &fks); err != nil {
|
||||
if err := in.db.NewRaw(sqlInspectForeignKeys, in.SchemaName, bun.List(exclude), bun.List(exclude)).Scan(ctx, &fks); err != nil {
|
||||
return dbSchema, err
|
||||
}
|
||||
dbSchema.ForeignKeys = make(map[sqlschema.ForeignKey]string, len(fks))
|
||||
@@ -165,7 +165,7 @@ type PrimaryKey struct {
|
||||
|
||||
const (
|
||||
// sqlInspectTables retrieves all user-defined tables in the selected schema.
|
||||
// Pass bun.In([]string{...}) to exclude tables from this inspection or bun.In([]string{''}) to include all results.
|
||||
// Pass bun.List([]string{...}) to exclude tables from this inspection or bun.List([]string{''}) to include all results.
|
||||
sqlInspectTables = `
|
||||
SELECT
|
||||
"t".table_schema,
|
||||
@@ -258,7 +258,7 @@ ORDER BY "table_schema", "table_name", "column_name"
|
||||
`
|
||||
|
||||
// sqlInspectForeignKeys get FK definitions for user-defined tables.
|
||||
// Pass bun.In([]string{...}) to exclude tables from this inspection or bun.In([]string{''}) to include all results.
|
||||
// Pass bun.List([]string{...}) to exclude tables from this inspection or bun.List([]string{''}) to include all results.
|
||||
sqlInspectForeignKeys = `
|
||||
WITH
|
||||
"schemas" AS (
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ package pgdialect
|
||||
|
||||
// Version is the current release version.
|
||||
func Version() string {
|
||||
return "1.2.16"
|
||||
return "1.2.18"
|
||||
}
|
||||
|
||||
+2
-1
@@ -42,7 +42,8 @@ func New(opts ...DialectOption) *Dialect {
|
||||
feature.AutoIncrement |
|
||||
feature.CompositeIn |
|
||||
feature.FKDefaultOnAction |
|
||||
feature.DeleteReturning
|
||||
feature.DeleteReturning |
|
||||
feature.CreateIndexIfNotExists
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(d)
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ package sqlitedialect
|
||||
|
||||
// Version is the current release version.
|
||||
func Version() string {
|
||||
return "1.2.16"
|
||||
return "1.2.18"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user