diff --git a/backend/online-boutique/services/checkout/go.mod b/backend/online-boutique/services/checkout/go.mod index f2b1ef2d..12a9ef32 100644 --- a/backend/online-boutique/services/checkout/go.mod +++ b/backend/online-boutique/services/checkout/go.mod @@ -5,7 +5,7 @@ go 1.21.6 replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. require ( - github.com/TBD54566975/ftl v0.99.0 + github.com/TBD54566975/ftl v0.107.0 github.com/TBD54566975/ftl/examples/online-boutique v0.0.0-00010101000000-000000000000 github.com/google/uuid v1.5.0 ) diff --git a/backend/online-boutique/services/checkout/go.sum b/backend/online-boutique/services/checkout/go.sum index fd3ee3fb..b9fff7c4 100644 --- a/backend/online-boutique/services/checkout/go.sum +++ b/backend/online-boutique/services/checkout/go.sum @@ -4,10 +4,10 @@ connectrpc.com/grpcreflect v1.2.0 h1:Q6og1S7HinmtbEuBvARLNwYmTbhEGRpHDhqrPNlmK+U connectrpc.com/grpcreflect v1.2.0/go.mod h1:nwSOKmE8nU5u/CidgHtPYk1PFI3U9ignz7iDMxOYkSY= connectrpc.com/otelconnect v0.7.0 h1:ZH55ZZtcJOTKWWLy3qmL4Pam4RzRWBJFOqTPyAqCXkY= connectrpc.com/otelconnect v0.7.0/go.mod h1:Bt2ivBymHZHqxvo4HkJ0EwHuUzQN6k2l0oH+mp/8nwc= -github.com/TBD54566975/ftl v0.99.0 h1:IBdJoPwajme+8EUwlLQPwT+aVgLWM4OibO3Dbamf80w= -github.com/TBD54566975/ftl v0.99.0/go.mod h1:KJrJ1KFFWdXFoZghKYBkHbrCkUaQYfcLhFs9jOZ4mcc= -github.com/alecthomas/assert/v2 v2.4.1 h1:mwPZod/d35nlaCppr6sFP0rbCL05WH9fIo7lvsf47zo= -github.com/alecthomas/assert/v2 v2.4.1/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= +github.com/TBD54566975/ftl v0.107.0 h1:zdeWEETDkcu+0onfgk/9IVsB5QPC++mv751fTVXePtA= +github.com/TBD54566975/ftl v0.107.0/go.mod h1:7yRFD+2zC5zstcXYcSJzAubRi6MecQZndMnEbd1zMwM= +github.com/alecthomas/assert/v2 v2.5.0 h1:OJKYg53BQx06/bMRBSPDCO49CbCDNiUQXwdoNrt6x5w= +github.com/alecthomas/assert/v2 v2.5.0/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= github.com/alecthomas/concurrency v0.0.2 h1:Q3kGPtLbleMbH9lHX5OBFvJygfyFw29bXZKBg+IEVuo= github.com/alecthomas/concurrency v0.0.2/go.mod h1:GmuQb/iHX7mbNtPlC/WDzEFxDMB0HYFer2Qda9QTs7w= github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6icjJvbsmV8= diff --git a/backend/online-boutique/services/recommendation/go.mod b/backend/online-boutique/services/recommendation/go.mod index 98cb2547..aa070375 100644 --- a/backend/online-boutique/services/recommendation/go.mod +++ b/backend/online-boutique/services/recommendation/go.mod @@ -4,7 +4,7 @@ go 1.21.6 replace github.com/TBD54566975/ftl/examples/online-boutique => ../.. -require github.com/TBD54566975/ftl v0.99.0 +require github.com/TBD54566975/ftl v0.107.0 require ( connectrpc.com/connect v1.14.0 // indirect diff --git a/backend/online-boutique/services/recommendation/go.sum b/backend/online-boutique/services/recommendation/go.sum index fd3ee3fb..b9fff7c4 100644 --- a/backend/online-boutique/services/recommendation/go.sum +++ b/backend/online-boutique/services/recommendation/go.sum @@ -4,10 +4,10 @@ connectrpc.com/grpcreflect v1.2.0 h1:Q6og1S7HinmtbEuBvARLNwYmTbhEGRpHDhqrPNlmK+U connectrpc.com/grpcreflect v1.2.0/go.mod h1:nwSOKmE8nU5u/CidgHtPYk1PFI3U9ignz7iDMxOYkSY= connectrpc.com/otelconnect v0.7.0 h1:ZH55ZZtcJOTKWWLy3qmL4Pam4RzRWBJFOqTPyAqCXkY= connectrpc.com/otelconnect v0.7.0/go.mod h1:Bt2ivBymHZHqxvo4HkJ0EwHuUzQN6k2l0oH+mp/8nwc= -github.com/TBD54566975/ftl v0.99.0 h1:IBdJoPwajme+8EUwlLQPwT+aVgLWM4OibO3Dbamf80w= -github.com/TBD54566975/ftl v0.99.0/go.mod h1:KJrJ1KFFWdXFoZghKYBkHbrCkUaQYfcLhFs9jOZ4mcc= -github.com/alecthomas/assert/v2 v2.4.1 h1:mwPZod/d35nlaCppr6sFP0rbCL05WH9fIo7lvsf47zo= -github.com/alecthomas/assert/v2 v2.4.1/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= +github.com/TBD54566975/ftl v0.107.0 h1:zdeWEETDkcu+0onfgk/9IVsB5QPC++mv751fTVXePtA= +github.com/TBD54566975/ftl v0.107.0/go.mod h1:7yRFD+2zC5zstcXYcSJzAubRi6MecQZndMnEbd1zMwM= +github.com/alecthomas/assert/v2 v2.5.0 h1:OJKYg53BQx06/bMRBSPDCO49CbCDNiUQXwdoNrt6x5w= +github.com/alecthomas/assert/v2 v2.5.0/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= github.com/alecthomas/concurrency v0.0.2 h1:Q3kGPtLbleMbH9lHX5OBFvJygfyFw29bXZKBg+IEVuo= github.com/alecthomas/concurrency v0.0.2/go.mod h1:GmuQb/iHX7mbNtPlC/WDzEFxDMB0HYFer2Qda9QTs7w= github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6icjJvbsmV8= diff --git a/frontend/mobile/lib/api/ad.dart b/frontend/mobile/lib/api/ad.dart index fb87f2f6..0d2c9bb6 100644 --- a/frontend/mobile/lib/api/ad.dart +++ b/frontend/mobile/lib/api/ad.dart @@ -6,7 +6,7 @@ import 'dart:typed_data'; import 'ftl_client.dart'; -class AdRequest { +class AdRequest{ List contextKeys; AdRequest({ required this.contextKeys, }); @@ -28,7 +28,7 @@ class AdRequest { factory AdRequest.fromJson(String source) => AdRequest.fromMap(json.decode(source)); } -class Ad { +class Ad{ String redirectURL; String text; @@ -53,7 +53,7 @@ class Ad { factory Ad.fromJson(String source) => Ad.fromMap(json.decode(source)); } -class AdResponse { +class AdResponse{ String name; List ads; diff --git a/frontend/mobile/lib/api/builtin.dart b/frontend/mobile/lib/api/builtin.dart index 48c6b301..0bbd7c13 100644 --- a/frontend/mobile/lib/api/builtin.dart +++ b/frontend/mobile/lib/api/builtin.dart @@ -6,13 +6,13 @@ import 'dart:typed_data'; import 'ftl_client.dart'; -class HttpRequest { +class HttpRequest{ String method; String path; Map pathParameters; Map> query; Map> headers; - Uint8List body; + Body body; HttpRequest({ required this.method, required this.path, required this.pathParameters, required this.query, required this.headers, required this.body, }); @@ -43,10 +43,10 @@ class HttpRequest { factory HttpRequest.fromJson(String source) => HttpRequest.fromMap(json.decode(source)); } -class HttpResponse { +class HttpResponse{ int status; Map> headers; - Uint8List body; + Body body; HttpResponse({ required this.status, required this.headers, required this.body, }); diff --git a/frontend/mobile/lib/api/cart.dart b/frontend/mobile/lib/api/cart.dart index 02f088c1..f35dcac1 100644 --- a/frontend/mobile/lib/api/cart.dart +++ b/frontend/mobile/lib/api/cart.dart @@ -6,7 +6,7 @@ import 'dart:typed_data'; import 'ftl_client.dart'; -class Item { +class Item{ String productID; int quantity; @@ -31,7 +31,7 @@ class Item { factory Item.fromJson(String source) => Item.fromMap(json.decode(source)); } -class AddItemRequest { +class AddItemRequest{ String userID; Item item; @@ -56,7 +56,7 @@ class AddItemRequest { factory AddItemRequest.fromJson(String source) => AddItemRequest.fromMap(json.decode(source)); } -class AddItemResponse { +class AddItemResponse{ AddItemResponse(); @@ -75,7 +75,7 @@ class AddItemResponse { factory AddItemResponse.fromJson(String source) => AddItemResponse.fromMap(json.decode(source)); } -class GetCartRequest { +class GetCartRequest{ String userID; GetCartRequest({ required this.userID, }); @@ -97,7 +97,7 @@ class GetCartRequest { factory GetCartRequest.fromJson(String source) => GetCartRequest.fromMap(json.decode(source)); } -class Cart { +class Cart{ String userID; List items; @@ -122,7 +122,7 @@ class Cart { factory Cart.fromJson(String source) => Cart.fromMap(json.decode(source)); } -class EmptyCartRequest { +class EmptyCartRequest{ String userID; EmptyCartRequest({ required this.userID, }); @@ -144,7 +144,7 @@ class EmptyCartRequest { factory EmptyCartRequest.fromJson(String source) => EmptyCartRequest.fromMap(json.decode(source)); } -class EmptyCartResponse { +class EmptyCartResponse{ EmptyCartResponse(); diff --git a/frontend/mobile/lib/api/checkout.dart b/frontend/mobile/lib/api/checkout.dart index 740894cc..6cdd5750 100644 --- a/frontend/mobile/lib/api/checkout.dart +++ b/frontend/mobile/lib/api/checkout.dart @@ -11,7 +11,7 @@ import 'productcatalog.dart' as productcatalog; import 'shipping.dart' as shipping; -class PlaceOrderRequest { +class PlaceOrderRequest{ String userID; String userCurrency; shipping.Address address; @@ -45,7 +45,7 @@ class PlaceOrderRequest { factory PlaceOrderRequest.fromJson(String source) => PlaceOrderRequest.fromMap(json.decode(source)); } -class OrderItem { +class OrderItem{ cart.Item item; currency.Money cost; @@ -70,7 +70,7 @@ class OrderItem { factory OrderItem.fromJson(String source) => OrderItem.fromMap(json.decode(source)); } -class Order { +class Order{ String id; String shippingTrackingID; currency.Money shippingCost; diff --git a/frontend/mobile/lib/api/currency.dart b/frontend/mobile/lib/api/currency.dart index ac7e0e5a..4393e386 100644 --- a/frontend/mobile/lib/api/currency.dart +++ b/frontend/mobile/lib/api/currency.dart @@ -6,7 +6,7 @@ import 'dart:typed_data'; import 'ftl_client.dart'; -class GetSupportedCurrenciesRequest { +class GetSupportedCurrenciesRequest{ GetSupportedCurrenciesRequest(); @@ -25,7 +25,7 @@ class GetSupportedCurrenciesRequest { factory GetSupportedCurrenciesRequest.fromJson(String source) => GetSupportedCurrenciesRequest.fromMap(json.decode(source)); } -class GetSupportedCurrenciesResponse { +class GetSupportedCurrenciesResponse{ List currencyCodes; GetSupportedCurrenciesResponse({ required this.currencyCodes, }); @@ -47,7 +47,7 @@ class GetSupportedCurrenciesResponse { factory GetSupportedCurrenciesResponse.fromJson(String source) => GetSupportedCurrenciesResponse.fromMap(json.decode(source)); } -class Money { +class Money{ String currencyCode; int units; int nanos; @@ -75,7 +75,7 @@ class Money { factory Money.fromJson(String source) => Money.fromMap(json.decode(source)); } -class ConvertRequest { +class ConvertRequest{ Money from; String toCode; diff --git a/frontend/mobile/lib/api/payment.dart b/frontend/mobile/lib/api/payment.dart index f6d0b795..efeb2ce4 100644 --- a/frontend/mobile/lib/api/payment.dart +++ b/frontend/mobile/lib/api/payment.dart @@ -7,7 +7,7 @@ import 'ftl_client.dart'; import 'currency.dart' as currency; -class CreditCardInfo { +class CreditCardInfo{ String number; int cVV; int expirationYear; @@ -38,7 +38,7 @@ class CreditCardInfo { factory CreditCardInfo.fromJson(String source) => CreditCardInfo.fromMap(json.decode(source)); } -class ChargeRequest { +class ChargeRequest{ currency.Money amount; CreditCardInfo creditCard; @@ -63,7 +63,7 @@ class ChargeRequest { factory ChargeRequest.fromJson(String source) => ChargeRequest.fromMap(json.decode(source)); } -class ChargeResponse { +class ChargeResponse{ String transactionID; ChargeResponse({ required this.transactionID, }); diff --git a/frontend/mobile/lib/api/productcatalog.dart b/frontend/mobile/lib/api/productcatalog.dart index f25aaae4..539d50ce 100644 --- a/frontend/mobile/lib/api/productcatalog.dart +++ b/frontend/mobile/lib/api/productcatalog.dart @@ -7,7 +7,7 @@ import 'ftl_client.dart'; import 'currency.dart' as currency; -class ListRequest { +class ListRequest{ ListRequest(); @@ -26,7 +26,7 @@ class ListRequest { factory ListRequest.fromJson(String source) => ListRequest.fromMap(json.decode(source)); } -class Product { +class Product{ String id; String name; String description; @@ -63,7 +63,7 @@ class Product { factory Product.fromJson(String source) => Product.fromMap(json.decode(source)); } -class ListResponse { +class ListResponse{ List products; ListResponse({ required this.products, }); @@ -85,7 +85,7 @@ class ListResponse { factory ListResponse.fromJson(String source) => ListResponse.fromMap(json.decode(source)); } -class GetRequest { +class GetRequest{ String id; GetRequest({ required this.id, }); @@ -107,7 +107,7 @@ class GetRequest { factory GetRequest.fromJson(String source) => GetRequest.fromMap(json.decode(source)); } -class SearchRequest { +class SearchRequest{ String query; SearchRequest({ required this.query, }); @@ -129,7 +129,7 @@ class SearchRequest { factory SearchRequest.fromJson(String source) => SearchRequest.fromMap(json.decode(source)); } -class SearchResponse { +class SearchResponse{ List results; SearchResponse({ required this.results, }); diff --git a/frontend/mobile/lib/api/recommendation.dart b/frontend/mobile/lib/api/recommendation.dart index 84739cdc..183950f2 100644 --- a/frontend/mobile/lib/api/recommendation.dart +++ b/frontend/mobile/lib/api/recommendation.dart @@ -7,7 +7,7 @@ import 'ftl_client.dart'; import 'productcatalog.dart' as productcatalog; -class ListRequest { +class ListRequest{ String userID; List userProductIDs; @@ -32,7 +32,7 @@ class ListRequest { factory ListRequest.fromJson(String source) => ListRequest.fromMap(json.decode(source)); } -class ListResponse { +class ListResponse{ List productIDs; ListResponse({ required this.productIDs, }); diff --git a/frontend/mobile/lib/api/shipping.dart b/frontend/mobile/lib/api/shipping.dart index b2b1bf6b..980c6244 100644 --- a/frontend/mobile/lib/api/shipping.dart +++ b/frontend/mobile/lib/api/shipping.dart @@ -8,7 +8,7 @@ import 'cart.dart' as cart; import 'currency.dart' as currency; -class Address { +class Address{ String streetAddress; String city; String state; @@ -42,7 +42,7 @@ class Address { factory Address.fromJson(String source) => Address.fromMap(json.decode(source)); } -class ShippingRequest { +class ShippingRequest{ Address address; List items; @@ -67,7 +67,7 @@ class ShippingRequest { factory ShippingRequest.fromJson(String source) => ShippingRequest.fromMap(json.decode(source)); } -class ShipOrderResponse { +class ShipOrderResponse{ String id; ShipOrderResponse({ required this.id, }); diff --git a/frontend/mobile/templates/template.js b/frontend/mobile/templates/template.js index 5279d517..14fa1234 100644 --- a/frontend/mobile/templates/template.js +++ b/frontend/mobile/templates/template.js @@ -31,8 +31,14 @@ function dartType(t) { if (context.name === t.module) { return t.name; } + if (t.typeParameters && t.typeParameters.length > 0) { + return `${t.module}.${t.name}${dartTypeParameters(t.typeParameters)}` + } return `${t.module}.${t.name}`; + case "TypeParameter": + return t.name; + case "Optional": return dartType(t.type) + "?"; @@ -41,6 +47,14 @@ function dartType(t) { } } +function dartTypeParameters (t) { + if (t.length == 0) { + return ""; + } + + return `<${t.map((p) => dartType(p)).join(", ")}>`; +} + function deserialize(t) { switch (typename(t)) { case "Array": diff --git a/frontend/mobile/templates/{{ .Name | lower }}.dart b/frontend/mobile/templates/{{ .Name | lower }}.dart index fdd259ff..7de2acf5 100644 --- a/frontend/mobile/templates/{{ .Name | lower }}.dart +++ b/frontend/mobile/templates/{{ .Name | lower }}.dart @@ -9,7 +9,7 @@ import '{{. | lower }}.dart' as {{. | lower}}; {{- end}} {{ range .Data }} -class {{ .Name | camel }} { +class {{ .Name | camel }}{{ .TypeParameters | dartTypeParameters }}{ {{- range .Fields }} {{ .Type | dartType }} {{ .Name }}; {{- end }} diff --git a/frontend/web/src/api/builtin.ts b/frontend/web/src/api/builtin.ts index a3c8f2cd..0dc40930 100644 --- a/frontend/web/src/api/builtin.ts +++ b/frontend/web/src/api/builtin.ts @@ -9,19 +9,19 @@ // /_/ /_/ /____/ // // -export interface HttpRequest { +export interface HttpRequest { method: string; path: string; pathParameters: Map; query: Map; headers: Map; - body: Uint8Array; + body: Body; } -export interface HttpResponse { +export interface HttpResponse { status: number; headers: Map; - body: Uint8Array; + body: Body; } diff --git a/frontend/web/templates/template.js b/frontend/web/templates/template.js index 87bde6e1..7638fa70 100644 --- a/frontend/web/templates/template.js +++ b/frontend/web/templates/template.js @@ -31,16 +31,30 @@ function tsType(t) { if (context.name === t.module) { return t.name } + if (t.typeParameters && t.typeParameters.length > 0) { + return `${t.module}.${t.name}${tsTypeParameters(t.typeParameters)}` + } return `${t.module}.${t.name}` case 'Optional': return tsType(t.type) + '?' + case "TypeParameter": + return t.name; + default: throw new Error(`Unspported FTL type: ${typename(t)}`) } } +function tsTypeParameters (t) { + if (t.length == 0) { + return ""; + } + + return `<${t.map((p) => tsType(p)).join(", ")}>`; +} + function deserialize(t) { switch (typename(t)) { case 'Array': diff --git a/frontend/web/templates/{{ .Name | lower }}.ts b/frontend/web/templates/{{ .Name | lower }}.ts index 2b2117e2..090850bb 100644 --- a/frontend/web/templates/{{ .Name | lower }}.ts +++ b/frontend/web/templates/{{ .Name | lower }}.ts @@ -15,7 +15,7 @@ import * as {{. | lower }} from "./{{. | lower}}" {{- end}} {{- range .Data }} -export interface {{ .Name | camel }} { +export interface {{ .Name | camel }}{{ .TypeParameters | tsTypeParameters }} { {{- range .Fields }} {{ .Name }}: {{ .Type | tsType }}; {{- end }}