Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
fix: ftl http ingress generics (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman authored Jan 25, 2024
1 parent 7b19762 commit 59900b7
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 51 deletions.
2 changes: 1 addition & 1 deletion backend/online-boutique/services/checkout/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
8 changes: 4 additions & 4 deletions backend/online-boutique/services/checkout/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion backend/online-boutique/services/recommendation/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions backend/online-boutique/services/recommendation/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions frontend/mobile/lib/api/ad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:typed_data';
import 'ftl_client.dart';


class AdRequest {
class AdRequest{
List<String> contextKeys;

AdRequest({ required this.contextKeys, });
Expand All @@ -28,7 +28,7 @@ class AdRequest {
factory AdRequest.fromJson(String source) => AdRequest.fromMap(json.decode(source));
}

class Ad {
class Ad{
String redirectURL;
String text;

Expand All @@ -53,7 +53,7 @@ class Ad {
factory Ad.fromJson(String source) => Ad.fromMap(json.decode(source));
}

class AdResponse {
class AdResponse{
String name;
List<Ad> ads;

Expand Down
8 changes: 4 additions & 4 deletions frontend/mobile/lib/api/builtin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'dart:typed_data';
import 'ftl_client.dart';


class HttpRequest {
class HttpRequest<Body>{
String method;
String path;
Map<String, String> pathParameters;
Map<String, List<String>> query;
Map<String, List<String>> headers;
Uint8List body;
Body body;

HttpRequest({ required this.method, required this.path, required this.pathParameters, required this.query, required this.headers, required this.body, });

Expand Down Expand Up @@ -43,10 +43,10 @@ class HttpRequest {
factory HttpRequest.fromJson(String source) => HttpRequest.fromMap(json.decode(source));
}

class HttpResponse {
class HttpResponse<Body>{
int status;
Map<String, List<String>> headers;
Uint8List body;
Body body;

HttpResponse({ required this.status, required this.headers, required this.body, });

Expand Down
14 changes: 7 additions & 7 deletions frontend/mobile/lib/api/cart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:typed_data';
import 'ftl_client.dart';


class Item {
class Item{
String productID;
int quantity;

Expand All @@ -31,7 +31,7 @@ class Item {
factory Item.fromJson(String source) => Item.fromMap(json.decode(source));
}

class AddItemRequest {
class AddItemRequest{
String userID;
Item item;

Expand All @@ -56,7 +56,7 @@ class AddItemRequest {
factory AddItemRequest.fromJson(String source) => AddItemRequest.fromMap(json.decode(source));
}

class AddItemResponse {
class AddItemResponse{

AddItemResponse();

Expand All @@ -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, });
Expand All @@ -97,7 +97,7 @@ class GetCartRequest {
factory GetCartRequest.fromJson(String source) => GetCartRequest.fromMap(json.decode(source));
}

class Cart {
class Cart{
String userID;
List<Item> items;

Expand All @@ -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, });
Expand All @@ -144,7 +144,7 @@ class EmptyCartRequest {
factory EmptyCartRequest.fromJson(String source) => EmptyCartRequest.fromMap(json.decode(source));
}

class EmptyCartResponse {
class EmptyCartResponse{

EmptyCartResponse();

Expand Down
6 changes: 3 additions & 3 deletions frontend/mobile/lib/api/checkout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions frontend/mobile/lib/api/currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:typed_data';
import 'ftl_client.dart';


class GetSupportedCurrenciesRequest {
class GetSupportedCurrenciesRequest{

GetSupportedCurrenciesRequest();

Expand All @@ -25,7 +25,7 @@ class GetSupportedCurrenciesRequest {
factory GetSupportedCurrenciesRequest.fromJson(String source) => GetSupportedCurrenciesRequest.fromMap(json.decode(source));
}

class GetSupportedCurrenciesResponse {
class GetSupportedCurrenciesResponse{
List<String> currencyCodes;

GetSupportedCurrenciesResponse({ required this.currencyCodes, });
Expand All @@ -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;
Expand Down Expand Up @@ -75,7 +75,7 @@ class Money {
factory Money.fromJson(String source) => Money.fromMap(json.decode(source));
}

class ConvertRequest {
class ConvertRequest{
Money from;
String toCode;

Expand Down
6 changes: 3 additions & 3 deletions frontend/mobile/lib/api/payment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'ftl_client.dart';
import 'currency.dart' as currency;


class CreditCardInfo {
class CreditCardInfo{
String number;
int cVV;
int expirationYear;
Expand Down Expand Up @@ -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;

Expand All @@ -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, });
Expand Down
12 changes: 6 additions & 6 deletions frontend/mobile/lib/api/productcatalog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'ftl_client.dart';
import 'currency.dart' as currency;


class ListRequest {
class ListRequest{

ListRequest();

Expand All @@ -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;
Expand Down Expand Up @@ -63,7 +63,7 @@ class Product {
factory Product.fromJson(String source) => Product.fromMap(json.decode(source));
}

class ListResponse {
class ListResponse{
List<Product> products;

ListResponse({ required this.products, });
Expand All @@ -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, });
Expand All @@ -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, });
Expand All @@ -129,7 +129,7 @@ class SearchRequest {
factory SearchRequest.fromJson(String source) => SearchRequest.fromMap(json.decode(source));
}

class SearchResponse {
class SearchResponse{
List<Product> results;

SearchResponse({ required this.results, });
Expand Down
4 changes: 2 additions & 2 deletions frontend/mobile/lib/api/recommendation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'ftl_client.dart';
import 'productcatalog.dart' as productcatalog;


class ListRequest {
class ListRequest{
String userID;
List<String> userProductIDs;

Expand All @@ -32,7 +32,7 @@ class ListRequest {
factory ListRequest.fromJson(String source) => ListRequest.fromMap(json.decode(source));
}

class ListResponse {
class ListResponse{
List<String> productIDs;

ListResponse({ required this.productIDs, });
Expand Down
6 changes: 3 additions & 3 deletions frontend/mobile/lib/api/shipping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'cart.dart' as cart;
import 'currency.dart' as currency;


class Address {
class Address{
String streetAddress;
String city;
String state;
Expand Down Expand Up @@ -42,7 +42,7 @@ class Address {
factory Address.fromJson(String source) => Address.fromMap(json.decode(source));
}

class ShippingRequest {
class ShippingRequest{
Address address;
List<cart.Item> items;

Expand All @@ -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, });
Expand Down
14 changes: 14 additions & 0 deletions frontend/mobile/templates/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) + "?";

Expand All @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion frontend/mobile/templates/{{ .Name | lower }}.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Loading

0 comments on commit 59900b7

Please sign in to comment.