@arrirpc/codegen-dart 0.66.0 → 0.68.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +19 -10
- package/dist/index.cjs +24 -5
- package/dist/index.mjs +24 -5
- package/package.json +2 -2
package/README.md
CHANGED
@@ -69,28 +69,37 @@ final service = MyClientUsersService(
|
|
69
69
|
);
|
70
70
|
```
|
71
71
|
|
72
|
+
#### Client / Service Options
|
73
|
+
|
74
|
+
| name | Type | description |
|
75
|
+
| ---------- | ------------------------------------------- | ------------------------------------------------------------- |
|
76
|
+
| httpClient | `http.Client` | Use this to pass in a custom `http.Client` instance |
|
77
|
+
| baseUrl | `String` | The base url for the backend server |
|
78
|
+
| headers | `FutureOr<Map<String, String>> Function()?` | A function that returns a Map of headers |
|
79
|
+
| onError | `Function(Object)?` | A hook that fires whenever any error is thrown by the client. |
|
80
|
+
|
72
81
|
### Using Arri Models
|
73
82
|
|
74
83
|
All generated models will be immutable. They will have access to the following features:
|
75
84
|
|
76
85
|
**Methods**:
|
77
86
|
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
87
|
+
- `Map<String, dynamic> toJson()`
|
88
|
+
- `String toJsonString()`
|
89
|
+
- `String toUrlQueryParams()`
|
90
|
+
- `copyWith()`
|
82
91
|
|
83
92
|
**Factory Methods**:
|
84
93
|
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
94
|
+
- `empty()`
|
95
|
+
- `fromJson(Map<String, dynamic> input)`
|
96
|
+
- `fromJsonString(String input)`
|
88
97
|
|
89
98
|
**Overrides**:
|
90
99
|
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
100
|
+
- `==` operator (allows for deep equality checking)
|
101
|
+
- `hashMap` (allows for deep equality checking)
|
102
|
+
- `toString` (will print out all properties and values instead of `Instance of X`)
|
94
103
|
|
95
104
|
This library was generated with [Nx](https://nx.dev).
|
96
105
|
|
package/dist/index.cjs
CHANGED
@@ -866,7 +866,16 @@ function dartHttpRpcFromSchema(schema, context) {
|
|
866
866
|
onMessage: onMessage,
|
867
867
|
onOpen: onOpen,
|
868
868
|
onClose: onClose,
|
869
|
-
onError: onError
|
869
|
+
onError: onError != null && _onError != null
|
870
|
+
? (err, es) {
|
871
|
+
_onError?.call(onError);
|
872
|
+
return onError(err, es);
|
873
|
+
}
|
874
|
+
: onError != null
|
875
|
+
? onError
|
876
|
+
: _onError != null
|
877
|
+
? (err, _) => _onError?.call(err)
|
878
|
+
: null,
|
870
879
|
);
|
871
880
|
}`;
|
872
881
|
}
|
@@ -879,6 +888,7 @@ function dartHttpRpcFromSchema(schema, context) {
|
|
879
888
|
clientVersion: _clientVersion,
|
880
889
|
${paramsType ? "params: params.toJson()," : ""}
|
881
890
|
parser: (body) ${schema.response ? `=> ${responseType}.fromJsonString(body)` : "{}"},
|
891
|
+
onError: _onError,
|
882
892
|
);
|
883
893
|
}`;
|
884
894
|
}
|
@@ -907,6 +917,7 @@ function dartWsRpcFromSchema(schema, context) {
|
|
907
917
|
clientVersion: _clientVersion,
|
908
918
|
parser: (msg) ${responseType ? `=> ${responseType}.fromJsonString(msg)` : "{}"},
|
909
919
|
serializer: (msg) ${paramsType ? "=> msg.toJsonString()" : '=> ""'},
|
920
|
+
onError: _onError,
|
910
921
|
);
|
911
922
|
}`;
|
912
923
|
}
|
@@ -963,14 +974,17 @@ function dartServiceFromSchema(schema, context) {
|
|
963
974
|
final http.Client? _httpClient;
|
964
975
|
final String _baseUrl;
|
965
976
|
final String _clientVersion = "${context.clientVersion}";
|
966
|
-
|
977
|
+
final FutureOr<Map<String, String>> Function()? _headers;
|
978
|
+
final Function(Object)? _onError;
|
967
979
|
${serviceName}({
|
968
980
|
http.Client? httpClient,
|
969
981
|
required String baseUrl,
|
970
982
|
FutureOr<Map<String, String>> Function()? headers,
|
983
|
+
Function(Object)? onError,
|
971
984
|
}) : _httpClient = httpClient,
|
972
985
|
_baseUrl = baseUrl,
|
973
|
-
_headers = headers
|
986
|
+
_headers = headers,
|
987
|
+
_onError = onError;
|
974
988
|
|
975
989
|
${rpcParts.join("\n\n")}
|
976
990
|
|
@@ -979,6 +993,7 @@ function dartServiceFromSchema(schema, context) {
|
|
979
993
|
baseUrl: _baseUrl,
|
980
994
|
headers: _headers,
|
981
995
|
httpClient: _httpClient,
|
996
|
+
onError: _onError,
|
982
997
|
);`
|
983
998
|
).join("\n\n")}
|
984
999
|
}
|
@@ -1191,14 +1206,17 @@ class ${clientName} {
|
|
1191
1206
|
final http.Client? _httpClient;
|
1192
1207
|
final String _baseUrl;
|
1193
1208
|
final String _clientVersion = "${context.clientVersion ?? ""}";
|
1194
|
-
|
1209
|
+
final FutureOr<Map<String, String>> Function()? _headers;
|
1210
|
+
final Function(Object)? _onError;
|
1195
1211
|
${clientName}({
|
1196
1212
|
http.Client? httpClient,
|
1197
1213
|
required String baseUrl,
|
1198
1214
|
FutureOr<Map<String, String>> Function()? headers,
|
1215
|
+
Function(Object)? onError,
|
1199
1216
|
}) : _httpClient = httpClient,
|
1200
1217
|
_baseUrl = baseUrl,
|
1201
|
-
_headers = headers
|
1218
|
+
_headers = headers,
|
1219
|
+
_onError = onError;
|
1202
1220
|
|
1203
1221
|
${rpcParts.join("\n\n")}
|
1204
1222
|
|
@@ -1207,6 +1225,7 @@ ${subServices.map(
|
|
1207
1225
|
baseUrl: _baseUrl,
|
1208
1226
|
headers: _headers,
|
1209
1227
|
httpClient: _httpClient,
|
1228
|
+
onError: _onError,
|
1210
1229
|
);`
|
1211
1230
|
).join("\n\n")}
|
1212
1231
|
}
|
package/dist/index.mjs
CHANGED
@@ -859,7 +859,16 @@ function dartHttpRpcFromSchema(schema, context) {
|
|
859
859
|
onMessage: onMessage,
|
860
860
|
onOpen: onOpen,
|
861
861
|
onClose: onClose,
|
862
|
-
onError: onError
|
862
|
+
onError: onError != null && _onError != null
|
863
|
+
? (err, es) {
|
864
|
+
_onError?.call(onError);
|
865
|
+
return onError(err, es);
|
866
|
+
}
|
867
|
+
: onError != null
|
868
|
+
? onError
|
869
|
+
: _onError != null
|
870
|
+
? (err, _) => _onError?.call(err)
|
871
|
+
: null,
|
863
872
|
);
|
864
873
|
}`;
|
865
874
|
}
|
@@ -872,6 +881,7 @@ function dartHttpRpcFromSchema(schema, context) {
|
|
872
881
|
clientVersion: _clientVersion,
|
873
882
|
${paramsType ? "params: params.toJson()," : ""}
|
874
883
|
parser: (body) ${schema.response ? `=> ${responseType}.fromJsonString(body)` : "{}"},
|
884
|
+
onError: _onError,
|
875
885
|
);
|
876
886
|
}`;
|
877
887
|
}
|
@@ -900,6 +910,7 @@ function dartWsRpcFromSchema(schema, context) {
|
|
900
910
|
clientVersion: _clientVersion,
|
901
911
|
parser: (msg) ${responseType ? `=> ${responseType}.fromJsonString(msg)` : "{}"},
|
902
912
|
serializer: (msg) ${paramsType ? "=> msg.toJsonString()" : '=> ""'},
|
913
|
+
onError: _onError,
|
903
914
|
);
|
904
915
|
}`;
|
905
916
|
}
|
@@ -956,14 +967,17 @@ function dartServiceFromSchema(schema, context) {
|
|
956
967
|
final http.Client? _httpClient;
|
957
968
|
final String _baseUrl;
|
958
969
|
final String _clientVersion = "${context.clientVersion}";
|
959
|
-
|
970
|
+
final FutureOr<Map<String, String>> Function()? _headers;
|
971
|
+
final Function(Object)? _onError;
|
960
972
|
${serviceName}({
|
961
973
|
http.Client? httpClient,
|
962
974
|
required String baseUrl,
|
963
975
|
FutureOr<Map<String, String>> Function()? headers,
|
976
|
+
Function(Object)? onError,
|
964
977
|
}) : _httpClient = httpClient,
|
965
978
|
_baseUrl = baseUrl,
|
966
|
-
_headers = headers
|
979
|
+
_headers = headers,
|
980
|
+
_onError = onError;
|
967
981
|
|
968
982
|
${rpcParts.join("\n\n")}
|
969
983
|
|
@@ -972,6 +986,7 @@ function dartServiceFromSchema(schema, context) {
|
|
972
986
|
baseUrl: _baseUrl,
|
973
987
|
headers: _headers,
|
974
988
|
httpClient: _httpClient,
|
989
|
+
onError: _onError,
|
975
990
|
);`
|
976
991
|
).join("\n\n")}
|
977
992
|
}
|
@@ -1184,14 +1199,17 @@ class ${clientName} {
|
|
1184
1199
|
final http.Client? _httpClient;
|
1185
1200
|
final String _baseUrl;
|
1186
1201
|
final String _clientVersion = "${context.clientVersion ?? ""}";
|
1187
|
-
|
1202
|
+
final FutureOr<Map<String, String>> Function()? _headers;
|
1203
|
+
final Function(Object)? _onError;
|
1188
1204
|
${clientName}({
|
1189
1205
|
http.Client? httpClient,
|
1190
1206
|
required String baseUrl,
|
1191
1207
|
FutureOr<Map<String, String>> Function()? headers,
|
1208
|
+
Function(Object)? onError,
|
1192
1209
|
}) : _httpClient = httpClient,
|
1193
1210
|
_baseUrl = baseUrl,
|
1194
|
-
_headers = headers
|
1211
|
+
_headers = headers,
|
1212
|
+
_onError = onError;
|
1195
1213
|
|
1196
1214
|
${rpcParts.join("\n\n")}
|
1197
1215
|
|
@@ -1200,6 +1218,7 @@ ${subServices.map(
|
|
1200
1218
|
baseUrl: _baseUrl,
|
1201
1219
|
headers: _headers,
|
1202
1220
|
httpClient: _httpClient,
|
1221
|
+
onError: _onError,
|
1203
1222
|
);`
|
1204
1223
|
).join("\n\n")}
|
1205
1224
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arrirpc/codegen-dart",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.68.0",
|
4
4
|
"type": "module",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": {
|
@@ -23,6 +23,6 @@
|
|
23
23
|
],
|
24
24
|
"dependencies": {
|
25
25
|
"pathe": "^1.1.2",
|
26
|
-
"@arrirpc/codegen-utils": "0.
|
26
|
+
"@arrirpc/codegen-utils": "0.68.0"
|
27
27
|
}
|
28
28
|
}
|