Skip to content

Commit f8fcc28

Browse files
committed
expose marshallers, move queryselector to xdatly
1 parent a782238 commit f8fcc28

File tree

18 files changed

+256
-128
lines changed

18 files changed

+256
-128
lines changed

cmd/datly/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pipeline:
99
set_sdk:
1010
action: sdk.set
1111
target: $target
12-
sdk: go:1.23
12+
sdk: go:1.25.1
1313
build:
1414
action: exec:run
1515
target: $target

e2e/local/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pipeline:
1414
set_sdk:
1515
action: sdk.set
1616
target: $target
17-
sdk: go:1.23
17+
sdk: go:1.25.1
1818

1919
buildValidator:
2020
action: exec:run

e2e/local/regression/regression.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pipeline:
55
set_sdk:
66
action: sdk.set
77
target: $target
8-
sdk: go:1.23
8+
sdk: go:1.25.1
99

1010
database:
1111
action: run

gateway/router/handler.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,8 @@ func (r *Handler) writeErrorResponse(ctx context.Context, w http.ResponseWriter,
261261
http.Error(w, err.Error(), http.StatusInternalServerError)
262262
return
263263
}
264-
if aComponent.Content.Marshaller.JSON.CanMarshal() {
265-
data, err = aComponent.Marshaller.JSON.Codec.Marshal(aResponse.State())
266-
} else {
267-
data, err = aComponent.Marshaller.JSON.JsonMarshaller.Marshal(aResponse.State())
268-
}
264+
mf := aComponent.MarshalFunc()
265+
data, err = mf(aResponse.State())
269266
if err != nil {
270267
w.Write(data)
271268
if execCtx != nil {
@@ -462,8 +459,10 @@ func (r *Handler) handleComponent(ctx context.Context, request *http.Request, aC
462459
options.Append(response.WithHeader("Content-Disposition", fmt.Sprintf(`attachment; filename="%s.xlsx"`, aComponent.Output.GetTitle())))
463460
}
464461
}
462+
// Use component-level marshaller with request-scoped options
465463
filters := aComponent.Exclusion(aSession.State())
466-
data, err := aComponent.Content.Marshal(format, aComponent.Output.Field(), output, filters)
464+
mf := aComponent.MarshalFunc(repository.WithRequest(request), repository.WithFormat(format), repository.WithFilters(filters))
465+
data, err := mf(output)
467466
if err != nil {
468467
return nil, response.NewError(500, fmt.Sprintf("failed to marshal response: %v", err), response.WithError(err))
469468
}
@@ -501,13 +500,9 @@ func (r *Handler) marshalComponentOutput(output interface{}, aComponent *reposit
501500
case []byte:
502501
return response.NewBuffered(response.WithBytes(actual)), nil
503502
default:
504-
var data []byte
505-
var err error
506-
if aComponent.Content.Marshaller.JSON.CanMarshal() {
507-
data, err = aComponent.Content.Marshaller.JSON.Codec.Marshal(output)
508-
} else {
509-
data, err = aComponent.Content.Marshaller.JSON.JsonMarshaller.Marshal(output)
510-
}
503+
// Default to JSON marshalling using component-level marshaller
504+
mf := aComponent.MarshalFunc()
505+
data, err := mf(output)
511506
if err != nil {
512507
return nil, response.NewError(http.StatusInternalServerError, err.Error(), response.WithError(err))
513508
}

gateway/runtime/apigw/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pipeline:
2525
set_sdk:
2626
action: sdk.set
2727
target: $target
28-
sdk: go:1.21
28+
sdk: go:1.25.1
2929

3030
build:
3131
package:

gateway/runtime/gcr/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pipeline:
1818
setSdk:
1919
action: sdk.set
2020
target: $target
21-
sdk: go:1.21
21+
sdk: go:1.25.1
2222

2323
deploy:
2424
buildBinary:

gateway/runtime/lambda/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pipeline:
2727
set_sdk:
2828
action: sdk.set
2929
target: $target
30-
sdk: go:1.21
30+
sdk: go:1.25.1
3131

3232
build:
3333
package:

go.mod

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ require (
4848
require (
4949
github.com/viant/aerospike v0.2.11-0.20241108195857-ed524b97800d
5050
github.com/viant/firebase v0.1.1
51-
github.com/viant/jsonrpc v0.7.5
52-
github.com/viant/mcp v0.5.2
51+
github.com/viant/jsonrpc v0.9.0
52+
github.com/viant/mcp v0.6.0
5353
github.com/viant/mcp-protocol v0.5.7
5454
github.com/viant/structology v0.6.1
5555
github.com/viant/tagly v0.2.2
56-
github.com/viant/xdatly v0.5.4-0.20250806192028-819cadf93282
56+
github.com/viant/xdatly v0.5.4-0.20251006174948-cb34263ae8aa
5757
github.com/viant/xdatly/extension v0.0.0-20231013204918-ecf3c2edf259
58-
github.com/viant/xdatly/handler v0.0.0-20250806192028-819cadf93282
58+
github.com/viant/xdatly/handler v0.0.0-20251006174948-cb34263ae8aa
5959
github.com/viant/xdatly/types/core v0.0.0-20250307183722-8c84fc717b52
6060
github.com/viant/xdatly/types/custom v0.0.0-20240801144911-4c2bfca4c23a
6161
github.com/viant/xlsy v0.3.1
@@ -105,6 +105,7 @@ require (
105105
github.com/go-errors/errors v1.5.1 // indirect
106106
github.com/go-logr/logr v1.4.1 // indirect
107107
github.com/go-logr/stdr v1.2.2 // indirect
108+
github.com/goccy/go-json v0.10.2 // indirect
108109
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
109110
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
110111
github.com/golang/protobuf v1.5.4 // indirect
@@ -127,6 +128,7 @@ require (
127128
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
128129
github.com/richardlehane/mscfb v1.0.4 // indirect
129130
github.com/richardlehane/msoleps v1.0.3 // indirect
131+
github.com/viant/gosh v0.2.1 // indirect
130132
github.com/viant/igo v0.2.0 // indirect
131133
github.com/viant/x v0.3.0 // indirect
132134
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca // indirect

go.sum

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,10 +1124,10 @@ github.com/viant/govalidator v0.3.1 h1:V7f/KgfzbP8fVDc+Kj+jyPvfXxMr2N1x7srOlDV6l
11241124
github.com/viant/govalidator v0.3.1/go.mod h1:D35Dwx0R8rR1knRxhlseoYvOkiqo24kpMg1/o977i9Y=
11251125
github.com/viant/igo v0.2.0 h1:ygWmTCinnGPaeV7omJLiyneOpzYZ5kiw7oYz7mUJZVQ=
11261126
github.com/viant/igo v0.2.0/go.mod h1:7V6AWsLhKWeGzXNTNH3AZiIEKa0m33DrQbdWtapsI74=
1127-
github.com/viant/jsonrpc v0.7.5 h1:QiLEVl5nP7j5i55jDQp4HUURKJLf+ENPafTlJT13u38=
1128-
github.com/viant/jsonrpc v0.7.5/go.mod h1:LW2l5/H4KkGCsx2ktPX59iUlycw85ZlBcRuK/WYWBX8=
1129-
github.com/viant/mcp v0.5.2 h1:m0Z7LdYOQOs7MhYg7Ql9nZlJDiedHfC86VNRzfKg3Gs=
1130-
github.com/viant/mcp v0.5.2/go.mod h1:ybylH9mD3/aVLrT8KQsakmsKxtfw7Kpo4A9hmTuetGw=
1127+
github.com/viant/jsonrpc v0.9.0 h1:vTZsApJxTd3Y50ygOBs8HKCJ24NrwgCa7lqG1oYXpdE=
1128+
github.com/viant/jsonrpc v0.9.0/go.mod h1:LW2l5/H4KkGCsx2ktPX59iUlycw85ZlBcRuK/WYWBX8=
1129+
github.com/viant/mcp v0.6.0 h1:+BCsLSW5pux07avEhS550hZno8Y5ZKKSfdLm6NHRU+8=
1130+
github.com/viant/mcp v0.6.0/go.mod h1:fb5wpE9kc/R32pNE4Pdo1DR4ZW6+0em3rsFuBHoqmp4=
11311131
github.com/viant/mcp-protocol v0.5.7 h1:3ifypMAy+oUjQEAsq+XwrAhE/B/3eIes4yXdhoRF9Eo=
11321132
github.com/viant/mcp-protocol v0.5.7/go.mod h1:EJPomVw6jnI+4Aa2ONYC3WTvApiF0YeQIiaaEpA54ec=
11331133
github.com/viant/parsly v0.3.3-0.20240717150634-e1afaedb691b h1:3q166tV28yFdbFV+tXXjH7ViKAmgAgGdoWzMtvhQv28=
@@ -1138,8 +1138,6 @@ github.com/viant/scy v0.24.0 h1:KAC3IUARkQxTNSuwBK2YhVBJMOOLN30YaLKHbbuSkMU=
11381138
github.com/viant/scy v0.24.0/go.mod h1:7uNRS67X45YN+JqTLCcMEhehffVjqrejULEDln9p0Ao=
11391139
github.com/viant/sqlparser v0.8.1 h1:nbcTecMtW7ROk5aNB5/BWUxnduepRPOkhVo9RWxI1Ns=
11401140
github.com/viant/sqlparser v0.8.1/go.mod h1:2QRGiGZYk2/pjhORGG1zLVQ9JO+bXFhqIVi31mkCRPg=
1141-
github.com/viant/sqlx v0.17.7 h1:drUv3N8mOboq917gnmcT9zC4G9vj4jU11bO/SsLpmc8=
1142-
github.com/viant/sqlx v0.17.7/go.mod h1:dizufL+nTNqDCpivUnE2HqtddTp2TdA6WFghGfZo11c=
11431141
github.com/viant/sqlx v0.17.8 h1:YxGTrXC2B1JmDz1qp8G+G9hGPk7XCRevWN1E4E+ZlCI=
11441142
github.com/viant/sqlx v0.17.8/go.mod h1:dizufL+nTNqDCpivUnE2HqtddTp2TdA6WFghGfZo11c=
11451143
github.com/viant/structology v0.6.1 h1:Forza+RF/1tmlQFk9ABNhu+IQ8vMAqbYM6FOsYtGh9E=
@@ -1156,12 +1154,12 @@ github.com/viant/velty v0.2.1-0.20230927172116-ba56497b5c85 h1:zKk+6hqUipkJXCPCH
11561154
github.com/viant/velty v0.2.1-0.20230927172116-ba56497b5c85/go.mod h1:Q/UXviI2Nli8WROEpYd/BELMCSvnulQeyNrbPmMiS/Y=
11571155
github.com/viant/x v0.3.0 h1:/3A0z/uySGxMo6ixH90VAcdjI00w5e3REC1zg5hzhJA=
11581156
github.com/viant/x v0.3.0/go.mod h1:54jP3qV+nnQdNDaWxEwGTAAzCu9sx9er9htiwTW/Mcw=
1159-
github.com/viant/xdatly v0.5.4-0.20250806192028-819cadf93282 h1:CqRQGsior7arN1lQA11oCoWdC/LZv1ObhCOGpdwvR3k=
1160-
github.com/viant/xdatly v0.5.4-0.20250806192028-819cadf93282/go.mod h1:lZKZHhVdCZ3U9TU6GUFxKoGN3dPtqt2HkDYzJPq5CEs=
1157+
github.com/viant/xdatly v0.5.4-0.20251006174948-cb34263ae8aa h1:o5o1CmraGb/LSpfrgmDoMdi9JJGjiopH8cmX98ukJS0=
1158+
github.com/viant/xdatly v0.5.4-0.20251006174948-cb34263ae8aa/go.mod h1:lZKZHhVdCZ3U9TU6GUFxKoGN3dPtqt2HkDYzJPq5CEs=
11611159
github.com/viant/xdatly/extension v0.0.0-20231013204918-ecf3c2edf259 h1:9Yry3PUBDzc4rWacOYvAq/TKrTV0agvMF0gwm2gaoHI=
11621160
github.com/viant/xdatly/extension v0.0.0-20231013204918-ecf3c2edf259/go.mod h1:fb8YgbVadk8X5ZLz49LWGzWmQlZd7Y/I5wE0ru44bIo=
1163-
github.com/viant/xdatly/handler v0.0.0-20250806192028-819cadf93282 h1:oNhkNyC6bRBifxWLyd7MTEFmCMwfg1LaAjKAmubrWCM=
1164-
github.com/viant/xdatly/handler v0.0.0-20250806192028-819cadf93282/go.mod h1:OeV4sVatklNs31nFnZtSp7lEvKJRoVJbH5opNRmRPg0=
1161+
github.com/viant/xdatly/handler v0.0.0-20251006174948-cb34263ae8aa h1:UzX1wB23RMENSKF5X0fQZR/cIy7wB7z2ODWCIm358IQ=
1162+
github.com/viant/xdatly/handler v0.0.0-20251006174948-cb34263ae8aa/go.mod h1:OeV4sVatklNs31nFnZtSp7lEvKJRoVJbH5opNRmRPg0=
11651163
github.com/viant/xdatly/types/core v0.0.0-20250307183722-8c84fc717b52 h1:G+e1MMDxQXUPPlAXVNlRqSLTLra7udGQZUu3hnr0Y8M=
11661164
github.com/viant/xdatly/types/core v0.0.0-20250307183722-8c84fc717b52/go.mod h1:LJN2m8xJjtYNCvyvNrVanJwvzj8+hYCuPswL8H4qRG0=
11671165
github.com/viant/xdatly/types/custom v0.0.0-20240801144911-4c2bfca4c23a h1:jecH7mH63gj1zJwD18SdvSHM9Ttr9FEOnhHkYfkCNkI=

internal/translator/rule.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type (
6767
IsGeneratation bool
6868
XMLUnmarshalType string `json:",omitempty"`
6969
JSONUnmarshalType string `json:",omitempty"`
70+
JSONMarshalType string `json:",omitempty"`
7071

7172
OutputParameter *inference.Parameter
7273
}
@@ -132,6 +133,7 @@ func (r *Rule) DSQLSetting() interface{} {
132133
DocURLs []string `json:",omitempty"`
133134
Internal bool `json:",omitempty"`
134135
JSONUnmarshalType string `json:",omitempty"`
136+
JSONMarshalType string `json:",omitempty"`
135137
Connector string `json:",omitempty"`
136138
contract.ModelContextProtocol
137139
contract.Meta
@@ -148,6 +150,7 @@ func (r *Rule) DSQLSetting() interface{} {
148150
DocURLs: r.DocURLs,
149151
Internal: r.Internal,
150152
JSONUnmarshalType: r.JSONUnmarshalType,
153+
JSONMarshalType: r.JSONMarshalType,
151154
Connector: r.Connector,
152155
ModelContextProtocol: r.ModelContextProtocol,
153156
Meta: r.Meta,
@@ -321,7 +324,9 @@ func (r *Rule) applyDefaults() {
321324
if r.XMLUnmarshalType != "" {
322325
r.Route.Content.Marshaller.XML.TypeName = r.XMLUnmarshalType
323326
}
324-
if r.JSONUnmarshalType != "" {
327+
if r.JSONMarshalType != "" {
328+
r.Route.Content.Marshaller.JSON.TypeName = r.JSONMarshalType
329+
} else if r.JSONUnmarshalType != "" {
325330
r.Route.Content.Marshaller.JSON.TypeName = r.JSONUnmarshalType
326331
}
327332
}

0 commit comments

Comments
 (0)